Button
Buttons let people take an action with a single click or tap.
import { Button } from '@halo-ds/react';
When to use it
Use a button for actions: saving, submitting, opening a dialog or starting a flow. For moving to another page, use a link instead.
Halo buttons come in four types, four sizes and five states, with optional icons on either side or an icon on its own. Every colour, space and corner comes from Halo tokens, so buttons work in light and dark mode automatically.
Do
- Use one primary button per view, for the most important action.
- Pair a primary with a secondary for the alternative (Save and Cancel).
- Write short, specific labels that start with a verb.
- Use Destructive for actions that delete data, and confirm them first.
- Use Premium for upgrades and paid features, at most once per screen.
Don't
- Put several primary buttons side by side; people won't know which matters.
- Use a button to go to another page; use a link.
- Mix sizes in the same group of buttons.
- Use Destructive styling for actions that are easy to undo.
- Put Premium next to a Primary button, or use it for everyday actions like Save.
Props
Button props
| Prop | Type | What it does | |
|---|---|---|---|
iconOnly | `false \ | undefined` | |
children (required) | ReactNode | The button text. Figma: Label. | |
iconLeft | ReactNode | Icon before the label. Figma: L icon. | |
iconRight | ReactNode | Icon after the label. Figma: R icon. | |
variant | `ButtonVariant \ | undefined` | Emphasis of the button. premium is a gradient for upgrades and paid features: one per screen at most. Figma: Type. |
size | `ButtonSize \ | undefined` | Height, padding, label and icon size. Figma: Size. |
loading | `boolean \ | undefined` | Shows a spinner while an action runs, like saving. The button keeps its width and its name, and ignores clicks until loading ends. Figma: State=Loading. |
classNames | `Partial<Record<ButtonPart, string>> \ | undefined` | Extra class names for the parts inside the component, by part name, like { header: 'my-header' }. |
styles | `Partial<Record<ButtonPart, CSSProperties>> \ | undefined` | Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }. |
aria-label | string | Icon-only buttons have no visible text, so they need a name for screen readers. |
It also takes the usual HTML attributes for its element.
Examples
Overview
import { Button } from '@halo-ds/react';
import { ArrowRight, Plus } from '@phosphor-icons/react';
export default function Example() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, justifyContent: 'center' }}>
<Button iconLeft={<Plus />}>New project</Button>
<Button variant="secondary">Cancel</Button>
<Button variant="ghost" iconRight={<ArrowRight />}>Learn more</Button>
<Button variant="destructive">Delete</Button>
</div>
);
}
Types
Primary for the main action, Secondary for the alternative, Ghost for quiet actions and Destructive for deleting.
import { Button } from '@halo-ds/react';
import { ArrowRight, Trash } from '@phosphor-icons/react';
export default function Demo() {
return (
<div className="demo-row">
<Button>Save changes</Button>
<Button variant="secondary">Cancel</Button>
<Button variant="ghost" iconRight={<ArrowRight />}>Learn more</Button>
<Button variant="destructive" iconLeft={<Trash />}>Delete</Button>
</div>
);
}
Sizes
Extra small, small, medium and large: 28, 32, 40 and 48px tall. Medium is the default.
import { Button } from '@halo-ds/react';
import { Plus } from '@phosphor-icons/react';
export default function Demo() {
return (
<div className="demo-row">
<Button size="xs">Extra small</Button>
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>
<Button size="lg" iconOnly aria-label="Add"><Plus /></Button>
</div>
);
}
Premium
A gradient for upgrades and paid features. Use at most one per screen, and never next to a Primary button.
import { Button } from '@halo-ds/react';
import { Sparkle } from '@phosphor-icons/react';
export default function Demo() {
return (
<div className="demo-row">
<Button variant="premium" size="lg" iconLeft={<Sparkle weight="fill" />}>Upgrade to Pro</Button>
<Button variant="premium" size="sm">Upgrade</Button>
</div>
);
}
Loading and disabled
Loading shows a spinner, keeps the width and ignores clicks. Press Save to try it.
import { useState } from 'react';
import { Button } from '@halo-ds/react';
export default function Demo() {
const [busy, setBusy] = useState(false);
const save = () => {
setBusy(true);
setTimeout(() => setBusy(false), 1500);
};
return (
<div className="demo-row">
<Button loading={busy} onClick={save}>Save</Button>
<Button variant="secondary" disabled>Disabled</Button>
</div>
);
}
Icon only
Round buttons for compact actions. They always need an aria-label, since there is no visible text.
import { Button } from '@halo-ds/react';
import { Gear, Heart, X } from '@phosphor-icons/react';
export default function Demo() {
return (
<div className="demo-row">
<Button iconOnly aria-label="Settings"><Gear /></Button>
<Button variant="secondary" iconOnly aria-label="Like"><Heart /></Button>
<Button variant="ghost" iconOnly aria-label="Close"><X /></Button>
</div>
);
}
More: https://halodesignsystem.dev/components/button