Button
10 filesEvery clickable action on the site. A link that looks like a button uses asChild.
Variants
Sizes and icons
Hover
Keyboard focus
Disabled
When to use. Variant follows the role: primary or accent is the one action the view is about, secondary or outline sits next to it, ghost is a tool inside a dense component, link sends the reader somewhere from inside a section.
Do
- One primary or accent action per view.
- Icon before the label; only a directional arrow trails it.
- asChild with a Link when the button navigates.
- disabled for an action that is not available yet.
Don't
- Two accent buttons side by side.
- uppercase, normal-case or capitalize on a Button: the case lives in the component (guard buttonCaseFromComponent).
- A bare <button> styled by hand next to the library.
- Lower opacity to mean disabled on an enabled button.
Names, types and defaults read from components/ui/button.tsx at build time.
| Prop | Type | Default | What it does |
|---|---|---|---|
| variant | "link" | "primary" | "accent" | "secondary" | "outline" | "ghost" | null | "primary" | The role of the action. |
| size | "md" | "sm" | "icon" | "inline" | null | "md" | md in content, sm in dense rows, icon for an icon-only action, inline inside text. |
| asChild | boolean | false | Renders the child (a Link) with the button styles. |
| ... | <button> | – | Every native <button> attribute. className only for layout: margin, width, grid placement. |
Accessibility
- The visible label is the name; size icon needs an aria-label.
- Focus ring from the global :focus-visible rule, 2px, 3:1 against the page.
- md and sm sizes reach 2.75rem, the touch target minimum.
