ComponentsMarkdown
Button
Trigger an action or form submission using five semantic variants and four token-paired sizes. Use asChild to render a link with button styling instead of a separate link variant.
Live example
Primary clicks: 0
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "primary" | "secondary" | "outline" | "ghost" | "destructive" | "primary" | Visual hierarchy and semantic color role. |
| size | "xs" | "sm" | "md" | "lg" | "md" | Height, corner radius, horizontal padding, and SVG icon size. |
| asChild | boolean | false | Merge button props and classes onto the single child element via Radix Slot. |
| type | "button" | "submit" | "reset" | "button" | Native button type when asChild is false. |
| disabled | boolean | false | Disables interaction using step 3 background and step 8 text without opacity. |
Sizes and tokens
| Tier / Role | Token | Value |
|---|---|---|
| xs | --control-height-xs / --control-radius-xs / --control-icon-xs | 24px height · radius-sm (4px) · 16px icon |
| sm | --control-height-sm / --control-radius-sm / --control-icon-sm | 32px height · radius-sm (4px) · 16px icon |
| md | --control-height-md / --control-radius-md / --control-icon-md | 40px height · radius-md (8px) · 20px icon |
| lg | --control-height-lg / --control-radius-lg / --control-icon-lg | 48px height · radius-md (8px) · 24px icon |
| Primary fill | --primary / --primary-hover / --primary-active | Brand step 9 → 10 → 9 |
| Disabled | --disabled / --disabled-foreground | Neutral step 3 background · step 8 text |
States
Code
import { Button } from "@freshgemui/monoplinth";
export function Example() {
return (
<div className="flex items-center gap-3">
<Button type="submit">Save changes</Button>
<Button variant="outline" asChild>
<a href="/docs">Read documentation</a>
</Button>
</div>
);
}Do and don't
Do: Keep one primary action per group and use asChild for navigation
Pair one primary button with secondary or outline actions, and wrap an anchor element with asChild when navigating to a URL.
Don't: Use opacity for disabled buttons or nest anchors inside buttons
Do not add opacity-50 to disabled buttons or wrap an anchor tag inside a button element.
Accessibility
- Defaults
typeto"button"so buttons inside<form>elements never submit unexpectedly. - Renders a
2px--ringoutline with a2pxoffset on:focus-visibleonly. - Uses
24px(xs) as the minimum height to satisfy WCAG 2.5.8 target size, and48px(lg) for primary mobile touch targets. - Disables
transition-colorswhenprefers-reduced-motion: reduceis active.
Rationale
Limiting Button to five semantic variants and omitting a link variant keeps <button> for actions and <a> for navigation while sharing one calibrated sizing scale with Input and Textarea.