Primitives

Button

Trigger for user actions; renders as <button> or <a> depending on context

Markdown version for agents · 14 stories in Storybook(opens in a new tab)

Import
import { Button } from '@amezquita/design-system/components/primitives/Button'

Live render

Light

VariantRestDisabledLoadingHover, focus, press
primary
secondary
ghost
link

Dark

VariantRestDisabledLoadingHover, focus, press
primary
secondary
ghost
link

Rest, disabled and loading come from props. Hover, keyboard focus and pressed are the browser’s own states: point at, Tab to, or press and hold the buttons in the last column.

demo-cool

demo-warm

demo-soft

The same Button in the three demo brands. Nothing about the component changes: each panel is a ThemeScope, and the brand’s tokens set the font, colours, corners and outline.

    Props

    PropTypeDescription
    variant?'primary' | 'secondary' | 'ghost' | 'link'How much emphasis the action gets. primary (default) for the one main action in a view, secondary for actions beside it, ghost for low-emphasis actions, link for an action that should read as text.
    childrenReact.ReactNodeThe label. Name the action ("Save changes"), not the element ("Click here").
    onClick?(event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => voidRuns on click. It doesn't run on a disabled or loading Button, or on an internal link that onNavigate handles.
    disabled?booleanBlocks the action. A <button> gets the native disabled attribute and leaves the tab order; an <a> gets aria-disabled, loses its href and is removed from the tab order.
    loading?booleanShows a spinner over the label and blocks the action like disabled, with aria-busy set. The label stays in place, invisible, so the Button keeps its width and the layout doesn't jump. Unlike disabled, it keeps the variant's colours: busy, not unavailable.
    fullWidth?booleanStretches the Button to the width of its container. Meant for narrow layouts and stacked forms.
    type?'button' | 'submit' | 'reset'The native button type. Defaults to 'button', so a Button inside a form doesn't submit it by accident; set 'submit' for the form's main action. Ignored when href is set.
    icon?React.ReactNodeAn icon beside the label, hidden from screen readers; the label carries the meaning. For an icon-only Button, also set aria-label.
    iconPosition?'start' | 'end'Which side of the label the icon goes on. Defaults to 'start'. An icon at 'end' takes the arrow's place, so arrow is ignored then.
    arrow?booleanTrailing arrow after the label. Off by default — turn it on for a call to action that leads somewhere. Ignored on the link variant, while loading, and when an icon sits at the end.
    motion?'functional' | 'expressive''expressive' adds the hover wipe and glow, and loads GSAP on demand. Left at 'functional', hover is a plain background change and no animation code is fetched. See decisions/0016.
    aria-label?stringAn accessible name for when the visible label isn't enough, e.g. an icon-only Button.
    href?stringRenders an <a> instead of a <button>, for an action that navigates.
    curtainColor?stringA colour passed to onNavigate along with the link, for a route transition that needs one. Does nothing on its own.
    onNavigate?(href: string, curtainColor?: string) => voidCalled instead of a plain navigation when set and the link is internal — lets host apps inject route-transition behavior (e.g. a page-curtain animation) without Button depending on any specific router or transition system. Omit for a plain internal navigation.

    Also accepts all props of: Omit<React.HTMLAttributes<HTMLElement>, 'onClick' | 'type'>

    Tokens

    TokenTypeValue
    --button-arrow-nudgedimension2px
    --button-border-radiusdimension9999px †
    --button-ghost-backgroundcolortransparent
    --button-ghost-bordercolortransparent
    --button-glow-colorcolorrgba(255, 255, 255, 0.45)
    --button-glow-sizedimension52px
    --button-outline-border-widthdimension2px †
    --button-padding-xdimension24px
    --button-padding-ydimension12px
    --button-secondary-backgroundcolortransparent
    --button-secondary-background-hovercolor#262626 †
    --button-secondary-bordercolor#262626 †
    --button-secondary-foregroundcolor#262626 †
    --button-spinner-durationduration750ms
    --button-wipe-duration-curveduration220ms
    --button-wipe-duration-curve-outduration180ms
    --button-wipe-duration-enterduration550ms
    --button-wipe-duration-exitduration400ms

    † resolves differently across brands and light/dark themes — see tokens.json for every value.

    Best practices

    Do

    • Use one primary Button per view, for the action most people came to do.
    • Name the action with a verb: "Save changes", "Send invite".
    • Use href for anything that goes somewhere, and a plain Button for anything that acts on the page.
    • Use loading while an action runs, instead of disabling the Button and changing its label.
    • Give an icon-only Button an aria-label.

    Don't

    • Don't put two primary Buttons side by side; make one of them secondary.
    • Don't use a Button for a link inside running text; that's what Link is for.
    • Don't disable a Button without saying nearby why. A disabled Button can't explain itself.
    • Don't turn on arrow for an action that stays on the page; the arrow promises a destination.
    • Don't make motion="expressive" the default in a shared wrapper unless the brand calls for it (ADR 0016).

    Accessibility

    • Semantic element: <button> by default; <a> when href is passed
    • When rendered as <a>: there's no native disabled, so disabled sets aria-disabled, drops the href and removes it from the tab order
    • ARIA: use aria-label for icon-only buttons; disabled on <button> removes it from tab order
    • Keyboard: Enter + Space activate <button>; Enter follows <a>