Overview
Reference usage
A clickable button or anchor with built-in loading state, icon slots, and a discriminated prop union that forces consumers to provide an accessible name at compile time.
Usage
When href is set, the component renders as <a>; otherwise it renders as <button>. Setting loading swaps in a spinner, blocks the consumer's onclick, forces aria-disabled / aria-busy, and strips href to prevent navigation. While loading the cursor is progress and the button keeps full strength; a page that dims it sets --cinder-button-loading-opacity (for example 0.75) on it. The width is held when the label stays or gets shorter; a longer label that arrives with loading ("Create", "Creating…") lets the width go so it never spills over the border.
Sizes
md is the default and the size for inline actions: the buttons in a row, a card, a dialog footer, or a toolbar. Use sm or xs where space is tight. Reserve lg for a page-level primary action, such as the one call to action that a page is organized around. A screen with several lg buttons has no primary action.
Disabled
A disabled button looks the same in every variant: a neutral surface (or none, for ghost and ghost-danger), --cinder-text-disabled text, and the shared disabled opacity. It never keeps its tone while disabled, so a disabled danger or ghost-danger button does not read as a faded red button. A primary button also never takes a tone from its container: inside a danger Card it is still the primary button.
Toggle buttons
Pass aria-pressed="true" or "false" to make a button a toggle. A pressed button takes the filled accent face (every variant except primary and danger, which are already filled); see button.a11y.md. This applies to every Button that carries aria-pressed="true", including a consumer's own: for example, kanban-board.svelte sets it on a column's drag handle while that column is lifted, so a lifted column's handle now takes the filled face. No committed Cinder baseline shows a pressed Button at rest besides the new button/*-pressed images, which the baseline refresh confirmed.
When to use
- Triggering a discrete action such as submit, save, or delete.
- Rendering a link that should look and behave like a button by passing href.
- Toggling a binary on or off state — use toggle instead.
- Selecting one of a small fixed set of options — use segmented-control instead.
Examples
Button as link
Passing href renders an anchor element with button styling.
Disabled button
A plain (non-icon-only) disabled button. The secondary variant has no variant-specific disabled override, so its border color comes from the base disabled rule in button.css while its opacity comes from the shared disabled-visual rule in foundation.css.
Icon-only buttons
Icon-only buttons keep the visual surface compact while still carrying an accessible name through label or aria-label.
Inert buttons with a reason
An aria-disabled button stays focusable, ignores the press and says why through aria-describedby and a tooltip. Icon-only inert buttons keep their accessible name; the live Export beside them still works.
Loading state
A permanent loading button alongside one that toggles loading on click; both render the spinner and set aria-busy.
Loading: label, width and spinner
Press "Start" to put every button in flight. When the label stays (Save), the width does not move; shorter words (Testing…) keep the width; longer words (Creating…) take the width they need so they never spill over the border. A page that dims the button while it works sets --cinder-button-loading-opacity (Connecting…).
Primary button
The default button variant.
Button sizes
xs, sm, md, and lg sizes, on the shared 24/28/32/40px control height scale. Use md for inline actions and keep lg for a page-level primary action.
Soft variants
Soft and soft-danger use a tinted fill with no border — mid-emphasis between ghost and primary/danger.
Text + icon buttons
leadingIcon and trailingIcon snippets are decorative-only and wrap their SVGs in aria-hidden. Meaning still lives in the button label.
Top bar icon buttons
Notifications and quick settings as 32px icon-only buttons. They rest as the bare glyph (quiet). Each has an aria-label, the notifications label carries the unread count, and hover, focus and pressed are distinct; focus uses the shared quiet ring.
Button variants
Primary, secondary, danger, and ghost styles.
Props
Name | Type | Default | Description |
|---|---|---|---|
variant | 'primary''secondary''soft''danger''soft-danger''ghost''ghost-danger''ghost-accent' | 'secondary' | Visual style. |
size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Size of the button. lg is for page-level primary actions only; inline actions use md. |
fullWidth | boolean | false | Expand to container width. |
loading | boolean | false | Show a spinner and make the button inert while work is in flight. The button gets
aria-disabled and aria-busy (not the native disabled, so it keeps focus), keeps its
label, ignores further presses, and holds the width it had at rest. |
loadingStatus | text | Text a polite, visually hidden status announces while loading (for example Saving…).
The status node is rendered beside the button, so it never joins the button's accessible
name, and it is mounted from the start so the announcement is not lost. Omit it and no
status node is rendered. | |
mutating | boolean | false | Marks a button that changes something (Edit, Save, Delete, a header "+"). Inside a stale
<StaleRegion> it goes inert: aria-disabled, still focusable, ignoring the press, and
described by the region's reason ("Off until it’s back"). It returns by itself when the
region stops being stale. A button that only reads (a link, Retry now) leaves this off and
stays live. |
iconOnly | false | false | |
quiet | boolean | false | Rests as the bare glyph: drops the resting fill and rule an icon-only ghost button
otherwise paints, for a toolbar such as the shell's top bar. Hover, pressed and focus still
paint. It has no effect unless the button is iconOnly with variant="ghost". |
leadingIcon | snippet | DECORATIVE icon rendered before the label/children. Always wrapped in aria-hidden.
If the icon conveys meaning, supply accessible text via label/aria-label instead. | |
trailingIcon | snippet | DECORATIVE icon rendered after the label/children. Always wrapped in aria-hidden.
Same accessible-name guidance as leadingIcon. | |
children | snippet | ||
label | text | ||
href | discriminated-union | ||
onclick | MouseEventHandler<T> | undefined | null |