Overview
The Spinner widget displays an animated loading indicator to provide visual feedback during asynchronous operations. It supports multiple animation variants and optional labels.Usage
Props
Spinner animation variant:
"dots"- Animated dots sequence"line"- Horizontal line animation"circle"- Spinning circle"bounce"- Bouncing animation"pulse"- Pulsing effect"arrows"- Rotating arrows"dots2"- Alternative dots pattern
Optional text label displayed after the spinner
Optional style override for the spinner and label
Optional reconciliation key for efficient updates
Examples
Basic Loading State
Multiple Spinner Variants
Conditional Loading
Styled Spinner
Loading State Patterns
Inline Loading
Full-Screen Overlay
Section Loading
Animation Behavior
The spinner animation is driven by the framework’s tick events:- Animation updates on every frame when the app is rendering
- Pauses automatically when the terminal is resized or suspended
- No manual animation state management required
Spinners automatically animate as long as they remain mounted. Remove the spinner from the view tree when loading completes.
Design System Integration
Spinners inherit theme colors by default:Accessibility
When using spinners for loading states:- Provide context - Include a descriptive label explaining what’s loading
- Time limits - Show alternative UI if loading exceeds expected duration
- Cancellation - Provide a way to cancel long-running operations
Best Practices
Use appropriate variants
Choose variants that match the operation duration:
- Quick operations:
"dots"or"pulse" - Long operations:
"circle"or"bounce"
Add descriptive labels
Always include a label explaining what’s loading to provide context to users.
Position strategically
Place spinners near the content being loaded rather than at arbitrary locations.
Remove when done
Ensure spinners are removed from the view tree when operations complete to avoid confusing users.