Expand description
§tui-spinner
Customizable animated spinner widgets for Ratatui TUI applications.
§Widgets
| Widget | Motion | Key options |
|---|---|---|
LinearSpinner | Scrolling window or bouncing dot along a straight axis | direction, flow, linear_style |
SquareSpinner | Braille-dot arc rotating around a square ring | size, spin, centre |
CircleSpinner | Braille-dot arc rotating around a circular ring | radius, spin, arc_len |
RectSpinner | Braille-dot arc rotating around a configurable rectangle | shape, spin, centre |
BarSpinner | Solid bar with a bouncing or looping glow arc | bar_style, motion, spin, track, fade_width |
FluxSpinner | Single-character glyph cycling through a frame sequence | frames, spin, phase_step |
SquareSpinner | Legacy 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.
- Circle
Spinner - A spinner whose arc rotates clockwise around a circular braille-dot ring.
- Flux
Frames - Built-in frame sequences for
FluxSpinner. - Flux
Spinner - A compact braille rotation spinner.
- Linear
Spinner - A linear spinner that animates either horizontally or vertically.
- Rect
Spinner - A simple square braille-arc spinner with filled or empty center.
- Square
Spinner - 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. - Linear
Style - The symbol pair used to draw active and inactive slot positions.
- Rect
Shape - Shape of the spinner.
- Spin
- Rotation direction of the arc.