Button
import { Button } from "@study/ui"
A button triggers something: save, create, upload. Its text says what happens, as a verb. If it only leads somewhere else, it is a LinkButton.
Result
Loading...
Live Editor
function Example() { const [saving, setSaving] = useState(false); return ( <div style={{ display: "flex", gap: 10, flexWrap: "wrap" }}> <Button variant="primary" icon="check" loading={saving} onClick={() => { setSaving(true); setTimeout(() => setSaving(false), 1500); }}> Save </Button> <Button>Cancel</Button> </div> ); }
Variants and states
Light
Dark
| Variant | For |
|---|---|
primary | the one main action of a view |
secondary | everything else (default) |
soft | a friendly secondary action on a colour, e.g. "With Claude" (tone) |
danger | delete, leave, sign out |
ghost | quiet actions in bars and lists |
When to use
✓ DoOne main action, next to it the alternative. The main action is on the right.
✗ Don'tSeveral main actions next to each other – nobody knows what counts.
✓ DoThe text says what happens.
✗ Don't“OK” and “Yes” say nothing.
- Use
loadinginstead of your own spinner – the button is then locked and tells screen readers that it is working. type="submit"only in a form; otherwise a Button is alwaystype="button".- For elements that cannot be a
Button,buttonClass({ variant, size })gives the classes.
Props
Plus all attributes of a <button> (onClick, type, disabled …).
| Prop | Type | Default | Meaning |
|---|---|---|---|
icon | enum | – | An icon before the text. |
iconEnd | enum | – | An icon after the text, e.g. an arrow for "Next". |
loading | boolean | – | Shows a spinner instead of the icon and blocks further presses. |
ref | Ref<HTMLButtonElement> | – | |
size | ButtonSize | – | sm 36 px, md 44 px (default), lg 52 px high. |
tone | "blau" | "petrol" | "gruen" | "gelb" | "orange" | "rot" | "violett" | "grau" | – | The colour of a `soft` button; default the neutral tint. |
variant | ButtonVariant | – | primary – the one main action of a view (dark). secondary – everything else (outlined); the default. soft – a friendly side action on a tint, e.g. "With Claude". danger – deleting and leaving. ghost – quiet actions in toolbars and lists. |
wide | boolean | – | As wide as its place. |
Accessibility
- A real
<button>: reachable with Tab, triggered with Enter and Space. - A clear focus ring (3 px,
--ui-focus), only for keyboard use. - At least 44 px high in
md;smonly where a mouse is likely. loadingsetsaria-busyand blocks double clicks.