Documentation
¶
Overview ¶
Package spinner renders a small animated glyph next to an optional label, the way an agent UI signals "working on it". A spinner cycles through a fixed list of frames on a fixed interval and stops when the parent model removes it from the View.
Spinners are stateless from the caller's perspective: each Update returns a new Spinner with the next frame, and Init returns the first tick command that drives the animation forward.
Index ¶
- type Spinner
- func (s Spinner) Frame() int
- func (s Spinner) Init() tea.Cmd
- func (s Spinner) Update(msg tea.Msg) (Spinner, tea.Cmd)
- func (s Spinner) View() string
- func (s Spinner) WithColor(c lipgloss.Color) Spinner
- func (s Spinner) WithID(id string) Spinner
- func (s Spinner) WithInterval(d time.Duration) Spinner
- func (s Spinner) WithLabel(label string) Spinner
- func (s Spinner) WithStyle(style Style) Spinner
- type Style
- type TickMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner is an animated indicator with an optional label.
func (Spinner) Init ¶
Init returns the first tick command. Subsequent ticks are scheduled by Update as long as the parent forwards TickMsg.
func (Spinner) Update ¶
Update advances the frame when it receives this Spinner's TickMsg. All other messages pass through unchanged.
func (Spinner) WithID ¶
WithID tags this spinner so a parent model with multiple spinners can route TickMsg messages by ID.
func (Spinner) WithInterval ¶
WithInterval overrides the per-frame interval. Minimum 16ms.
type Style ¶
type Style int
Style enumerates the built-in animation styles.
const ( // StyleDots is a ten-frame braille rotator. The shadcn-ish default. StyleDots Style = iota // StyleLine is the classic - \ | / line spinner. StyleLine // StyleArc cycles a quarter-arc around a center point. StyleArc // StylePulse fades through four block characters. StylePulse // StyleBounce moves a single dot up and down. StyleBounce )
