Button
Triggers an action. Verb first, naming the outcome.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Triggers an action. Verb first, naming the outcome.
Import
import { Button } from "@ir/ui";Variants
| Axis | Options | Default |
|---|---|---|
variant | default · neutral · secondary · destructive · outline · ghost · link | default |
size | xs · sm · md · lg · icon-xs · icon-sm · icon-md · icon-lg | md |
Props
| Prop | Type | Required | What it does |
|---|---|---|---|
asChild | boolean | Render as the child element, keeping Button's styling. | |
loading | boolean | Shows a spinner and disables the button. |
Do and don't
Keep Ghost transparent until hover.
Don't — Give Ghost a resting background.
A ghost with a resting fill reads as Outline, so the hierarchy between a primary and a tertiary action collapses and every toolbar looks equally important.
Leave Link as text, coloured by fg/link/*.
Don't — Put Link in a box — fill, border or radius.
A link drawn as a button is ambiguous about whether it navigates or acts. fg/link carries it at 7.66:1 without a box.
Underline on hover only.
Don't — Underline Link at rest.
textDecoration propagates across every node sharing a text style, so underlining Link in Figma underlines all 168 buttons. Colour distinguishes it; the underline is a hover affordance.
Pass aria-label on every icon-* size.
Don't — Ship an icon-only button with no accessible name.
Screen readers announce nothing. The icon sizes have no text child by definition, so the label has to come from the attribute.
Pick Size for height and touch target.
Don't — Reach for a larger Size to get bigger text.
Size changes height and padding; the label stays label/md. Resizing an instance to force a height is how 36 instances ended up off-scale.
Leave it at its variant height.
Don't — Set a Button to vertical HUG in Figma.
Its vertical padding is inert, so a HUG instance collapses to 16–18px. This broke 22 instances once already.
One primary; everything else a step quieter.
Don't — Put two primary buttons side by side.
Primary means “this is the next thing to do”. Two of them means neither is, and the reader has to work out the hierarchy the design was supposed to give them.
Name the outcome — "Save changes", "Delete probe", "Export CSV".
Don't — Label a button "Submit", "OK" or "Yes".
The label is the only thing many people read before clicking. Two or three words; if it needs more, the explanation belongs above the button.
Name the thing in both the button and the confirm.
Don't — Use Destructive without a confirmation that restates what is lost.
Destructive is a warning, not a safeguard. "Delete probe" then "Delete probe SYD-03? Its history is removed."
Accessibility
- Focus ring is border/focused at 2px with a 2px offset; never remove it.
- loading sets aria-busy and disables the button — a busy button must not be activatable.
- Disabled contrast is 2.24:1 by design. SC 1.4.3 exempts disabled controls; the low contrast is the signal.
Where it is drawn
Figma — structure from figma, measurements from shadcn.