๐ฅฌ spinach
December 5, 2025 ยท View on GitHub
Practical no dependency spinner for Rust โ
v3now with method chaining
Install
Add as a dependency to your Cargo.toml.
[dependencies]
spinach = "3"
Usage
Basic example.
use spinach::Spinner;
fn main() {
// Cut spinaches
let s = Spinner::new("Cutting spinaches...").start();
// Cut tomatoes
s.text("Cutting tomatoes...").update();
// We're done!
s.text("Vegetables cut").symbol("๐ช").stop();
}
Starting
use spinach::{Color, Spinner};
// With custom text
let s = Spinner::new("workin'...").start();
// With custom text, spinner, spinner speed and spinner color
let symbols = vec!["โฎ","โฏ"];
let s = Spinner::new("blip... blop...")
.color(Color::Red)
.symbols(symbols)
.frames_duration(80)
.start();
Updating
use spinach::{Color, Spinner};
let s = Spinner::new("workin'...").start();
// Updating text
s.text("new text").update();
// Updating color
s.color(Color::White).update();
// Updating spinner symbols
s.symbols(vec!["โ", "โ", "โ", "โ"]).update();
// Updating spinner speed
s.frames_duration(80).update();
// Updating multiple at once
s.text("new text").color(Color::Red).update();
Stopping
use spinach::{Color, Spinner};
let s = Spinner::new("workin'...").start();
// Stop with final `โ` frame and green color.
s.text("gg!").success();
// Stop with final `โ` frame and red color.
s.text("ups").failure();
// Stop with final `โ ` frame and yellow color.
s.text("something may have happened?").warn();
// Stop with without further modification (outside of chained updates).
s.text("notice").stop();
// Stop current spinner (sends update at the same time)
s.stop(); // freeze
s.text("spinach'd").symbol("๐ฅฌ").stop(); // stop with the text "spinach'd" and a vegetable as the spinner
FAQ
How to avoid leaving terminal without prompt on interupt (ctrl^c)?
You can use a library like ctrlc to handle interupts.
The most basic way to handle it would be in conjuction with this lib QoL show_cursor function like this:
use spinach::{show_cursor, Spinner};
fn main() {
ctrlc::set_handler(|| {
show_cursor();
std::process::exit(0);
})
.expect("Error setting Ctrl-C handler");
let s = Spinner::new("workin'...").start();
// ...
Related
Inspired by: