Skip to content
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

PropTypeDefaultDescription
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.
asChildbooleanfalseMerge button props and classes onto the single child element via Radix Slot.
type"button" | "submit" | "reset""button"Native button type when asChild is false.
disabledbooleanfalseDisables interaction using step 3 background and step 8 text without opacity.

Sizes and tokens

Tier / RoleTokenValue
xs--control-height-xs / --control-radius-xs / --control-icon-xs24px height · radius-sm (4px) · 16px icon
sm--control-height-sm / --control-radius-sm / --control-icon-sm32px height · radius-sm (4px) · 16px icon
md--control-height-md / --control-radius-md / --control-icon-md40px height · radius-md (8px) · 20px icon
lg--control-height-lg / --control-radius-lg / --control-icon-lg48px height · radius-md (8px) · 24px icon
Primary fill--primary / --primary-hover / --primary-activeBrand step 9 → 10 → 9
Disabled--disabled / --disabled-foregroundNeutral step 3 background · step 8 text

States

As child link

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 type to "button" so buttons inside <form> elements never submit unexpectedly.
  • Renders a 2px --ring outline with a 2px offset on :focus-visible only.
  • Uses 24px (xs) as the minimum height to satisfy WCAG 2.5.8 target size, and 48px (lg) for primary mobile touch targets.
  • Disables transition-colors when prefers-reduced-motion: reduce is 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.