Button

Minimal button with subtle hover states and clean typography.

ActionsTailwind CSS

Overview

Buttons allow users to trigger actions with a single tap. They are the primary way for users to interact with your application.

When to use

  • To trigger an action or event
  • To submit a form
  • To navigate to another page
  • To confirm or cancel an action

Preview

Usage

html
<!-- Tailwind CSS pattern - copy the HTML/classes below -->

Class Variations

Swap these Tailwind classes to change the pattern's appearance:

Variants

VariationTailwind Classes
Primarybg-primary text-primary-foreground hover:bg-primary-hover
Secondarybg-surface-hover text-default
Outlinebg-surface-raised text-default border border-default hover:bg-surface-hover hover:border-emphasis
Ghosttext-muted hover:bg-surface-hover hover:text-default
Dangerbg-error-emphasis text-white hover:opacity-90

Sizes

VariationTailwind Classes
Smallh-8 px-3 rounded-md text-xs
Mediumh-10 px-4 rounded-lg text-sm

Default size

Largeh-12 px-6 rounded-lg text-base

States

VariationTailwind Classes
Disabledopacity-70 cursor-not-allowed

Add disabled attribute to button

Loadingopacity-70 cursor-not-allowed

Add spinner SVG and disabled attribute

Guidelines

Do

  • Use clear, action-oriented labels
  • Use primary variant for the main action on a page
  • Keep button text concise (1-3 words)
  • Use consistent button styling throughout your app

Don't

  • Don't use more than one primary button in a single view
  • Don't use vague labels like 'Click here'
  • Don't disable buttons without explaining why
  • Don't use buttons for navigation when a link would suffice

Accessibility

  • Use semantic <button> element for actions
  • Provide aria-label for icon-only buttons
  • Ensure sufficient color contrast
  • Make sure buttons are keyboard accessible

Examples

Primary

Secondary

Outline

Ghost

Danger

With Icon

Loading

Sizes

Related Components