Skip to main content

Spinner

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Spinner component provides a rotating loading indicator with multiple sizes and colors. Built with Lucide React icons and class-variance-authority, it offers consistent styling and smooth animations. Perfect for buttons, cards, overlays, and any loading states that need visual feedback.

Basic Usage

With Label

Loading...

Processing data...

Saving changes...

Sizes

xs

sm

md

lg

xl

2xl

Colors

primary

secondary

success

error

warning

info

neutral

white

Loading Buttons

Card Loading States

Data Processing

File Upload

API Request

Overlay Loading

Content Area

This is some content that will be overlaid with a loading spinner when the load button is clicked.

Inline Spinners

Saving your changes...
Processing payment...
Syncing data with server...
Uploading files (3 of 10)...
Retrying connection...

Properties

Spinner

PropertyTypeDefaultDescription
size"xs" | "sm" | "md" | "lg" | "xl" | "2xl""md"Size of the spinner.
color"primary" | "secondary" | "success" | "error" | "warning" | "info" | "white" | "neutral""primary"Color theme of the spinner.
labelstring-Optional label displayed below the spinner.
classNamestring-Additional CSS classes for custom styling.

Size Reference

SizeDimensionsUse Case
xs16x16pxInline text, small buttons
sm24x24pxRegular buttons, form inputs
md32x32pxCards, default loading (default)
lg40x40pxLarge cards, prominent loading
xl56x56pxPage overlays, major operations
2xl80x80pxFull-page loading, splash screens

Color Reference

ColorThemeUse Case
primaryBrand colorGeneral loading states
secondarySecondary brandAlternative loading states
successGreenSuccess operations, confirmations
errorRedError states, failed operations
warningYellow/OrangeWarning states, caution
infoBlueInformation, data processing
whiteWhiteDark backgrounds, overlays
neutralGraySubtle loading states

Accessibility

The Spinner component includes accessibility considerations:

  • Visual Indication - Clear rotating animation indicates loading activity
  • Screen Reader Support - Can be enhanced with aria-label for loading announcements
  • Non-Interactive - Spinners are not focusable or interactive elements
  • Color Contrast - All color variants meet accessibility contrast requirements
  • Motion Sensitivity - Consider users with motion sensitivity preferences

Common Use Cases

The Spinner component is perfect for:

  • Button Loading - Async operations like save, submit, delete
  • Data Loading - API calls, database queries, file operations
  • Page Transitions - Route changes and navigation loading
  • Form Submission - Processing forms and validation
  • File Operations - Upload, download, processing files
  • Authentication - Login, logout, token refresh
  • Real-time Updates - Live data synchronization

Best Practices

  1. Appropriate Sizing - Match spinner size to the context and importance
  2. Meaningful Labels - Use descriptive labels that explain what's loading
  3. Color Context - Use colors that match the operation type (success, error, etc.)
  4. Consistent Timing - Don't show spinners for very quick operations (<200ms)
  5. User Feedback - Always provide context about what's happening
  6. Accessibility - Consider screen readers and motion preferences
  7. Performance - Use spinners to improve perceived performance
  8. Error Handling - Replace spinners with error states when operations fail