Button

Triggers an action. Four variants by emphasis, destructive versions for irreversible actions, and a link style. Neutral for actions, coral only for danger.

Usage

pnpm dlx shadcn@latest add button

Then replace components/ui/button.tsx with the Matrix version. It keeps shadcn's API and adds the Matrix variants, sizes, square, round and loading.

import { Button } from '@/components/ui/button';

<Button onClick={save}>Save changes</Button>
<Button variant="secondary">Cancel</Button>

Variants

PrimaryThe main action in a view
SecondaryEvery other action next to it
GhostLow-emphasis actions in toolbars and menus
LinkAn action that reads like text

Primary is the dark neutral; secondary is outlined on the page color; ghost has no fill until hover. Links are always underlined. The neutral link turns dark brand green on hover, like primary; the coral link just gets a shade darker (coral-600 → coral-700).

Destructive

For actions that can't be undone

Coral means danger, so it's only for deleting, removing or disconnecting. Use the solid version for the final confirm, and the ghost or link version where the action is one of several.

Sizes

28 · 32 · 36 · 40
xs · 28px, 13pxsm · 32px, 14pxmd · 36px, 14pxlg · 40px, 17px

md (36px) is the default. Every size has an 8px corner, so buttons read as one family next to each other.

With icon

Leading and trailing

Put a Lucide icon straight inside the button; it's sized for you (14px at xs, 16px above) and the padding on that side tightens so the button stays balanced.

Icon only

Square and round

square makes the width equal the height at any size. Use ghost for quiet neutral icon actions (more, edit, close) and ghost-destructive only when the action deletes or removes; add round for circular buttons like the chat composer's send. An icon-only button always needs an aria-label.

States

Loading and disabled

loading shows a spinner, keeps the button's width and blocks clicks. Hover and focus are built in: tab to any button on this page to see the gold focus ring.

API reference

Prop

Type

Guidelines

  • One primary button per view. If two actions compete, neither is primary.
  • Write labels as verb + noun in sentence case: "Create agent", "Connect provider", not "Submit" or "OK".
  • Use xs in dense chrome like toolbars, md in content and forms, lg for a single focused action such as onboarding.
  • Keep coral for actions that destroy or remove something.
  • Don't disable a button without saying why; add helper text, or a tooltip on a wrapper (a disabled button can't show one itself).
  • Don't use ghost or link for the main action; they don't carry enough weight.