For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
43
Sponsor

Button

Displays a button or a component that looks like a button.

import { Button } from "@/components/ui/button";

export function ButtonDemo() {
  return <Button>Button</Button>;
}

Installation

$ pnpm dlx shadcn@latest add https://shadcn-cssinjs.com/r/button.json

Usage

import { Button } from "@/components/ui/button/button";
<Button variant="outline">Button</Button>

Examples

Variants

Use the variant prop to change the button style.

import { Button } from "@/components/ui/button";

export function ButtonVariants() {
  return (
    <div style={{ display: "flex", flexWrap: "wrap", gap: 8 }}>
      <Button>Default</Button>

Size

Use the size prop to change the button size.

import { Button } from "@/components/ui/button";

export function ButtonSizes() {
  return (
    <div style={{ alignItems: "center", display: "flex", gap: 8 }}>
      <Button size="sm">Small</Button>
import { Button } from "@/components/ui/button";

export function ButtonLink() {
  return <Button variant="link">Link</Button>;
}

Icon

Use size="icon" for a square, icon-only button.

import { ChevronRightIcon } from "lucide-react";

import { Button } from "@/components/ui/button";

export function ButtonIcon() {
  return (

With Icon

Place an icon before or after the label.

import { MailIcon } from "lucide-react";

import { Button } from "@/components/ui/button";

export function ButtonWithIcon() {
  return (

Disabled

import { Loader2Icon } from "lucide-react";

import { Button } from "@/components/ui/button";

export function ButtonDisabled() {
  return (

Default

import { Button } from "@/components/ui/button";

export function ButtonDefault() {
  return <Button>Button</Button>;
}

Outline

import { Button } from "@/components/ui/button";

export function ButtonOutline() {
  return <Button variant="outline">Outline</Button>;
}

Secondary

import { Button } from "@/components/ui/button";

export function ButtonSecondary() {
  return <Button variant="secondary">Secondary</Button>;
}

Ghost

import { Button } from "@/components/ui/button";

export function ButtonGhost() {
  return <Button variant="ghost">Ghost</Button>;
}

Destructive

import { Button } from "@/components/ui/button";

export function ButtonDestructive() {
  return <Button variant="destructive">Destructive</Button>;
}

Rounded

import { ArrowUpIcon } from "lucide-react";

import { Button } from "@/components/ui/button";

export function ButtonRounded() {
  return (

Spinner

import { Button } from "@/components/ui/button";
import { Spinner } from "@/components/ui/spinner";

export function ButtonSpinner() {
  return (
    <div className="flex gap-2">

Button Group

import { Button } from "@/components/ui/button";
import { ButtonGroup } from "@/components/ui/button-group";

export function ButtonGroupExample() {
  return (
    <ButtonGroup>

Use the render prop to render the button as a link.

import { Button } from "@/components/ui/button";

export function ButtonAsLink() {
  return <Button render={<a href="#link">Login</a>} />;
}

RTL

To enable right-to-left support, see the RTL guide.

"use client";

import { ArrowRightIcon, PlusIcon } from "lucide-react";

import { useTranslation } from "@/components/language-selector";
import type { Translations } from "@/components/language-selector";

API Reference

Button

The Button component is a wrapper around the button element that adds a variety of styles and functionality.

PropTypeDefault
variant"default" | "destructive" | "outline" | "secondary" | "ghost" | "link""default"
size"default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg""default"
renderReact.ReactElement-

Use the render prop to render the button as a different element (the Base UI equivalent of asChild).