Spinners for use in the terminal
npx @tessl/cli install tessl/npm-cli-spinners@3.2.0CLI Spinners provides a comprehensive collection of 88 terminal spinner animations for command-line interfaces and console applications. The package serves as a data library containing spinner definitions with timing intervals and frame sequences using Unicode characters, ASCII art, and various visual patterns.
npm install cli-spinnersimport cliSpinners from "cli-spinners";
import { randomSpinner } from "cli-spinners";For TypeScript:
import cliSpinners, { randomSpinner, SpinnerName, Spinner } from "cli-spinners";import cliSpinners, { randomSpinner } from "cli-spinners";
// Access a specific spinner
console.log(cliSpinners.dots);
// {
// interval: 80,
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
// }
// Get a random spinner
const spinner = randomSpinner();
console.log(spinner);
// {
// interval: 80,
// frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
// }
// Use with a terminal spinner library (like ora)
import ora from 'ora';
const loading = ora({
text: 'Loading...',
spinner: cliSpinners.dots
}).start();The default export provides access to all 88 available spinner animations. Each spinner contains recommended timing and frame data optimized for terminal display.
/**
* Collection of 88 spinner definitions for terminal animations.
* Each spinner provides interval timing and frame sequences.
*/
declare const cliSpinners: {
readonly [spinnerName in SpinnerName]: Spinner;
};
export default cliSpinners;Available Spinner Names (88 total):
dots, dots2, dots3, dots4, dots5, dots6, dots7, dots8, dots9, dots10, dots11, dots12, dots13, dots14, dots8Bit, dotsCircle, sand, line, line2, pipe, simpleDots, simpleDotsScrolling, star, star2, flip, hamburger, growVertical, growHorizontal, balloon, balloon2, noise, bounce, boxBounce, boxBounce2, triangle, binary, arc, circle, squareCorners, circleQuarters, circleHalves, squish, toggle, toggle2, toggle3, toggle4, toggle5, toggle6, toggle7, toggle8, toggle9, toggle10, toggle11, toggle12, toggle13, arrow, arrow2, arrow3, bouncingBar, bouncingBall, smiley, monkey, hearts, clock, earth, material, moon, runner, pong, shark, dqpb, weather, christmas, grenade, point, layer, betaWave, fingerDance, fistBump, soccerHeader, mindblown, speaker, orangePulse, bluePulse, orangeBluePulse, timeTravel, aesthetic, dwarfFortress
Get a randomly selected spinner from the collection for dynamic spinner variation.
/**
* Get a random spinner from the collection.
*
* @returns A randomly selected spinner object with interval and frames
*/
export function randomSpinner(): Spinner;Usage Example:
import { randomSpinner } from "cli-spinners";
// Get a different spinner each time
const spinner1 = randomSpinner();
const spinner2 = randomSpinner();
const spinner3 = randomSpinner();
// Use with setInterval to create animated display
let currentFrame = 0;
const randomSpinner = randomSpinner();
const interval = setInterval(() => {
process.stdout.write(`\r${randomSpinner.frames[currentFrame]} Loading...`);
currentFrame = (currentFrame + 1) % randomSpinner.frames.length;
}, randomSpinner.interval);/**
* Union type of all available spinner names.
* Includes all 88 spinner identifiers for type safety.
*/
export type SpinnerName =
| 'dots' | 'dots2' | 'dots3' | 'dots4' | 'dots5' | 'dots6' | 'dots7' | 'dots8'
| 'dots9' | 'dots10' | 'dots11' | 'dots12' | 'dots13' | 'dots14' | 'dots8Bit'
| 'dotsCircle' | 'sand' | 'line' | 'line2' | 'pipe' | 'simpleDots' | 'simpleDotsScrolling'
| 'star' | 'star2' | 'flip' | 'hamburger' | 'growVertical' | 'growHorizontal'
| 'balloon' | 'balloon2' | 'noise' | 'bounce' | 'boxBounce' | 'boxBounce2'
| 'binary' | 'triangle' | 'arc' | 'circle' | 'squareCorners' | 'circleQuarters'
| 'circleHalves' | 'squish' | 'toggle' | 'toggle2' | 'toggle3' | 'toggle4'
| 'toggle5' | 'toggle6' | 'toggle7' | 'toggle8' | 'toggle9' | 'toggle10'
| 'toggle11' | 'toggle12' | 'toggle13' | 'arrow' | 'arrow2' | 'arrow3'
| 'bouncingBar' | 'bouncingBall' | 'smiley' | 'monkey' | 'hearts' | 'clock'
| 'earth' | 'material' | 'moon' | 'runner' | 'pong' | 'shark' | 'dqpb'
| 'weather' | 'christmas' | 'grenade' | 'point' | 'layer' | 'betaWave'
| 'fingerDance' | 'fistBump' | 'soccerHeader' | 'mindblown' | 'speaker'
| 'orangePulse' | 'bluePulse' | 'orangeBluePulse' | 'timeTravel' | 'aesthetic'
| 'dwarfFortress';
/**
* Structure defining a terminal spinner animation.
* Contains recommended timing and frame sequence data.
*/
export type Spinner = {
/**
* The recommended interval.
*/
readonly interval: number;
/**
* A list of frames to show for the spinner.
*/
readonly frames: string[];
}CLI Spinners follows a simple, data-driven architecture:
spinners.json contains all spinner definitions as structured JSONwith {type: 'json'})import ora from 'ora';
import cliSpinners from 'cli-spinners';
// Use specific spinner
const spinner = ora({
text: 'Processing data...',
spinner: cliSpinners.material
}).start();
// Use random spinner
const randomSpinner = ora({
text: 'Loading...',
spinner: randomSpinner()
}).start();import cliSpinners, { randomSpinner } from 'cli-spinners';
function animateSpinner(text = 'Loading...', duration = 5000) {
const spinner = randomSpinner();
let currentFrame = 0;
const interval = setInterval(() => {
process.stdout.write(`\r${spinner.frames[currentFrame]} ${text}`);
currentFrame = (currentFrame + 1) % spinner.frames.length;
}, spinner.interval);
setTimeout(() => {
clearInterval(interval);
process.stdout.write('\r✅ Complete!\n');
}, duration);
}
animateSpinner('Processing files...', 3000);All frames within a spinner maintain consistent visual width, making them suitable for fixed-position terminal displays:
import cliSpinners from 'cli-spinners';
// All frames in 'dots' have the same visual width
const { frames } = cliSpinners.dots;
console.log(frames); // ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']
// Safe to use in fixed-width terminal layouts
frames.forEach(frame => {
console.log(`[${frame}] Status: Processing...`);
});