Basic Spinner
Here’s a simple loading spinner fromexamples/spinner/main.go:
Key Concepts
Initialization
Create a spinner and set its style:Starting the Spinner
Return theTick command from Init():
Updating the Spinner
Pass all messages to the spinner’sUpdate() method:
Rendering
Include the spinner in your view:Available Spinner Styles
Theexamples/spinners directory shows all available spinner types:
Spinner Showcase Example
Fromexamples/spinners/main.go:
Spinner Style Reference
- Line
- Dot
- MiniDot
- Jump
- Pulse
- Points
- Globe
- Moon
- Monkey
Common Patterns
Spinner with Long-Running Task
Custom Spinner Colors
Multiple Spinners
Best Practices
Start in Init()
Always return
spinner.Tick from your Init() functionPass All Messages
Forward messages to the spinner in your default case
Style Consistently
Match spinner colors to your application theme
Show Context
Display what’s loading alongside the spinner
Running the Examples
Source Code
- examples/spinner - Basic spinner usage
- examples/spinners - All spinner styles
- examples/progress-download - Spinner with progress