Components
Button
Triggers an action or navigates. Hierarchy, variant and size are properties; states are driven by the user and the platform.
Overview
When to use
- To start an action (send, download, open Studio) or to move to another page.
- As the primary call to action of a region, with at most one primary per region.
When not to use
- For inline text links within a sentence: use a link.
- To switch between views or options: use a segmented control.
Used on the portfolio: Hero actions · Studio section actions · Footer actions · Header: Customize this website · System Anatomy mock.
Preview and properties
The preview is the real Button, rendered from the same model the site uses. Properties are labelled by scope.
System property
The system default is "…" (change it in System Studio). An instance can override it.
Component properties
Simulated state
Paints a state on this preview only. The live website is not affected.
<Button iconTrailing="arrow-right">Download CV</Button><button class="btn" data-component="button" data-hierarchy="primary" data-size="md" type="button">
<span class="btn__label" data-part="label">Download CV</span>
<svg class="icon" data-part="icon-trailing" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
<path d="M5 12h14"/>
<path d="m12 5 7 7-7 7"/>
</svg>
</button>System
Set in System Studio and applied to every button (the variant default). Changes the live site.
Component
Props of one instance: hierarchy, size, icons, label. They exist in code and affect only that button.
Preview only
Simulated states (hover, active, focus, disabled, loading). Painted on this page's preview; never applied to the live website.
Variant matrix
Every valid variant × hierarchy combination, rendered with the real component. Each variant is applied per instance (data-variant) so all appear at once.
Five treatments: solid (filled accent), outline, ghost (text with a hover fill), underline (an underlined label, no box) andoffset (a thick border with a hard shadow in the text colour, elevation.offset). Treatment, hierarchy, size, shape, icon position and interaction state are independent properties: a treatment only sets colours, borders, shadow and decoration tokens; it never fixes a shape or a size.
Shape
The system corner style (Studio: sharp, subtle, soft, rounded, pill) sets button.radius for every button. An instance can override it with shape (pill or square), independent of the treatment.
Sizes
States
States are driven by the user and the platform. The matrix paints them with data-sim for documentation; real hover, active and focus use the same styles.
Disabled and loading are mutually exclusive: a loading button stays focusable and announces that it is busy; a disabled button leaves the tab order. The component normalises an invalid combination and the playground explains why.
Anatomy
- 1Container. The interactive element:
button, orawhen it navigates. - 2Leading icon. Optional, decorative (
aria-hidden). - 3Label. Short, starts with a verb. Always present unless icon-only.
- 4Trailing icon. Optional: direction (arrow) or external destination.
- ·Focus ring. A 2px outline offset 3px, using
color.focus.ring.
Tokens
Button reads only component tokens. Variants replace the colour tokens; sizes replace the size tokens. Open any of them in the token explorer to follow its chain.
| Component token | References | Resolved (dark) | Resolved (light) |
|---|---|---|---|
{color.accent.fill} | #B9A6FF | #B9A6FF | |
{color.accent.on-fill} | #0C0C0C | #0C0C0C | |
{color.accent.fill} | #B9A6FF | #B9A6FF | |
{color.text.primary} | #EAE9E7 | #0C0C0C | |
{color.text.inverse} | #0C0C0C | #EAE9E7 | |
{color.text.primary} | #EAE9E7 | #0C0C0C | |
{color.text.inverse} | #0C0C0C | #EAE9E7 | |
{color.text.primary} | #EAE9E7 | #0C0C0C | |
{color.accent.fill} | #B9A6FF | #B9A6FF | |
{color.accent.on-fill} | #0C0C0C | #0C0C0C | |
{radius.control} | 2px | 2px | |
2rem | 2rem | 2rem | |
{space.inline.md} | calc(16px * 1) | calc(16px * 1) | |
{space.inline.xs} | calc(8px * 1) | calc(8px * 1) | |
{prim.font.size.xs} | 0.75rem | 0.75rem | |
2.75rem | 2.75rem | 2.75rem | |
{space.inline.lg} | calc(24px * 1) | calc(24px * 1) | |
{space.inline.sm} | calc(12px * 1) | calc(12px * 1) | |
{prim.font.size.xs} | 0.75rem | 0.75rem | |
3.5rem | 3.5rem | 3.5rem | |
{space.stack.md} | calc(24px * 1) | calc(24px * 1) | |
{space.inline.md} | calc(16px * 1) | calc(16px * 1) | |
{prim.font.size.sm} | 0.875rem | 0.875rem | |
{space.inline.sm} | calc(12px * 1) | calc(12px * 1) | |
{opacity.disabled} | 0.4 | 0.4 | |
{border.width.hairline} | 1px | 1px | |
none | none | none | |
none | none | none | |
2px | 2px | 2px | |
{color.annotation} | #B9A6FF | #0C0C0C |
Guidelines
Do
- Use one primary button per region; make supporting actions secondary.
- Write the label as a verb: "Download CV", "Open System Studio".
- Choose the visual variant system-wide (Studio) and override it per instance only for a reason.
Do not
- Disable a button to hide a feature; explain why it is unavailable instead.
- Ship an icon-only button without an accessible name.
- Stack more than two buttons in a row; use a list of links.
Limitation: there is no destructive or danger hierarchy yet, because the portfolio has no destructive actions. It is proposed, not implemented.
Accessibility
| Topic | Behaviour |
|---|---|
| Keyboard | Reachable with Tab. Space and Enter activate a button; Enter activates a link. Disabled buttons are removed from the tab order. |
| Focus | A visible focus ring appears on keyboard focus. Its colour is a theme role (accent in dark, ink in light) validated at 3:1 or more against the page. |
| Semantics | Native button or a. Icons are aria-hidden. Links that open a new tab add visually hidden text. |
| Loading | aria-busy="true" and aria-disabled="true", with hidden "Loading" text. The spinner stops in reduced motion. |
| Contrast | Text on the accent fill measures 9.3:1 (dark) and 9.3:1 (light) for the default accent; the build checks every accent. |
| Target size | Medium is 44px, small is 32px, both above the WCAG 2.2 minimum of 24px. |
Code and API
| Property | Type | Default | Scope | Description |
|---|---|---|---|---|
hierarchy | 'primary' | 'secondary' | 'primary' | component | How prominent the action is. |
variant | 'inherit' | 'solid' | 'outline' | 'ghost' | 'underline' | 'offset' | 'inherit' | system | Defaults to the system choice; an instance may override it. |
shape | 'inherit' | 'pill' | 'square' | 'inherit' | component | Corner shape for one instance; independent of the treatment. |
size | 'sm' | 'md' | 'lg' | 'md' | component | Height, padding, type size. |
iconLeading / iconTrailing | IconName | — | component | Decorative icon beside the label. |
iconOnly + ariaLabel | IconName + string | — | component | Icon-only button; ariaLabel is required. |
href / external | string / boolean | — | component | Renders an anchor; external opens a new tab safely. |
disabled / loading | boolean | false | component | Mutually exclusive; links cannot be disabled. |
sim | 'hover' | 'active' | 'focus' | — | preview only | Documentation only. Never used on the site. |
import Button from '../components/ui/Button.astro';
<Button href="#work" iconTrailing="arrow-right">View selected work</Button>
<Button hierarchy="secondary" variant="outline" size="sm">Get in touch</Button>
<Button iconOnly="plus" ariaLabel="Add item" />/* generated from variants.tokens.json */
.btn[data-variant="outline"] {
--ds-button-primary-bg: transparent;
--ds-button-primary-fg: var(--ds-color-text-primary);
--ds-button-primary-border: var(--ds-color-text-primary);
}Live example on this page: Follow button.primary.bg in the explorer