Skip to content

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.

Live preview

Everything below is the real component. Change the controls, tab through it, and turn on Inspector Mode to read any value off the screen.

Playground

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.

primaryThe one filled action in a view. It is the strongest neutral on the page, so it inverts with the theme instead of carrying a color.
Default
With icon
Hover
Focus
Inactive
Disabled
secondaryAn outline, for a real alternative to the primary action. It takes the primary look when it is the selected option of a set.
Default
With icon
Hover
Active
Disabled
tertiaryA ghost: no fill and no edge until hovered. Icon buttons, and the actions the product would rather you did not take — cancel, skip, dismiss.
Default
With icon
Hover
Inactive
Disabled
standardA quiet fill, one step up from whatever it stands on. For an action that should read as a button without competing with the primary one.
Default
With icon
Hover
Inactive
Disabled
auraThe signature: pink into orange under a white label. For the one moment a product is asking for something — create, subscribe, the closing call to action.
Default
With icon
Hover
Disabled
navA navigation pill. The one for the page you are on takes the primary look, from aria-current rather than from a second variant.
Default
Hover
Current page
Disabled
frosted-glassGlass for a control over imagery: a thin tint of the label color and a 16px backdrop blur. Hover thickens the glass; borderless drops the edge.
Default
Borderless
Hover
Active
Disabled
smoked-glassGlass that pulls the picture toward the page color instead, for a control on bright or busy artwork where frosted glass would lose its label.
Default
Borderless
Hover
Active
Disabled
inheritTakes its color from the text around it. For a link in a nav row or a footer that needs a button’s hit area and hover, and nothing else of a button.
Default
With icon
Hover
Inactive

Tone, shape and relatives

What changes a button without changing its variant, and the components built out of it.

Destructive — a tone on a variant, not a variant of its own

Shape — pill is the default; the other two are for a row of squarer controls

pill
rounded
rectangle

Icon buttons — as wide as they are tall, always with an accessible name

Grouped and split

Floating action button — one per screen, never two

Sizes

Four heights, all multiples of 4. Medium is the default and should cover roughly 90% of usage.

xs · 28px
sm · 32px
md · 36px
lg · 44px

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.

Default
HoverA wash fades in over the fill
Focus2px ring, 2px offset
Pressed98.5% scale, wash held
DisabledIts own fill and label, no pointer
LoadingWidth held constant
SuccessReverts after ~1.5s
DangerDestructive, irreversible

Anatomy

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Design tokens used

Values are read live from the running stylesheet, so this table can never drift from the code. Click any value to copy it.

Color

TokenValueUsed 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

TokenValueUsed for
padding-xxs / sm / md / lg horizontal padding on a pill (10 / 12 / 14 / 20px on the other shapes)
gapSpace between icon and label

Radius

TokenValueUsed for
pillThe default shape, at every size
--radius-smxs corners on the rounded shape
--radius-mdsm and md corners on the rounded shape
--radius-lglg corners on the rounded shape

Typography

TokenValueUsed for
--text-label-smxs label
--text-labelsm and md labels
--text-label-lglg label

Motion

TokenValueUsed for
--ease-standardColor and wash transitions
durationHover and press feedback
backdrop blurNav and both glass variants

Recommended sizes

Pick a size from this table. Do not invent a new one — a fourth height is how a design system starts dying.

SizeHeightPaddingRadiusIconLabel gapTypeMin widthMax widthTouch targetWhen to use
Extra small28px0 12pxpill13px6px14px / 50056px—44px (padded)Inside table rows, chips and dense toolbars. Never as a form’s primary action.
Small32px0 14pxpill14px6px15px / 50064px—44px (padded)Card footers, panel headers, secondary toolbars, filter bars.
Medium36px0 16pxpill16px8px15px / 50072px20rem44px (padded)The default. Forms, dialogs, page headers — reach for anything else only with a reason.
Large44px0 24pxpill18px8px17px / 50096px24rem44px (native)Marketing pages, mobile primary actions, checkout. One per screen at most.

Do

Give every view exactly one primary buttonThe primary variant is the answer to "what did you bring me here to do?". Two answers is the same as none — users fall back to reading every label, which is the cost the emphasis ladder exists to avoid.
Label with a verb the user would say out loud"Delete 3 projects" tells the user what will happen and how much of it. "OK" and "Submit" force them to re-read the dialog to reconstruct the consequence.
Keep the width fixed while loadingThe spinner is overlaid and the label is hidden, not removed. A button that shrinks mid-click moves the target out from under the pointer and invites a second, accidental click elsewhere.
confirmation required
Put destructive actions behind a different color and a confirmationRed is the only place color alone is allowed to change meaning, and even then it is paired with an explicit verb. Users have learned red = irreversible; borrowing it for "clear filters" spends that trust.

Don't

Do not stack multiple primary buttonsEvery button becomes the primary button, so none of them is. This is the single most common cause of "the app feels cluttered" feedback that gets misdiagnosed as a spacing problem.
…but why?
Do not disable a button without saying whyA grayed-out button is a dead end: it fails contrast, it usually cannot receive focus, and it never explains itself. Keep it enabled and explain the problem on submit, or show the blocking reason next to it.
Do not use an icon-only button for an ambiguous actionIcons are recognized, not read. Outside a tiny set of universals (close, search, add, more) an unlabeled glyph is a guessing game, and a tooltip does not help on touch.
Do not invent a heightA 38px button next to a 36px input is not "close enough" — the misalignment is visible even to people who cannot name it, and it multiplies across every screen that copies the pattern.

Accessibility

Not a checklist to run at the end. These are the requirements the component was built from.

1.4.3Contrast (Minimum)AA2.1.1KeyboardA2.4.7Focus VisibleAA2.5.8Target Size (Minimum)AA4.1.2Name, Role, ValueA

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

TabMoves focus to the button in DOM order.
EnterActivates. On a <button type="submit"> also submits the form.
SpaceActivates on key-up, so the user can slide off to cancel.
↓ / Alt+↓On a split button, opens the options menu.
EscCloses 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.
AttributeApplied toNotes
aria-labelIconButtonRequired. Without it the button announces as "button" and is unusable by name.
aria-busy="true"buttonSet while loading so assistive tech knows the action is in flight rather than ignored.
aria-disabledbuttonPrefer over the disabled attribute when the button must stay focusable and explain itself.
aria-expanded / aria-haspopupSplit button triggerOn the disclosure half only. The primary half stays a plain button.
aria-pressedToggle buttonsOnly 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 buttonMarks 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.

Code

Example usage

The common cases. Everything else is a combination of these props.

tsx
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.

html
<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.

css
.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

PropTypeDefaultDescription
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.
activebooleanfalseThe selected option of a set: takes the primary look. Set aria-pressed yourself if it is a toggle.
inactivebooleanfalseStill pressable, but not the live option. Dimmed, never below 4.5:1.
borderlessbooleanfalseDrops the edge of a glass variant.
loadingbooleanfalseOverlays a spinner, hides the label without unmounting it, sets aria-busy and disables interaction.
successbooleanfalseShows a check for confirmation. Reset it yourself after ~1.5s.
startIconReactNode—Leading icon. Sized automatically.
endIconReactNode—Trailing icon, for disclosure or direction.
fullWidthbooleanfalseStretches to the container. Mobile and dialog footers only.
iconOnlybooleanfalseRenders square. Prefer <IconButton>, which forces a label.
disabledbooleanfalseUse sparingly — see Don’t #2.

IconButton

PropTypeDefaultDescription
label*string—Accessible name. There is no fallback.
icon*ReactNode—The glyph. Sized from the button size.
variantButtonVariant'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

PropTypeDefaultDescription
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

PropTypeDefaultDescription
icon*ReactNode—Usually a plus. Keep it universal.
label*string—Accessible name, and the visible text when extended.
extendedbooleanfalseShows 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.

Notes

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.