← Gallery
Primary (brand solid)
Neutral solid
Secondary (neutral weak)
Line
Ghost
Text button
Critical
Button
UI primitivebuttonStarts an action on the current screen: submit, save, open, delete.
Live preview
Starts an action on the current screen: submit, save, open, delete. One primary button per region of a screen; everything else is a quieter variant. Navigation to another page is a link, not a button.
Live examples
defaultPrimary (brand solid)
neutralNeutral solid
secondarySecondary (neutral weak)
outlineLine
ghostGhost
brandGhostText button
destructiveCritical
size
xs · 32pxsize
sm · 36pxsize
md · 40pxsize
lg · 52pxsize
icon · 40pxDisabled
Pair: secondary left, primary right
Anatomy
- Container — the
<button>(or the child element withasChild), height and radius from the size and the brand recipe, or the project's recorded default height and corner. - Leading or trailing icon — optional SVG, sized automatically per size.
- Label — a verb and an object, one to three words.
From the code
- Tokens consumed
accentbackgroundborderbranddestructiveforegroundsecondarysurface-mutedtext-disabledtext-primary- Radius
- recipe control radius (
ss-pattern-control→--ss-control-radius, 0–999px by brand recipe or the project's recorded corner) - Focus
- focus-visible:ring-2 · focus-visible:ring-brand/20 · focus-visible:ring-destructive/20
- Motion
- duration-150 · transition-colors
Variants
| Code | Designer name | Use when |
|---|---|---|
| default | Primary (brand solid) | The one main action in a region: Save, Place order. |
| neutral | Neutral solid | Strong emphasis that should not use the key colour, for example on a brand-coloured surface. |
| secondary | Secondary (neutral weak) | The alternative beside a primary: Close next to Confirm. |
| outline | Line | A bordered secondary action in toolbars and dense forms. |
| ghost | Ghost | Low-emphasis actions in dense UI, and icon-only buttons. |
| brandGhost | Text button | A key-colour text action without a surface: Retry, Maybe later. |
| destructive | Critical | An action that deletes or cannot be undone. |
States
| State | Looks | Note |
|---|---|---|
| Default | Per variant. | — |
| Pressed | Background one step darker (active: …/85, /90, /8). | Colour only; no scale change. |
| Disabled | surface-muted background, text-disabled text, pointer events off. | Keep the label readable; explain why nearby if it is not obvious. |
| Focus | 2px ring in the brand colour at 20%. | Keyboard only (focus-visible). |
| Loading | Not built in. | Swap the label for a 16px spinner, keep the size, block clicks (DESIGN-LANGUAGE §46). |
Do
- Label the outcome: "Save changes", "Delete project", never "Submit" or "OK" (UX-WRITING WB-1, WB-2).
- In a pair, put the primary on the right and the secondary on the left, 12px apart (DESIGN-LANGUAGE §46).
- Name both outcomes in a destructive dialog: "Delete / Keep" (UX-WRITING WB-3).
- Give icon-only buttons an
aria-label.
Don't
- Don't put two primary buttons in one region.
- Don't shrink on press (
active:scale) or use a gradient background (DESIGN-LANGUAGE §46). - Don't recolour a variant through
className(bg-…); pick a variant or add one to the contract. - Don't use
destructivefor emphasis that is not destructive.
Known gaps
- At the
:rootcontrol height (40px),md(40px),sm(36px),xs(32px) andicon(40px) are under the 44px touch minimum (DESIGN-LANGUAGE §41). Every size follows--ss-control-height, so the numbers move with the brand recipe or the project's recorded default height. - The default
mdbutton, the default input and the default select take one height from the brand recipe or the project's recorded default height (--ss-control-height), so they share a height in one context (CRAFT-BASELINE). Use the default size beside default form controls. - There is no hover style; pointer users get feedback only on press.
- There is no loading state; §46 describes one.
Machine checks
- Height under the 44px touch minimum (DESIGN-LANGUAGE §41) at the
:rootcontrol height (40px):xs32px,sm36px,md40px,icon40px. On touch surfaces, extend the hit area or use a taller size.
Sources: DESIGN-LANGUAGE §46 Button design rules; §41 Touch targets; §24 Interaction rules · UX-WRITING §W1 Buttons & actions (WB-1, WB-2, WB-3) · CRAFT-BASELINE: control heights (rule CRAFT-control-heights)
Size
3.0 KB
Exports
1
Imports
4
Type
ui
Exports
ButtonImports
- react
- @radix-ui/react-slot
- class-variance-authority
- ./utils
Source
View on GitHub →import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "./utils";
const buttonVariants = cva(
"ss-pattern-control inline-flex items-center justify-center whitespace-nowrap font-bold transition-colors duration-150 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 shrink-0 outline-none focus-visible:ring-2 focus-visible:ring-brand/20",
{
variants: {
variant: {
// brandSolid — key color background, white text
default:
"bg-brand text-white active:bg-brand/85 disabled:bg-surface-muted disabled:text-text-disabled",
// neutralSolid — inverse of the page: foreground as background, background as text (flips with the theme)
neutral:
"bg-foreground text-background active:bg-foreground/90 disabled:bg-surface-muted disabled:text-text-disabled",
// neutralWeak — quiet secondary surface, primary text
secondary:
"bg-secondary text-text-primary active:bg-accent disabled:bg-surface-muted disabled:text-text-disabled",
// criticalSolid — 위험 액션
destructive:
"bg-destructive text-white active:bg-destructive/85 focus-visible:ring-destructive/20 disabled:bg-surface-muted disabled:text-text-disabled",
// outline — 테두리만
outline:
"border border-border bg-transparent text-text-primary active:bg-surface-muted/50 disabled:border-surface-muted disabled:text-text-disabled dark:border-white/8",
// ghost — 배경/테두리 없음
ghost:
"bg-transparent text-text-primary active:bg-surface-muted/50 disabled:text-text-disabled",
// brandGhost — 키컬러 텍스트, 배경 없음
brandGhost:
"bg-transparent text-brand active:bg-brand/8 disabled:text-text-disabled",
},
size: {
xs: "h-[calc(var(--ss-control-height,40px)-8px)] px-3.5 gap-1 text-[13px] [&_svg:not([class*='size-'])]:size-3.5",
sm: "h-[calc(var(--ss-control-height,40px)-4px)] px-3.5 gap-1 text-[14px] [&_svg:not([class*='size-'])]:size-3.5",
md: "h-[var(--ss-control-height,40px)] px-4 gap-1.5 text-[14px] [&_svg:not([class*='size-'])]:size-4",
lg: "h-[calc(var(--ss-control-height,40px)+12px)] px-5 gap-2 text-[18px] [&_svg:not([class*='size-'])]:size-[22px]",
icon: "size-[var(--ss-control-height,40px)] [&_svg:not([class*='size-'])]:size-[18px]",
},
},
defaultVariants: {
variant: "default",
size: "md",
},
},
);
function Button({
className,
variant,
size,
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
}) {
const Comp = asChild ? Slot : "button";
return (
<Comp
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
);
}
export { Button, buttonVariants };