Button
A pill that does something on this page. Primary is the action fill; secondary is a rule border. For navigation that should read as a button, use ButtonLink, which shares these classes.
Examples
Primary, secondary, the small size and disabled.
TSX
// Button: a pill that does something on this page (send, start over). Use
// primary for the one main action in a view and secondary beside it. For a
// control that goes to another page, use ButtonLink instead.
import { Button } from "@repo/ui/button";
export default function ButtonExamples() {
return (
<>
<Button>Ask a question</Button>
<Button variant="secondary">Start over</Button>
{/* sm is 40px tall, for a toolbar or the header. */}
<Button size="sm">Send</Button>
{/* Disabled dims to 40% and turns off the hover tones. */}
<Button disabled>Send</Button>
</>
);
}buttonVariants
The same classes as a function, for an element that is not a button.
TSX
// buttonVariants: the Button's classes as a function, for an element that is
// not a <button>, such as a plain link drawn before any script loads. For a
// link inside the app, prefer ButtonLink, which wraps this.
import { buttonVariants } from "@repo/ui/button";
// href is where the link goes; it defaults to the Join page.
export default function ButtonClasses({ href = "/join" }: { href?: string }) {
return (
<a
href={href}
className={buttonVariants({ variant: "secondary", size: "sm" })}
>
Join
</a>
);
}Variants
| Prop | Value | How it looks |
|---|---|---|
| variant | primary | Action fill with the on-accent text. On hover the fill becomes accent-hover. |
| variant | secondary | No fill, a 1px rule border and the text colour. On hover the border becomes the accent and the fill becomes the hover tint. |
| base | shared | Inline flex, centred, a full pill (rounded-full), 8px gap, weight 500, text-base (16/24), no text selection. |
| size | md | 44px tall at least, 24px side padding, 12px top and bottom. |
| size | sm | 40px tall at least, 20px side padding, 10px top and bottom. |
States
| State | How it looks |
|---|---|
| rest | The variant's own fill or border. |
| hover | Primary: accent-hover fill. Secondary: accent border and hover tint. Colour changes ease over 300ms (transition-tone); nothing moves. |
| pressed | not written |
| focus | The global keyboard focus ring: 2px in the focus colour, 2px off the edge, following the pill. |
| disabled | 40% opacity (opacity-disabled) and a not-allowed cursor. Hover tones are off while it is disabled. |
Props
Import from @repo/ui/button.
| Prop | Type | Default | What it does |
|---|---|---|---|
| variant | "primary" | "secondary" | default "primary" | The action fill, or a rule border that tints on hover. |
| size | "md" | "sm" | default "md" | md is 44px tall with 24px sides; sm is 40px with 20px. |
| className | string | Joined with cn(), so a caller's class overrides a default. | |
| disabled | boolean | default false | 40% opacity and a not-allowed cursor. From Base UI's button. |
| ... | Base UI button props | Every other prop of Base UI's button, such as type and onClick. |
Use it well
Colour changes ease; nothing moves.
The header's Ask a question is ButtonLink at size sm.
The label is the accessible name. Keep it a short verb.
Do: Use ButtonLink when the control goes to another page, and Button for what happens on this one.
Don't: Put a link inside a Button, or a button inside a link. Use ButtonLink.