Overview
TheButton component provides a styled, accessible button with support for multiple visual variants and sizes. Built with class-variance-authority (CVA) for type-safe variant handling.
Import
Basic Usage
Variants
The Button component supports three visual variants:- Primary
- Secondary
- Ghost
Sizes
Three size options are available:sm- Height: 28px (7), Padding: 12px (3), Font: 12px (xs)md- Height: 32px (8), Padding: 16px (4), Font: 14px (sm) - Defaultlg- Height: 36px (9), Padding: 20px (5), Font: 14px (sm)
Props
'primary' | 'secondary' | 'ghost'
default:"primary"
The visual style variant of the button.
'sm' | 'md' | 'lg'
default:"md"
The size of the button.
string
Additional CSS classes to apply.
boolean
Disables the button and reduces opacity to 50%.
ButtonHTMLAttributes<HTMLButtonElement>, so all standard button attributes are supported (onClick, type, disabled, etc.).
Accessibility Features
- Focus visible outline with 2px accent color and offset
- Disabled state prevents pointer events
- Semantic
<button>element - Proper ARIA attributes inherited from native button
Examples
Disabled State
With Icon and Text
gap-1.5 to automatically space child elements.
Custom Styling
Component Definition
Location:packages/gadget-ui/src/components/button.tsx:55
The Button uses forwardRef to support ref forwarding to the underlying button element.