Skip to main content

Crate tui_spinner

Crate tui_spinner 

Source
Expand description

§tui-spinner

Customizable animated spinner widgets for Ratatui TUI applications.

§Widgets

WidgetMotionKey options
LinearSpinnerScrolling window or bouncing dot along a straight axisdirection, flow, linear_style
SquareSpinnerBraille-dot arc rotating around a square ringsize, spin, centre
CircleSpinnerBraille-dot arc rotating around a circular ringradius, spin, arc_len
RectSpinnerBraille-dot arc rotating around a configurable rectangleshape, spin, centre
BarSpinnerSolid bar with a bouncing or looping glow arcbar_style, motion, spin, track, fade_width
FluxSpinnerSingle-character glyph cycling through a frame sequenceframes, spin, phase_step
SquareSpinnerLegacy alias for RectSpinner::Square

§Quick start

use ratatui::style::Color;
use tui_spinner::{
    BarMotion, BarSpinner, BarStyle, Centre, CircleSpinner,
    Direction, FluxFrames, FluxSpinner, Flow, LinearSpinner,
    LinearStyle, RectShape, RectSpinner, Spin, SquareSpinner,
};

// Vertical bouncing dot
let v = LinearSpinner::new(42)
    .direction(Direction::Vertical)
    .linear_style(LinearStyle::Braille)
    .active_color(Color::Cyan);

// Square arc, clockwise, filled centre
let sq = SquareSpinner::new(42)
    .size(3)
    .spin(Spin::Clockwise)
    .centre(Centre::Filled)
    .arc_color(Color::Cyan);

// Circular arc, counter-clockwise
let circle = CircleSpinner::new(42)
    .radius(5)
    .spin(Spin::CounterClockwise)
    .arc_color(Color::Magenta);

// Bouncing braille bar (Bounce) — fills available width automatically
let bounce = BarSpinner::new(42)
    .arc_color(Color::Cyan)
    .dim_color(Color::DarkGray);

// Continuous sweep (Loop) with a Star symbol style
let sweep = BarSpinner::new(42)
    .bar_style(BarStyle::Star)
    .motion(BarMotion::Loop)
    .spin(Spin::Clockwise)
    .arc_color(Color::Yellow);

// Minimal 1×1 status-bar spinner
let flux = FluxSpinner::new(42).color(Color::Cyan);

// 8-wide travelling wave
let wave = FluxSpinner::new(42)
    .frames(FluxFrames::ORBIT)
    .width(8)
    .phase_step(1)
    .color(Color::LightBlue);

§Integration

All widgets are stateless — pass a monotonically-increasing tick: u64 counter (incremented once per render frame). No mutable widget state needed.

use ratatui::Frame;
use ratatui::layout::Rect;
use tui_spinner::{BarSpinner, BarMotion, Spin};

struct App { tick: u64 }

fn draw(frame: &mut Frame, area: Rect, app: &App) {
    frame.render_widget(
        BarSpinner::new(app.tick)
            .motion(BarMotion::Loop)
            .spin(Spin::Clockwise),
        area,
    );
}

Structs§

BarSpinner
A Zed / Claude-style braille loading bar that bounces left and right.
CircleSpinner
A spinner whose arc rotates clockwise around a circular braille-dot ring.
FluxFrames
Built-in frame sequences for FluxSpinner.
FluxSpinner
A compact braille rotation spinner.
LinearSpinner
A linear spinner that animates either horizontally or vertically.
RectSpinner
A simple square braille-arc spinner with filled or empty center.
SquareSpinner
A rotating square braille-arc spinner.

Enums§

BarMotion
Controls how the arc behaves when it reaches the edge of the bar.
BarStyle
Selects the glyph set used for the arc and background track.
BarTrack
Controls the appearance of the dim background track behind the bouncing arc.
Centre
Whether the centre of the spinner is filled or empty.
Direction
The animation direction (and layout axis) of a LinearSpinner.
Flow
The animation flow direction of a LinearSpinner.
LinearStyle
The symbol pair used to draw active and inactive slot positions.
RectShape
Shape of the spinner.
Spin
Rotation direction of the arc.