Skip to content
Halyard
Layout: Full width
Theme: Smoke
Search the docs
Layout: Full width
System
Ask AI

Button

Open in FigmaOpen in Storybook

Starts an action: saving a form, sending a message, opening a dialog.

A Button tells the reader what will happen when they press it, and does it on this page. It comes in three variants that set how much it stands out, so a view can have one clear main action with quieter ones beside it, and two sizes that match the height of the fields and controls it sits with. It renders a native button element, so the keyboard and assistive technology work with no extra wiring. Use a Link instead when pressing it takes the reader somewhere else.

Installation#

npx halyard-ui add button

Or add it by hand, if the package is already in your app:

  1. 1

    Install the package

    Once per app, with your package manager.

  2. 2

    Import the stylesheet

    Once, in your root layout, before your own CSS.

  3. 3

    Import the Button

    From halyard-ui, wherever you need it.

npm install halyard-ui

Usage#

Give each button a verb that says what it does, and one primary per view for the main action.

Variants#

variant sets how much the button stands out. Use primary for the one main action, secondary for an alternative to it, and tertiary for a quiet action such as Cancel.

Writing labels#

Start with a verb, and name the outcome rather than the gesture.

DoSay what happens when it is pressed.
Don'tLeave the reader guessing what it does.

Accessibility#

Button renders a native button element, so it is in the tab order and pressed from the keyboard with no extra wiring.

Keyboard
KeyAction
Tab
Moves focus to the button.
Enter
Presses the button.
Space
Presses the button.

API reference#

Button props
PropTypeDefaultDescription
variant
'primary' | 'secondary' | 'tertiary'
'primary'
How much the button stands out.
size
'default' | 'compact'
'default'
The control height, matching the fields beside it.
onClick
(event: MouseEvent) => void
–
Runs when the button is pressed.
disabled
boolean
false
Holds the button still.
loading New
boolean
false
Shows a spinner and holds the button still while an action runs.
Back to top