Components
Spinner
A versatile loading spinner component that provides visual feedback for loading states. Supports multiple sizes, variants, and customization options.
Props
className
: string (optional) - Additional CSS classesvariant
: ‘primary’ | ‘secondary’ | ‘success’ | ‘warning’ | ‘danger’ (optional) - Color variant of the spinnersize
: ‘xs’ | ‘sm’ | ‘md’ | ‘lg’ (optional) - Size of the spinner
Usage Examples
Basic Spinner
Different Sizes
Color Variants
With Custom Styling
In Button
Loading State
Styling
The component uses Tailwind CSS for styling and includes:
- Smooth animation
- Color variants
- Size options
- Border styling
- Dark mode support
- Customizable colors
- Responsive design
Size Guide
xs
: 16px - For inline or compact UI elementssm
: 20px - For buttons or small containersmd
: 32px - Default size, for general uselg
: 40px - For prominent loading states
Color Variants
primary
: Brand color, default optionsecondary
: Neutral color for secondary actionssuccess
: Green for success stateswarning
: Yellow for warning statesdanger
: Red for error states
Best Practices
-
Usage Guidelines:
- Use appropriate sizes for context
- Choose meaningful color variants
- Consider loading duration
- Maintain visual hierarchy
-
Implementation:
- Center in containers
- Match button heights
- Use consistent variants
- Consider mobile views
-
Accessibility:
- Add loading announcements
- Maintain color contrast
- Consider reduced motion
- Provide text alternatives
Implementation Notes
- Uses CSS animations
- Supports theme customization
- Maintains aspect ratio
- Handles color modes
- Responsive sizing
- Performance optimized