COMPONENT · 01
Button
7 style variants, 7 intent colors, elevated and glow effects, a loading state with spinner, icons, and tooltip.
- @ui-sdk/react
- class-variance-authority
- lucide-react
Preview
import { Button } from "@/components/ui/button"
export function ButtonVariantsDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button>Solid</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="soft">Soft</Button>
<Button variant="dashed">Dashed</Button>
<Button variant="subtle">Subtle</Button>
<Button variant="surface">Surface</Button>
</div>
)
}Copy code
Colors
import { Button } from "@/components/ui/button"
export function ButtonColorsDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button color="primary">Primary</Button>
<Button color="secondary">Secondary</Button>
<Button color="muted">Muted</Button>
<Button color="info">Info</Button>
<Button color="warning">Warning</Button>
<Button color="success">Success</Button>
<Button color="error">Error</Button>
</div>
)
}Copy code
Sizes
padding sets the padding and a matching text size.
import { Button } from "@/components/ui/button"
export function ButtonSizesDemo() {
return (
<div className="flex flex-wrap items-end justify-center gap-2.5">
<Button padding="none">None</Button>
<Button padding="xs">XS</Button>
<Button padding="sm">SM</Button>
<Button padding="base">Base</Button>
<Button padding="md">MD</Button>
<Button padding="lg">LG</Button>
<Button padding="xl">XL</Button>
</div>
)
}Copy code
Radius
Create
import { Plus } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonRadiusDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button radius="none">None</Button>
<Button radius="sm">SM</Button>
<Button radius="md">MD</Button>
<Button radius="lg">LG</Button>
<Button radius="xl">XL</Button>
<Button radius="full">Full</Button>
<Button icon={<Plus aria-hidden="true" />} radius="full" tooltip="Create" />
</div>
)
}Copy code
Text size
textSize changes the text size on its own, keeping the padding.
import { Button } from "@/components/ui/button"
export function ButtonTextSizeDemo() {
return (
<div className="flex flex-wrap items-end justify-center gap-2.5">
<Button textSize="xs">XS</Button>
<Button textSize="sm">SM</Button>
<Button textSize="base">Base</Button>
<Button textSize="lg">LG</Button>
<Button textSize="xl">XL</Button>
<Button textSize="2xl">2XL</Button>
<Button textSize="display">Display</Button>
</div>
)
}Copy code
Icon size
import { Sparkles } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonIconSizeDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button iconSize="xs" startIcon={<Sparkles aria-hidden="true" />}>XS</Button>
<Button iconSize="sm" startIcon={<Sparkles aria-hidden="true" />}>SM</Button>
<Button iconSize="base" startIcon={<Sparkles aria-hidden="true" />}>Base</Button>
<Button iconSize="md" startIcon={<Sparkles aria-hidden="true" />}>MD</Button>
<Button iconSize="lg" startIcon={<Sparkles aria-hidden="true" />}>LG</Button>
<Button iconSize="xl" startIcon={<Sparkles aria-hidden="true" />}>XL</Button>
</div>
)
}Copy code
States
import { Button } from "@/components/ui/button"
export function ButtonStatesDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button isLoading loadingText="Loading…" tapAnimation={false}>
Loading
</Button>
<Button disabled>Disabled</Button>
<Button effect="elevated">Elevated</Button>
<Button color="error">Error</Button>
</div>
)
}Copy code
Glow
effect="glow" adds a glow in the button's own color. Use one effect at a time.
import { Button } from "@/components/ui/button"
export function ButtonGlowDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button effect="glow">Primary</Button>
<Button effect="glow" color="info">Info</Button>
<Button effect="glow" color="success">Success</Button>
<Button effect="glow" color="warning">Warning</Button>
<Button effect="glow" color="error">Error</Button>
<Button effect="glow" variant="outline">Outline</Button>
<Button effect="glow" variant="ghost">Ghost</Button>
</div>
)
}Copy code
Icons
import { ArrowRight, Download, Plus, Trash2 } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonIconsDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button startIcon={<Download aria-hidden="true" />}>Download</Button>
<Button endIcon={<ArrowRight aria-hidden="true" />}>Continue</Button>
<Button startIcon={<Plus aria-hidden="true" />} endIcon={<ArrowRight aria-hidden="true" />}>
Both
</Button>
<Button variant="outline" color="error" startIcon={<Trash2 aria-hidden="true" />}>
Delete
</Button>
</div>
)
}Copy code
Icon only
An icon-only button has no visible text, so give it a name with aria-label or tooltip.
Download
import { Bell, Download, Plus, Star, Trash2 } from "lucide-react"
import { Button } from "@/components/ui/button"
// An icon-only button has no visible text: name it with `aria-label` or `tooltip`.
export function ButtonIconOnlyDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button icon={<Plus aria-hidden="true" />} aria-label="Add" />
<Button icon={<Star aria-hidden="true" />} variant="outline" aria-label="Favorite" />
<Button icon={<Bell aria-hidden="true" />} variant="ghost" aria-label="Notifications" />
<Button icon={<Trash2 aria-hidden="true" />} color="error" variant="soft" aria-label="Delete" />
<Button icon={<Download aria-hidden="true" />} effect="elevated" tooltip="Download" />
</div>
)
}Copy code
With tooltip
Create a new element
Add item
Delete selection
You need admin permissions
import { Plus, Trash2 } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonTooltipDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button tooltip="Create a new element">New</Button>
<Button icon={<Plus aria-hidden="true" />} variant="outline" tooltip="Add item" />
<Button icon={<Trash2 aria-hidden="true" />} color="error" variant="ghost" tooltip="Delete selection" />
{/* A disabled button with a tooltip stays focusable, so the tooltip is still reachable. */}
<Button disabled tooltip="You need admin permissions">
Admin only
</Button>
</div>
)
}Copy code
Responsive
Resize the window below 640px to see the effect.
import { Plus } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonResponsiveDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
{/* Text visually hidden below `sm`, still read by screen readers */}
<Button mobile="only-icon" startIcon={<Plus aria-hidden="true" />}>
New
</Button>
{/* Full width below `sm`, auto from `sm` up */}
<Button mobile="full-width">Full width</Button>
{/* Hidden below `sm` */}
<Button mobile="hidden">Desktop only</Button>
</div>
)
}Copy code
Custom styles
iconClassName and textClassName style the icon and the text separately, without losing the variant.
import { Bell, Download, Sparkles, Star } from "lucide-react"
import { Button } from "@/components/ui/button"
export function ButtonCustomStylesDemo() {
return (
<div className="flex flex-wrap items-center justify-center gap-2.5">
<Button startIcon={<Star aria-hidden="true" />} iconClassName="text-warning">
Favorite
</Button>
<Button
startIcon={<Sparkles aria-hidden="true" />}
iconClassName="text-info"
textClassName="italic font-light"
variant="outline"
>
Special
</Button>
<Button
startIcon={<Bell aria-hidden="true" />}
iconClassName="text-info"
textClassName="tracking-widest uppercase text-xs"
variant="outline"
color="info"
>
Notifications
</Button>
<Button
icon={<Download aria-hidden="true" />}
iconClassName="text-success"
variant="soft"
color="success"
aria-label="Download"
/>
</div>
)
}Copy code
Installation
npx shadcn@latest add https://lanzate-ui.vercel.app/r/button.jsonCopy code
Usage
import { Button } from "@/components/ui/button"
// Default
<Button>Take off</Button>
// Variant and color
<Button variant="outline" color="success">
Confirmed
</Button>
// Icon and loading state
<Button isLoading={isPending} loadingText="Saving..." startIcon={<Save />}>
Save
</Button>
// Elevated, with a tooltip
<Button effect="elevated" tooltip="Main action">
Publish
</Button>
// As a link
<Button render={<a href="/docs" />}>Read the docs</Button>Copy code
API
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "solid" | "outline" | "ghost" | "soft" | "dashed" | "subtle" | "surface" | "solid" | Visual style. |
color | "primary" | "secondary" | "muted" | "info" | "warning" | "success" | "error" | "primary" | Intent color, from the design tokens. |
effect | "none" | "elevated" | "glow" | "none" | Depth treatment: a drop shadow, or a glow in the button's color. One at a time. |
padding | "none" | "xs" | "sm" | "base" | "md" | "lg" | "xl" | "base" | Padding and text size. |
radius | "none" | "sm" | "md" | "lg" | "xl" | "full" | "md" | Corner radius. |
textSize | "xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "display" | Text size independent of padding. | |
iconSize | "xs" | "sm" | "base" | "md" | "lg" | "xl" | Icon size relative to the text. | |
startIcon | ReactNode | Icon before the text. | |
endIcon | ReactNode | Icon after the text. | |
icon | ReactNode | Icon-only, square button. Name it with `aria-label` or `tooltip`. | |
isLoading | boolean | false | Shows a spinner, disables the button and marks it busy. |
loadingText | string | Replaces the label while loading. | |
tooltip | ReactNode | Wraps the button in a Tooltip. A disabled button with a tooltip stays focusable. | |
tapAnimation | boolean | true | Scales down slightly on press. |
mobile | "only-icon" | "full-width" | "hidden" | Behavior below the `sm` breakpoint. `only-icon` hides the label (kept for screen readers) and makes the button square, like an icon-only one. | |
render | ReactElement | Renders another element, like a link: render={<a href="/docs" />}. | |
className | string | Classes for the root element, merged after the variants. | |
iconClassName | string | Classes for the icon wrapper (startIcon, endIcon, icon). | |
textClassName | string | Classes for the text wrapper (children or loadingText). |