Group-icon button

Group-icon button family from the ai2 styled layer: five icon-first action groups (IconButtonGroup, LabelButtonGroup, MixedButtonGroup, CompactIconButtonGroup, TooltipButtonGroup) that differ in how much of each button's label is visible. Sizes run from sm to xl and colors come only from ai2 semantic tokens.

componentstyledbuttonregistry-item.json
Group-icon button
LIVE · running in a sandboxed iframe
Installed with shadcn add · 2 workarounds · theme from registry.json
  • applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
  • installed base item https://ai2.design/r/tokens.json (registry preview settings)
See how it was built

Installation

pnpm dlx shadcn@latest add @ai2/button-group-icon

Requires @ai2 in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { IconButtonGroup } from "@/components/ui/button-group-icon"export function Toolbar() {  return <IconButtonGroup size="md" />}
  • Compact toolbars for text formatting, alignment, or editor actions where icons are the primary affordance.
  • Icon plus label rows where some actions need a visible word and others only need an icon (MixedButtonGroup).
  • Dense inspector or sidebar rails that need a tight icon-only strip (CompactIconButtonGroup).
  • Icon-only toolbars where a keyboard- and focus-reachable tooltip should explain each icon (TooltipButtonGroup).

Examples

Icon-only toolbar with custom actions

Icon-only group where every button gets an aria-label from its label field.

icon-only-toolbar-with-custom-actions.tsx
import { AlignLeft, AlignCenter, AlignRight } from "lucide-react"import { IconButtonGroup } from "@/components/ui/button-group-icon"export default function AlignToolbar() {  return (    <IconButtonGroup      size="lg"      actions={[        { label: "Align left", icon: <AlignLeft />, onClick: () => console.log("left") },        { label: "Align center", icon: <AlignCenter />, onClick: () => console.log("center") },        { label: "Align right", icon: <AlignRight />, onClick: () => console.log("right") },      ]}    />  )}

Icon with visible labels

LabelButtonGroup renders each icon followed by its visible label text.

icon-with-visible-labels.tsx
import { Bold, Italic, Underline } from "lucide-react"import { LabelButtonGroup } from "@/components/ui/button-group-icon"export default function FormatLabels() {  return (    <LabelButtonGroup      size="sm"      actions={[        { label: "Bold", icon: <Bold />, onClick: () => {} },        { label: "Italic", icon: <Italic />, onClick: () => {} },        { label: "Underline", icon: <Underline />, onClick: () => {} },      ]}    />  )}

Primary action with icon rail

MixedButtonGroup puts the first action in a labeled primary button and renders the rest as icon-only.

primary-action-with-icon-rail.tsx
import { Save, Copy, Trash2 } from "lucide-react"import { MixedButtonGroup } from "@/components/ui/button-group-icon"export default function SaveBar() {  return (    <MixedButtonGroup      size="md"      actions={[        { label: "Save", icon: <Save />, onClick: () => {} },        { label: "Copy", icon: <Copy />, onClick: () => {} },        { label: "Delete", icon: <Trash2 />, onClick: () => {} },      ]}    />  )}

API reference

PropTypeDefaultDescription
classNamestring—Extra classes merged onto the group container via cn(). Applied to the root div for all five components.
sizeStyledSize ("sm" | "md" | "lg" | "xl")"md"Size of the buttons. Labeled variants use h-8, h-9, h-10, h-12 with horizontal padding and text size; icon-only variants use size-8, size-9, size-10, size-12. CompactIconButtonGroup and MixedButtonGroup's icon buttons use the icon sizes.
actionsAction[] where Action = { label?: string; icon?: React.ReactNode; onClick?: () => void }[{ label: "Bold", icon: <Bold /> }, { label: "Italic", icon: <Italic /> }, { label: "Underline", icon: <Underline /> }]Ordered list of actions to render. label is the visible text for LabelButtonGroup and MixedButtonGroup's primary button, and the aria-label for icon-only buttons. icon is rendered inside the button. onClick is attached to each button. In TooltipButtonGroup, label is the tooltip text, and no tooltip is shown when label is missing.

Accessibility

  • Every icon-only button needs a label, which is set as aria-label. With no visible text, this is the only accessible name.
  • The group container is role="group" with aria-label "Text formatting". This fixed label is not configurable through props, so change the source if a different group name is needed.
  • TooltipButtonGroup opens the tooltip on focus and on pointer enter, and closes it on blur, pointer leave, or Escape. The tooltip is linked with aria-describedby while open, and the accessible name still comes from aria-label.
  • Focused buttons show a visible 3px focus ring and are raised with focus-visible:z-10.
  • Disabled styling uses disabled:pointer-events-none and disabled:opacity-50, but the components do not accept a disabled prop, so disabling requires editing the source.
  • Buttons are type="button" so they do not submit surrounding forms.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Group-icon button" component (ai2/button-group-icon) from its shadcn registry.1. Install it with: npx shadcn@latest add @ai2/button-group-icon2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: className, size, actions.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { IconButtonGroup } from "@/components/ui/button-group-icon"export function Toolbar() {  return <IconButtonGroup size="md" />}```

Files & dependencies

  • registry/ai2/styled/button-group-icon.tsx→ components/ui/button-group-icon.tsx
dependencieslucide-react@^1.23.0
registryDependencies@ai2/tokens

Looks similar, elsewhere