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 buttonThen 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
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
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
md (36px) is the default. Every size has an 8px corner, so buttons read as one family next to each other.
With icon
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 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 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
xsin dense chrome like toolbars,mdin content and forms,lgfor 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.