Components
Button
Triggers an action, such as saving a form or opening a dialog. To go to another page, render a link with the button's styles instead.
Import
import { Button } from "@tessera/react";Examples
Variants
<Button variant="primary">Save changes</Button>
<Button variant="stroke">Cancel</Button>
<Button variant="ghost">Skip for now</Button>Sizes
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>With an icon
<Button><PlusIcon /> New project</Button>
<Button variant="stroke">Continue <ArrowIcon /></Button>Loading and disabled
<Button loading>Saving…</Button>
<Button disabled>Publish</Button>Props
Button also accepts every attribute of the native button element.
Prop | Type | Default | Description |
|---|---|---|---|
| variant | "primary" | "stroke" | "ghost" | "primary" | The visual weight. Use one primary button per view. |
| size | "sm" | "md" | "lg" | "md" | Height and padding. Icons follow the button's size. |
| loading | boolean | false | Shows a spinner, disables the button and sets aria-busy. |
| disabled | boolean | false | Prevents interaction. Prefer explaining why an action is unavailable. |
| asChild | boolean | false | Renders its single child (for example a link) with the button's styles. |
Accessibility
- Buttons are native button elements: Enter and Space activate them, and they are in the tab order.
- An icon-only button needs an accessible name. Add aria-label, or visually hidden text.
- A loading button is disabled and sets aria-busy. Announce the result of the action once it completes.
- The focus ring is drawn outside the button with a gap, in both colour schemes.