Skip to content
Skip to content

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
import { Button } from "@tessera/react";

Examples

Variants

Variants example
<Button variant="primary">Save changes</Button>
<Button variant="stroke">Cancel</Button>
<Button variant="ghost">Skip for now</Button>

Sizes

Sizes example
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>

With an icon

With an icon example
<Button><PlusIcon /> New project</Button>
<Button variant="stroke">Continue <ArrowIcon /></Button>

Loading and disabled

Loading and disabled example
<Button loading>Saving…</Button>
<Button disabled>Publish</Button>

Props

Button also accepts every attribute of the native button element.

Button props
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.
loadingbooleanfalseShows a spinner, disables the button and sets aria-busy.
disabledbooleanfalsePrevents interaction. Prefer explaining why an action is unavailable.
asChildbooleanfalseRenders 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.