IconButton
Square icon-only button on Button's icon size. label is required in TypeScript and rendered as aria-label. All Button variants, loading and asChild are inherited.
Design intent
IconButton removes the footgun of unlabeled icon controls: label is a required prop mapped to aria-label, and sizes stay on the spacing scale. It composes Button so variants, loading and asChild behave identically.
npx @slipstream-ui/cli@latest add icon-buttonProps
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | required | Accessible name rendered as aria-label. |
| size | 'sm' | 'md' | 'lg' | 'md' | Square edge: sm h-8, md h-10, lg h-11. |
| variant | Button variant | — | Inherited from Button. |
| loading | boolean | false | Inherited: spinner, disabled and aria-busy. |
| className | string | — | Additional CSS classes to apply. |
Anti-patterns
validate_usage is the MCP tool that rejects these mistakes: the same list agents see over MCP and in the canonical markdown.
Don't pass icon-only content without label
label is required by the type; omitting it is a compile error, not a runtime warning.
tsx// Avoid (type error)<IconButton><SettingsIcon /></IconButton>// Prefer<IconButton label="Settings"><SettingsIcon /></IconButton>
Accessibility
- label is required by the type and mapped to aria-label — icon-only controls can never ship unnamed.
- Inherits Button focus-visible ring, disabled and loading (aria-busy) semantics.
- sm is h-8 w-8, above the 24px WCAG target minimum.
Content guidelines
Button labels
- Use verb + object phrasing for actions
- Keep labels under 4 words
- Match the tooltip text when one is present
Good examples
- Close dialog
- Copy link
- Open menu
Bad examples
- X
- Click
- Do the thing
Composition
Compose with Button: IconButton composes Button size=icon and inherits variant/loading/asChild
<IconButton label="Refresh" variant="outline" loading={busy}><RefreshIcon/></IconButton>
Compose with Icon: Wrap the icon child in Icon for tone and consistent sizing
<IconButton label="Delete"><Icon icon={TrashIcon} tone="destructive"/></IconButton>
Dependencies
What the registry installs alongside this component. Package imports already include these.
npm packages
- class-variance-authority
- clsx
- tailwind-merge
Browser support
| Browser | Tested versions |
|---|---|
| Chrome | 111+ (Mar 2023) |
| Edge | 111+ (Mar 2023) |
| Firefox | 121+ (Dec 2023) |
| Safari | 17.2+: macOS & iOS (Dec 2023) |
Slipstream components rely only on CSS custom properties, Flexbox/Grid, and ARIA, the everyday baseline of the last two years of evergreen releases. Anything newer is progressive enhancement: unsupported browsers keep full functionality with static behavior instead of animations.