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

Usage

You can use one of the btn classes to style a button element:

  • Variants:
    • btn or btn-primary for default/primary buttons.
    • btn-secondary for secondary buttons.
    • btn-destructive for destructive buttons.
    • btn-outline for outline buttons.
    • btn-ghost for ghost buttons.
    • btn-link for link buttons.
  • Sizes:
    • btn-xs for extra small buttons.
    • btn-sm for small buttons.
    • btn-lg for large buttons.
    • btn-icon for icon buttons. This can be combined with sizes and variants, for example btn-sm-icon-outline or btn-xs-icon-destructive.

Button classes are combined into a single class name. Use btn-{variant}, btn-{size}, btn-{size}-{variant}, btn-icon-{variant}, or btn-{size}-icon-{variant}. Do not stack classes like btn-sm btn-outline; use btn-sm-outline instead.

Basecoat follows Tailwind v4's default button cursor behavior and does not force cursor: pointer.

<button type="button" class="btn">Button</button>
<button type="button" class="btn">Default</button>
<button type="button" class="btn-outline">Outline</button>
<button type="button" class="btn-sm">Small</button>
<button type="button" class="btn-sm-outline">Small outline</button>
<button type="button" class="btn-icon-outline" aria-label="Settings">
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /><circle cx="12" cy="12" r="3" /></svg>
</button>
<button type="button" class="btn-sm-icon-outline" aria-label="Settings">
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" /><circle cx="12" cy="12" r="3" /></svg>
</button>

Examples

Size

Use size-specific classes to change the size of the button.

Default

Outline

Secondary

Ghost

Destructive

Icon

With Icon

Mark inline icons with data-icon="inline-start" or data-icon="inline-end" when the button should use icon-aware spacing.

Rounded

Use standard Tailwind classes to override the button radius.

Spinner

Button Group

To group related buttons, use the Button Group component.

RTL

Buttons support right-to-left layouts through logical spacing. Add dir="rtl" to the button or an ancestor. Directional icons should be flipped explicitly.