Documentation
¶
Overview ¶
Package shimmer provides animated shimmering text for terminal UIs.
A wave of light sweeps across text, creating a modern loading indicator. Works standalone or as a Bubble Tea component.
Quick start:
shimmer.Run("Loading", "#00D787")
With background task:
shimmer.NewSpinner("Installing", "#00D787").
Action(func() { exec.Command("npm", "install").Run() }).
Run()
As Bubble Tea component:
m := shimmer.New("Loading", "#00D787")
// use m.Init(), m.Update(), m.View() in your Bubble Tea app
Index ¶
Constants ¶
const ( DefaultInterval = 50 * time.Millisecond // Animation frame rate DefaultPeakLight = 90 // Maximum lightness percentage (0-100) DefaultWaveWidth = 8 // Number of characters in the wave DefaultWavePause = 8 // Pause between wave loops (in characters) )
Default configuration values for the shimmer effect.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run displays shimmering text until the user presses Ctrl+C, q, or Esc. This is a blocking call that handles all Bubble Tea setup.
Example:
shimmer.Run("Loading", "#00D787")
With options:
shimmer.Run("Processing", "#FFC000",
shimmer.WithInterval(100*time.Millisecond),
shimmer.WithWaveWidth(12),
)
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model creates an animated shimmer effect on text. A wave of brightened color sweeps across the text, creating a loading indicator.
func New ¶
New creates a new shimmer model with the given text and base color. Color should be a hex color like "#00D787".
func (Model) SetLoading ¶
SetLoading enables or disables the shimmer animation.
type Option ¶
type Option func(*Model)
Option is a function that configures a Model.
func WithDirection ¶
WithDirection sets the wave direction (left or right).
func WithInterval ¶
WithInterval sets the animation speed (time between frames).
func WithPeakLight ¶
WithPeakLight sets the maximum lightness (0-100). Higher = brighter shimmer.
func WithWavePause ¶
WithWavePause sets the pause between wave loops (in character positions).
func WithWaveWidth ¶
WithWaveWidth sets the width of the shimmer wave in characters.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner provides a builder pattern for running shimmer with a background action.
func NewSpinner ¶
NewSpinner creates a spinner builder for running shimmer with background work.
Example:
shimmer.NewSpinner("Installing", "#00D787").
Action(func() { exec.Command("npm", "install").Run() }).
Run()
func (*Spinner) Action ¶
Action sets a function to run while the shimmer animates. The shimmer stops when the action completes.