Icon Button
Alignment target:@astryxdesign/core v0.7.1 · IconButton
<IconButton
label="Add"
variant="secondary"
size="md"
>
<Icon name="carbon:add" />
</IconButton>IconButton Props #
IconButton inherits most Button props but does not expose isIconOnly, because it is always icon-only.
| Name | Type | Default | Description |
|---|---|---|---|
label | string | required | Accessible name for the button. |
variant | 'primary' | 'secondary' | 'ghost' | 'destructive' | 'secondary' | Visual hierarchy and semantic variant. |
size | 'sm' | 'md' | 'lg' | 'md' | Square control size. |
elevation | 'none' | 'low' | 'med' | 'high' | 'none' | Resting shadow depth for a standalone floating button. |
isDisabled | boolean | false | Disables interaction. The button never uses the native disabled attribute: it is marked aria-disabled and stays in the Tab order, so keyboard and screen-reader users can still reach it. |
isLoading | boolean | false | Shows loading state, sets aria-busy, and disables non-interruptible activation. |
isInterruptible | boolean | false | Allows clickAction to run again while earlier work is pending. |
clickAction | (event: MouseEvent) => void | Promise<void> | — | Action function that automatically drives pending state. |
tooltip | string | — | Supplementary hint shown on hover and keyboard focus. |
href | string | — | Renders the enabled root as a link when present. |
width | number | string | — | Button width. Numbers become pixels; CSS strings are used as supplied. |
These props are also inherited. See Button props for their definitions.
type.name.value.form.loadingLabel.as.target.rel.
Slot #
- The default slot is required.
- The default slot must contain one icon that represents the action.
IconButtondoes not display text.IconButtondoes not provide anendslot.
Accessible name
Provide an accurate label. Without it, assistive technology cannot identify the button's purpose.
tooltip provides additional information. Do not use it instead of label.
Events #
The click event passes a MouseEvent.
Template ref #
IconButton exposes element. Its type is HTMLButtonElement | HTMLAnchorElement | HTMLElement | null. In link mode (with href and not disabled) it is the link element: the anchor, or the root element of the as link component. Otherwise it is the button.
Native attributes #
The root element receives:
- HTML attributes.
aria-*attributes.data-*attributes.class.style.- Native event listeners.