Import
Usage
Sizes
Spinner comes in three sizes:Custom Color
Override the spinner color using thecolor prop:
In Buttons
Commonly used in buttons to show loading states:Centered Loading
Center the spinner in a container:With Text
Combine with text for context:Props
Size of the spinner:
sm: 16px (1rem)md: 24px (1.5rem)lg: 32px (2rem)
Custom color for the spinner. Accepts any CSS color value or CSS variable.
Additional CSS classes to apply to the spinner.
Accessible label for screen readers.
Accessibility
- Uses
role="status"for screen reader announcements - Includes default
aria-label="Loading"which can be customized - Ensure to provide descriptive labels when multiple spinners are present
Styling
The Spinner component:- Uses CSS border animation for smooth rotation
- Inherits text color by default (can be overridden with
colorprop) - Automatically applies appropriate border width for each size
- Includes
animate-spinutility for continuous rotation
Best Practices
- Use
smsize for inline elements like buttons - Use
mdorlgfor standalone loading indicators - Always provide descriptive
aria-labelfor context - Consider showing fallback content for users who have reduced motion enabled