Button

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

Examples

Size

Small
Default
Large
<div class="flex flex-col items-start gap-8 sm:flex-row">
  <div class="flex items-start gap-2">
    <c-button size="sm" variant="outline">Small</c-button>
    <c-button size="icon-sm" variant="outline" aria-label="Submit">→</c-button>
  </div>
  <div class="flex items-start gap-2">
    <c-button variant="outline">Default</c-button>
    <c-button size="icon" variant="outline" aria-label="Submit">→</c-button>
  </div>
  <div class="flex items-start gap-2">
    <c-button variant="outline" size="lg">Large</c-button>
    <c-button size="icon-lg" variant="outline" aria-label="Submit">→</c-button>
  </div>
</div>

Default

Button
<c-button>Button</c-button>

Secondary

Secondary
<c-button variant="secondary">Secondary</c-button>

Outline

Outline
<c-button variant="outline">Outline</c-button>

Ghost

Ghost
<c-button variant="ghost">Ghost</c-button>

Destructive

Destructive
<c-button variant="destructive">Destructive</c-button>
Link
<c-button variant="link">Link</c-button>

Icon

<c-button variant="outline" size="icon" aria-label="Submit">→</c-button>

With Icon

New Branch
<c-button variant="outline" size="sm">
  <c-lucide-icon icon="git-branch" size="16"></c-lucide-icon>
  New Branch
</c-button>

Loading

Submit
<c-button size="sm" variant="outline" disabled>
  <svg
    class="animate-spin"
    xmlns="http://www.w3.org/2000/svg"
    width="16"
    height="16"
    viewBox="0 0 24 24"
    fill="none"
    stroke="currentColor"
    stroke-width="2"
    stroke-linecap="round"
    stroke-linejoin="round"
  >
    <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  </svg>
  Submit
</c-button>
Go to Components
<c-button href="/components/button">Go to Components</c-button>

API Reference

Button

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

Prop Type Default Description
variant 'default' | 'outline' | 'ghost' | 'destructive' | 'secondary' | 'link' 'default' Visual style variant
size 'default' | 'sm' | 'lg' | 'icon' | 'icon-sm' | 'icon-lg' 'default' Size of the component
button-classes string - Additional CSS classes for the element
href string - URL for the link
type 'button' | 'submit' | 'reset' 'button' Type of the component
disabled boolean false Whether the component is disabled

When href is provided, the button renders as an anchor (<a>) element instead of a <button>.