Button
The element users press to make something happen. Nine variants, four sizes, three shapes, and one rule: only one of them can be the most important thing on the screen.
Also called CTA, Icon Button, FAB, Floating Action Button, Link Button — in this system all of them are Button.
Everything below is the real component. Change the controls, tab through it, and turn on Inspector Mode to read any value off the screen.
Variants
The first four are the ladder: read them as most to least emphasis. The other five belong to a place. Hover and focus are pinned here so they can be seen without a pointer; every button is also live.
Tone, shape and relatives
What changes a button without changing its variant, and the components built out of it.
Sizes
Four heights, all multiples of 4. Medium is the default and should cover roughly 90% of usage.
Interaction states
Every state a user can put this component into, rendered side by side. If a state is missing here, it is missing in production too.
Every part, every measurement, and the reason it is that number.
Medium button, primary variant, pill shape. The hatched area is padding; the dashed outline is the pointer target, which is larger than the visual box on touch devices.
- Horizontal padding16px (md, pill)
Twice the 8px icon–label gap. A pill’s ends are round, so it takes 2px more than the squarer shapes do at the same size: the label has to clear the curve, not just the edge.
- Shapepill · rounded · rectangle
Pill is the default: a fully rounded end is the one silhouette on a page that is unmistakably pressable. Rounded takes the radius inputs use (8px at md), for a button in a row of fields; rectangle is for a button set flush into an edge.
- Icon16px, 1.75 stroke
Sub-linear scaling: a 1.5× taller button gets a 1.2× larger icon. Matching the icon to the cap height rather than the line height keeps it optically aligned with the text.
- Height36px = 9 × 4px
On the 4px grid, so a button aligns with an input, a select and a segmented control without any per-component nudging.
- Hover wash--btn-wash, 0 → 100% in 120ms
One translucent layer over whatever the fill is, so hover is the same small step on a clear button, a filled one and a gradient. There is no shadow: these buttons are flat, and the wash is the whole of the feedback.
Values are read live from the running stylesheet, so this table can never drift from the code. Click any value to copy it.
Color
| Token | Value | Used for |
|---|---|---|
| --ds-btn-primary | — | Primary fill; also a selected secondary, glass or nav button |
| --ds-btn-primary-fg | — | Label and icon on the primary fill |
| --ds-btn-wash-inverse | — | Hover wash over the primary fill |
| --ds-layer-hover | — | Hover wash on secondary, tertiary and standard |
| --ds-border-interactive | — | Secondary edge |
| --ds-btn-quiet | — | Standard fill; an inactive primary |
| --ds-btn-disabled | — | Disabled fill |
| --ds-fg-disabled | — | Disabled label |
| --ds-aura-from | — | Aura, first stop |
| --ds-aura-to | — | Aura, last stop |
| --ds-fog-thin | — | Nav fill |
| --ds-fog-thick | — | Frosted glass at rest |
| --ds-fog-dense | — | Frosted glass on hover |
| --ds-smoke-thick | — | Smoked glass at rest |
| --ds-smoke-dense | — | Smoked glass on hover |
| --ds-danger | — | Primary fill under the danger tone |
| --ds-danger-text | — | Secondary and tertiary label under the danger tone |
| --ds-focus-ring | — | Focus outline |
Spacing
| Token | Value | Used for |
|---|---|---|
| padding-x | xs / sm / md / lg horizontal padding on a pill (10 / 12 / 14 / 20px on the other shapes) | |
| gap | Space between icon and label |
Radius
| Token | Value | Used for |
|---|---|---|
| pill | The default shape, at every size | |
| --radius-sm | xs corners on the rounded shape | |
| --radius-md | sm and md corners on the rounded shape | |
| --radius-lg | lg corners on the rounded shape |
Typography
| Token | Value | Used for |
|---|---|---|
| --text-label-sm | xs label | |
| --text-label | sm and md labels | |
| --text-label-lg | lg label |
Motion
| Token | Value | Used for |
|---|---|---|
| --ease-standard | Color and wash transitions | |
| duration | Hover and press feedback | |
| backdrop blur | Nav and both glass variants |
Pick a size from this table. Do not invent a new one — a fourth height is how a design system starts dying.
| Size | Height | Padding | Radius | Icon | Label gap | Type | Min width | Max width | Touch target | When to use |
|---|---|---|---|---|---|---|---|---|---|---|
| Extra small | 28px | 0 12px | pill | 13px | 6px | 14px / 500 | 56px | — | 44px (padded) | Inside table rows, chips and dense toolbars. Never as a form’s primary action. |
| Small | 32px | 0 14px | pill | 14px | 6px | 15px / 500 | 64px | — | 44px (padded) | Card footers, panel headers, secondary toolbars, filter bars. |
| Medium | 36px | 0 16px | pill | 16px | 8px | 15px / 500 | 72px | 20rem | 44px (padded) | The default. Forms, dialogs, page headers — reach for anything else only with a reason. |
| Large | 44px | 0 24px | pill | 18px | 8px | 17px / 500 | 96px | 24rem | 44px (native) | Marketing pages, mobile primary actions, checkout. One per screen at most. |
Not a checklist to run at the end. These are the requirements the component was built from.
Contrast
- Label against the button fill must reach 4.5:1. Primary is #101010 on #E5E4E3 → 15.0:1 in dark, white on #171A20 → 17.4:1 in light. Aura takes a white label at 4.7:1 on both of its stops.
- The button’s own edge against the page must reach 3:1 for the secondary and tertiary variants, or the control is invisible to low-vision users until hovered.
- Glass has no ground of its own, so it has no fixed ratio: the label sits on whatever is behind it, blurred and tinted. Check a glass button against the actual picture, at its brightest point, and switch from frosted to smoked when it fails.
- An inactive button is still pressable, so its label still clears 4.5:1. Only disabled gives contrast up.
- The focus ring must reach 3:1 against both the button and the surrounding surface — this is why the ring sits at 2px offset rather than flush.
- Disabled controls are exempt from contrast requirements, which is exactly why "disable it" is not an accessibility solution.
Keyboard
| Tab | Moves focus to the button in DOM order. |
| Enter | Activates. On a <button type="submit"> also submits the form. |
| Space | Activates on key-up, so the user can slide off to cancel. |
| ↓ / Alt+↓ | On a split button, opens the options menu. |
| Esc | Closes an open split-button menu and returns focus to the trigger. |
Screen readers
- The accessible name comes from the visible label. Do not add an aria-label that differs from it — voice-control users say what they see.
- Loading and success states expose a visually hidden "Loading" / "Done" string so the change is announced, not just drawn.
- Icons inside buttons are aria-hidden. Announcing "save icon Save changes button" is noise.
- Never nest a button inside an anchor or vice versa: the accessibility tree becomes ambiguous and activation behavior differs per browser.
Focus & touch
- A 2px solid ring in --ds-focus-ring at 2px offset, applied with :focus-visible so pointer users never see it and keyboard users always do. The ring is never removed — if it clashes with a layout, the layout is wrong.
- Every size renders a 44 × 44 pointer target via an ::after overlay applied on coarse pointers, so a 28px toolbar button is still thumb-safe on a tablet without inflating the desktop layout. Adjacent targets keep at least 8px of clear space.
| Attribute | Applied to | Notes |
|---|---|---|
| aria-label | IconButton | Required. Without it the button announces as "button" and is unusable by name. |
| aria-busy="true" | button | Set while loading so assistive tech knows the action is in flight rather than ignored. |
| aria-disabled | button | Prefer over the disabled attribute when the button must stay focusable and explain itself. |
| aria-expanded / aria-haspopup | Split button trigger | On the disclosure half only. The primary half stays a plain button. |
| aria-pressed | Toggle buttons | Only for buttons that stay pressed. A button that fires and returns must not use it. The `active` prop only changes the look — the caller sets this, because only the caller knows whether the button is a toggle. |
| aria-current="page" | Nav button | Marks the pill for the page you are on, and is also what gives it the primary look. There is no separate prop, so the look and the announcement cannot disagree. |
Example usage
The common cases. Everything else is a combination of these props.
1import { Button, IconButton, SplitButton, Fab } from '@/ui/Button'2import { Save, Trash2, Plus, Copy } from 'lucide-react'34// Primary action — one per view5<Button onClick={save}>Save changes</Button>67// With an icon and a loading state that holds its width8<Button startIcon={<Save />} loading={isSaving}>9 Save changes10</Button>1112// The rest of the ladder13<Button variant="secondary">Save draft</Button>14<Button variant="standard">Duplicate</Button>15<Button variant="tertiary">Cancel</Button>1617// Destructive is a tone on a variant — always paired with a confirmation step18<Button tone="danger" startIcon={<Trash2 />} onClick={confirmDelete}>19 Delete 3 projects20</Button>21<Button variant="secondary" tone="danger">Revoke access</Button>2223// The selected option of a set takes the primary look24<Button variant="secondary" active={view === 'week'} aria-pressed={view === 'week'}>25 Week26</Button>2728// Navigation: aria-current is the look and the announcement29<Button variant="nav" aria-current={here ? 'page' : undefined}>Library</Button>3031// Over a picture32<Button variant="frosted-glass">Play</Button>33<Button variant="smoked-glass" borderless>Share</Button>3435// The signature call to action36<Button variant="aura" size="lg">Start for free</Button>3738// A squarer shape, for a row of fields39<Button shape="rounded">Apply</Button>4041// Icon only — aria-label is required, not optional42<IconButton label="Copy to clipboard" icon={<Copy />} />4344// Default action plus its variants45<SplitButton46 label="Deploy"47 onAction={deployToStaging}48 options={[49 { label: 'Deploy to production', description: 'Requires two approvals' },50 { label: 'Cancel queued deploy', danger: true },51 ]}52/>5354// One FAB per screen, maximum55<Fab icon={<Plus />} label="New project" extended />Framework-free HTML
No framework required. The classes below map 1:1 to the tokens, so this snippet behaves identically inside the design system.
<button type="button" class="ds-btn ds-btn--primary ds-btn--md">
<span class="ds-btn__content">
<svg class="ds-btn__icon" width="16" height="16" aria-hidden="true">…</svg>
Save changes
</span>
</button>
<!-- Loading: label stays in the DOM so the width never changes -->
<button type="button" class="ds-btn ds-btn--primary ds-btn--md" aria-busy="true" disabled>
<span class="ds-btn__content is-hidden">Save changes</span>
<span class="ds-btn__spinner" aria-hidden="true"></span>
<span class="sr-only">Loading</span>
</button>
<!-- A selected option, and the navigation pill for the current page -->
<button type="button" class="ds-btn ds-btn--secondary ds-btn--sm" data-active aria-pressed="true">
<span class="ds-btn__content">Week</span>
</button>
<a class="ds-btn ds-btn--nav ds-btn--md" href="/library" aria-current="page">
<span class="ds-btn__content">Library</span>
</a>
<!-- Icon only -->
<button type="button" class="ds-btn ds-btn--tertiary ds-btn--md ds-btn--icon" aria-label="Copy to clipboard">
<span class="ds-btn__content"><svg width="16" height="16" aria-hidden="true">…</svg></span>
</button>CSS
Every color is a token. A variant is two or three lines, because all it does is fill in slots the base class reads.
.ds-btn {
/* The five slots. A variant fills these in and styles nothing else. */
--btn-bg: transparent;
--btn-text: currentColor;
--btn-border: transparent;
--btn-wash: var(--ds-layer-hover);
--btn-blur: 0px;
position: relative;
isolation: isolate;
display: inline-flex;
align-items: center;
justify-content: center;
white-space: nowrap;
user-select: none;
font: inherit;
font-weight: 500;
border: 0;
border-radius: 9999px;
color: var(--btn-text);
background-color: var(--btn-bg);
/* The edge is an inset ring, so a button with one is the size of one without. */
box-shadow: inset 0 0 0 1px var(--btn-border);
transition:
background-color 120ms var(--ease-standard),
color 120ms var(--ease-standard),
box-shadow 120ms var(--ease-standard),
transform 120ms var(--ease-standard);
}
/* The hover wash: one layer over whatever the fill is. */
.ds-btn::before {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
background: var(--btn-wash);
opacity: 0;
transition: opacity 120ms var(--ease-standard);
pointer-events: none;
}
.ds-btn:enabled:hover::before,
.ds-btn:enabled:active::before { opacity: 1; }
.ds-btn__content { position: relative; display: inline-flex; align-items: center; gap: 8px; }
/* Guarantees a 44px target on touch without changing desktop layout */
@media (pointer: coarse) {
.ds-btn::after {
content: '';
position: absolute;
inset-inline: 0;
top: 50%;
height: 44px;
transform: translateY(-50%);
}
}
.ds-btn:active { transform: scale(0.985); }
.ds-btn:focus-visible {
outline: 2px solid var(--ds-focus-ring);
outline-offset: 2px;
}
/* --- sizes: the padding is the pill's --- */
.ds-btn--xs { height: 28px; padding-inline: 12px; font-size: 0.875rem; } /* 14px */
.ds-btn--sm { height: 32px; padding-inline: 14px; font-size: 0.9375rem; } /* 15px */
.ds-btn--md { height: 36px; padding-inline: 16px; font-size: 0.9375rem; } /* 15px */
.ds-btn--lg { height: 44px; padding-inline: 24px; font-size: 1.0625rem; } /* 17px */
.ds-btn--icon { padding-inline: 0; aspect-ratio: 1; }
/* --- shapes --- */
.ds-btn--rounded { border-radius: var(--radius-md); }
.ds-btn--rectangle { border-radius: 0; }
/* --- variants: each one only fills in slots --- */
.ds-btn--primary {
--btn-bg: var(--ds-btn-primary);
--btn-text: var(--ds-btn-primary-fg);
--btn-wash: var(--ds-btn-wash-inverse);
}
.ds-btn--secondary { --btn-text: var(--ds-fg); --btn-border: var(--ds-border-interactive); }
.ds-btn--tertiary { --btn-text: var(--ds-fg); }
.ds-btn--standard { --btn-bg: var(--ds-btn-quiet); --btn-text: var(--ds-fg); }
.ds-btn--aura {
--btn-bg: var(--ds-aura-to);
--btn-text: var(--ds-aura-fg);
--btn-wash: var(--ds-aura-wash);
background-image: var(--ds-aura);
}
.ds-btn--nav {
--btn-bg: var(--ds-fog-thin);
--btn-text: var(--ds-fg);
--btn-wash: color-mix(in srgb, currentColor 10%, transparent);
--btn-blur: 16px;
}
.ds-btn--frosted-glass {
--btn-bg: var(--ds-fog-thick);
--btn-text: var(--ds-fg);
--btn-border: var(--ds-border);
--btn-wash: transparent;
--btn-blur: 16px;
}
.ds-btn--frosted-glass:enabled:hover { --btn-bg: var(--ds-fog-dense); }
.ds-btn--smoked-glass {
--btn-bg: var(--ds-smoke-thick);
--btn-text: var(--ds-fg);
--btn-border: var(--ds-border);
--btn-wash: transparent;
--btn-blur: 16px;
}
.ds-btn--smoked-glass:enabled:hover { --btn-bg: var(--ds-smoke-dense); }
.ds-btn--inherit { --btn-wash: color-mix(in srgb, currentColor 10%, transparent); }
.ds-btn--borderless { --btn-border: transparent; }
/* Only the glass variants pay for a backdrop root. */
.ds-btn--nav,
.ds-btn--frosted-glass,
.ds-btn--smoked-glass { backdrop-filter: blur(var(--btn-blur)); }
/* --- states are second recipes over the same slots --- */
.ds-btn[data-active],
.ds-btn--nav[aria-current='page'] {
--btn-bg: var(--ds-btn-primary);
--btn-text: var(--ds-btn-primary-fg);
--btn-border: transparent;
--btn-wash: var(--ds-btn-wash-inverse);
}
.ds-btn--danger.ds-btn--primary { --btn-bg: var(--ds-danger); --btn-text: var(--ds-danger-fg); }
.ds-btn--danger.ds-btn--secondary,
.ds-btn--danger.ds-btn--tertiary { --btn-text: var(--ds-danger-text); --btn-wash: var(--ds-danger-subtle); }
.ds-btn--danger.ds-btn--secondary { --btn-border: var(--ds-danger-border); }
.ds-btn:disabled {
--btn-bg: var(--ds-btn-disabled);
--btn-text: var(--ds-fg-disabled);
--btn-border: transparent;
background-image: none;
pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
.ds-btn, .ds-btn::before { transition-duration: 1ms; }
.ds-btn:active { transform: none; }
}Component API
Button
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | 'primary' | 'secondary' | 'tertiary' | 'standard' | 'aura' | 'nav' | 'frosted-glass' | 'smoked-glass' | 'inherit' | 'primary' | The first four are the emphasis ladder — one primary button per view. The other five belong to a place: a call to action, navigation, a control over a picture, a link in running text. |
| size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Height and padding preset. Do not override with a className. |
| shape | 'pill' | 'rounded' | 'rectangle' | 'pill' | Rounded takes the radius inputs use, for a button in a row of fields. Rectangle is square. |
| tone | 'danger' | — | Recolors primary, secondary and tertiary for a destructive action. The other variants ignore it. |
| active | boolean | false | The selected option of a set: takes the primary look. Set aria-pressed yourself if it is a toggle. |
| inactive | boolean | false | Still pressable, but not the live option. Dimmed, never below 4.5:1. |
| borderless | boolean | false | Drops the edge of a glass variant. |
| loading | boolean | false | Overlays a spinner, hides the label without unmounting it, sets aria-busy and disables interaction. |
| success | boolean | false | Shows a check for confirmation. Reset it yourself after ~1.5s. |
| startIcon | ReactNode | — | Leading icon. Sized automatically. |
| endIcon | ReactNode | — | Trailing icon, for disclosure or direction. |
| fullWidth | boolean | false | Stretches to the container. Mobile and dialog footers only. |
| iconOnly | boolean | false | Renders square. Prefer <IconButton>, which forces a label. |
| disabled | boolean | false | Use sparingly — see Don’t #2. |
IconButton
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | string | — | Accessible name. There is no fallback. |
| icon* | ReactNode | — | The glyph. Sized from the button size. |
| variant | ButtonVariant | 'tertiary' | Same variants as Button. |
| size | 'xs' | 'sm' | 'md' | 'lg' | 'md' | Renders as a square of this height — a circle, on the default pill shape. |
SplitButton
| Prop | Type | Default | Description |
|---|---|---|---|
| label* | string | — | The default action’s label. |
| onAction | () => void | — | Fired by the primary half. |
| options* | { label, description?, onSelect?, danger? }[] | — | Menu contents. Put the most common variant first. |
| variant | 'primary' | 'secondary' | 'standard' | 'primary' | Applied to both halves. |
Fab
| Prop | Type | Default | Description |
|---|---|---|---|
| icon* | ReactNode | — | Usually a plus. Keep it universal. |
| label* | string | — | Accessible name, and the visible text when extended. |
| extended | boolean | false | Shows the label. Use when the action is not obvious from the icon. |
| size | 'sm' | 'md' | 'lg' | 'md' | 40 / 56 / 64px square. |
| tone | 'accent' | 'surface' | 'accent' | Surface tone for FABs over colorful content. |
Professional tips
- Order actions as Cancel → Secondary → Primary on desktop (left to right, primary last, matching the F-pattern exit point). On mobile, stack them with the primary on top and full width.
- Sentence case, not Title Case. "Save changes" reads faster than "Save Changes" because lowercase word shapes are more distinctive.
- Cap a label at three words. If you need more, the button is doing a job that belongs to a heading or an inline description.
- For "Copy", swap the icon to a check for 1.5s instead of firing a toast. The feedback should appear where the user is looking.
- A button that opens a dialog should end its label with an ellipsis ("Invite people…") — an old macOS convention that still reliably signals "more input required".
Performance
- Transition only background-color, color, box-shadow, transform and the wash’s opacity. Adding `all` forces the browser to watch every property and drops frames on hover-heavy toolbars.
- Prefer transform: scale() over changing width or padding for the pressed state — transform is composited and never triggers layout.
- In long lists, one delegated click handler on the container beats one closure per row; a 500-row table saves 500 function allocations per render.
- Icon imports must be named (`import { Save } from "lucide-react"`), never a namespace import — the latter defeats tree-shaking and adds ~600 kB.
Common mistakes
- Using a <div> with onClick. It is not focusable, it does not fire on Enter or Space, and it announces as nothing. If it presses, it is a <button>.
- Forgetting type="button" inside a form. The default is "submit", so an innocuous "Add row" button reloads the page.
- Removing outline on :focus instead of restyling it. This is the single most common accessibility regression in production code.
- Putting the loading spinner beside the label instead of over it. The button grows, the layout jumps, and the user clicks the wrong thing.
- Coloring a non-destructive action red because it "feels important". Red means irreversible; spending it elsewhere means users stop trusting it where it matters.
Real-world recommendations
- In a dialog footer, right-align and let the primary sit closest to the corner the eye exits from. In a form, left-align under the fields, on the same axis as the labels.
- For dangerous operations, require typing the resource name rather than just a second click. Two clicks is muscle memory; typing "production-db" is a decision.
- Rate-limit at the UI layer: after the first click, go straight to loading. Debouncing the handler is not enough — the user still sees a button that appears to do nothing.
- If a button triggers work longer than about 10 seconds, do not hold it in a loading state. Return immediately, show progress somewhere persistent, and let the user leave the page.
- Audit your product for primary buttons per screen. Any view with more than one is a design bug, and it is the fastest measurable quality metric a team can adopt.