IconButton

Compact square button for icon-only actions in dense toolbars, top bars, and row controls.

Setup

import { IconButton } from '@usefragments/ui';

Examples

Toolbar action

A named icon-only toolbar action

Loading preview...

Pressed state

A toggle-style action with its state exposed

Loading preview...

Props

PropTypeDefaultDescription
childrenRequirednodeNot setIcon element rendered inside the button
variantenumghostsubtleoutlinedghostVisual treatment for the icon-only action
sizeenumsmmdlg"md"Control size aligned with adjacent fields and toolbar actions
pressedbooleanNot setMarks a toggle-style action as pressed and sets aria-pressed
typeenumsubmitresetbuttonbutton
aria-labelstringNot setAccessible action name when no labelled-by relationship is available
aria-labelledbystringNot setID reference for an external accessible action label

Usage Guidelines

When to use

  • Compact icon-only actions in toolbars or top bars
  • Row actions where a text button would be too wide
  • Toggle-style icon actions with a visible pressed state

When not to use

  • The action needs a visible text label (use Button)
  • The control changes a persistent boolean setting (use Switch)
  • The icon is decorative and not interactive (use Icon)

Best practices

  • Always provide aria-label or aria-labelledby
  • Use ghost for ordinary toolbar actions and outlined when more separation is needed
  • Use pressed only when the button represents a persistent toggle state
Accessibility
  • Every icon-only button must have an accessible name
  • The accessible name should describe the action, not the icon
  • Pressed state must be exposed with aria-pressed