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.
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.
Loading state
A permanent loading button alongside one that toggles loading on click; both render the spinner and set aria-busy.
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.
Button variants
Primary, secondary, danger, and ghost styles.
Props
Name | Type | Default | Description |
|---|---|---|---|
variant | 'primary''secondary''soft''danger''soft-danger''ghost''ghost-danger' | '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 | Disable the button and show a spinner. |
iconOnly | false | false | |
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 |