Button
A versatile button component with multiple variants and sizes
Quick Preview
Structure
Anatomy of the Button β what parts it can contain and their roles.
States
Hover, click, or press Tab to focus each button and observe live CSS transitions.
Primary β interactive states
Hover or Tab to each cell to trigger the live state
Default
Resting
Hover
β Move cursor over
Focus
β¨ Tab key to reach
Disabled
pointer-events-none
Loading
disabled + spinner
Variants β all four at rest
Click any button to see its active state
Primary
Secondary
Outline
Ghost
Variants β disabled state
All variants with disabled prop applied
Primary
Secondary
Outline
Ghost
Sizes
Three size tokens β sm md (default) lg.
Sizes β sm / md / lg
Visual comparison of all three size tokens
Small β sm
px-4 py-2 text-sm
Medium β md
px-6 py-3 text-base Β· default
Large β lg
px-8 py-4 text-lg
Installation
// Copy the Button component fromsrc/components/ui/Button.tsx
Usage
import { Button } from '@/components/ui/Button'export default function Example() {return (<Button variant="primary" size="md">Get started</Button>)}
Examples
With Icons
Pass icons as children alongside the label text
Full Width
Stretch to container width with className w-full
Prompt Preview
Copy a prompt that recreates this UI
Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.
Copy-ready AI prompt
Starts from the current visual reference and project constraints.
Tweak only product-specific copy or data after the first generation pass.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "primary" | "secondary" | "outline" | "ghost" | "primary" | Visual style variant of the button |
size | "sm" | "md" | "lg" | "md" | Size of the button |
asChild | boolean | - | Render as a child component (for custom elements) |
disabled | boolean | - | Disable button interactions |
Features
- βMultiple variants (primary, secondary, outline, ghost)
- βThree sizes (sm, md, lg)
- βForwardRef support
- βDisabled state handling
- βSmooth transitions
- βFocus-visible ring