Import
Usage
Props
The text content displayed on the button.
The visual style variant of the button:
primary- Filled button with primary color and shadowsecondary- Filled button with secondary colorghost- Transparent background with hover effectdestructive- Filled button with destructive/danger color and shadowoutline- Transparent with border outline
The size of the button:
xs- Height 7 (28px), text xs, padding 2.5sm- Height 8 (32px), text sm, padding 3md- Height 9 (36px), text sm, padding 4lg- Height 10 (40px), text base, padding 5xl- Height 11 (44px), text base, padding 6
Whether the button is disabled. Disabled buttons have reduced opacity and cannot be clicked.
Whether the button is in a loading state. Shows a spinner and disables interaction.
The aria-label is updated to include “loading” for accessibility.
Callback function triggered when the button is clicked. Ignored when disabled or loading.
Additional CSS classes to apply to the button element.
Forward ref to the underlying button element.
Accessibility
- Uses semantic
<button>element withtype="button" - Sets
disabledandaria-disabledattributes when disabled or loading - Updates
aria-labelto include loading state:"{label} — loading" - Includes focus-visible ring for keyboard navigation
- Click handlers are properly disabled when button is disabled or loading
Styling
The Button component uses Tailwind CSS classes and supports:- Smooth transitions (150ms ease-out)
- Focus ring with offset for keyboard navigation
- Hover and active states for all variants
- Disabled state with reduced opacity (50%)
- Shadow effects on primary and destructive variants
Variant Styles
- Primary: Primary background with shadow, 90% opacity on hover, 80% on active
- Secondary: Secondary background, transitions to accent on hover/active
- Ghost: Transparent background, accent background on hover
- Destructive: Destructive background with shadow, 90% opacity on hover, 80% on active
- Outline: Border with transparent background, accent on hover