Components
Button
A comprehensive and customizable button component that serves as a fundamental building block for user interactions in your application.
A versatile button component that supports multiple variants, sizes, and states. Designed to provide consistent button styling across the application while maintaining flexibility and accessibility. This component is built with modern web practices and follows the WAI-ARIA guidelines for maximum accessibility.
Key Features
- Flexible Styling: Multiple variants and sizes to match your design system
- Accessibility Built-in: ARIA compliant with keyboard navigation support
- Icon Support: Seamless integration with icons from popular icon libraries
- Responsive Design: Adapts to different screen sizes and device types
- TypeScript Support: Full type safety with comprehensive TypeScript definitions
- Customizable: Extensive styling options through Tailwind CSS classes
Props
size
: ‘sm’ | ‘md’ | ‘lg’ - Controls the button size- ‘sm’: Small size (24px height), suitable for compact UIs and dense layouts
- ‘md’: Medium size (32px height), default option for most use cases
- ‘lg’: Large size (40px height), good for prominent actions and touch targets
variant
: ‘primary’ | ‘secondary’ | ‘warning’ | ‘black’ | ‘danger’ - Sets the button’s visual style- ‘primary’: Main action buttons, used for primary CTAs and important actions
- ‘secondary’: Less prominent actions, perfect for secondary options
- ‘warning’: Actions that need caution, used for potentially risky operations
- ‘black’: High contrast actions, ideal for maximum visibility
- ‘danger’: Destructive or dangerous actions, such as delete operations
outline
: boolean - When true, renders a bordered button without background, useful for less prominent actionsicon
: ReactNode - Optional icon to display alongside text, supports any React componentchildren
: ReactNode - Button content (text or other React components)className
: string - Additional CSS classes for custom styling- All standard HTML button attributes (type, disabled, onClick, etc.)
Usage Examples
Basic Buttons
Variant Examples
Outline Style
With Icons
Disabled State
Accessibility
- Fully keyboard accessible
- Proper ARIA attributes maintained
- Focus states clearly visible
- Disabled states properly handled
Styling
The component uses Tailwind CSS for styling and includes:
- Consistent padding and spacing
- Hover and active states
- Focus rings for keyboard navigation
- Smooth transitions
- Support for light and dark themes
- Disabled state styling
Best Practices
-
Use the appropriate variant for the action’s context:
- Primary for main actions
- Secondary for alternative actions
- Danger for destructive actions
- Warning for cautionary actions
-
Maintain consistent sizing within the same view:
- Use larger sizes for main actions
- Use smaller sizes for compact layouts
- Keep similar actions the same size
-
Include clear, action-oriented text:
- Use verbs to describe the action
- Keep text concise
- Be specific about the action’s result