Getting Started

Install and start using spinners in seconds

Installation

Install the package using your preferred package manager:

pnpm add @visulima/spinner
bash npm install @visulima/spinner
bash yarn add @visulima/spinner
bun add @visulima/spinner

@visulima/interactive-manager is included as a dependency and provides terminal output coordination.

Basic Usage

Simple Spinner

import { InteractiveManager, InteractiveStreamHook } from "@visulima/interactive-manager";
import { Spinner } from "@visulima/spinner";

const stdoutHook = new InteractiveStreamHook(process.stdout);
const stderrHook = new InteractiveStreamHook(process.stderr);
const manager = new InteractiveManager(stdoutHook, stderrHook);

const spinner = new Spinner({ name: "dots" }, manager);

spinner.start("Processing...");

await processData();

spinner.succeed("Completed!");

With Error Handling

const spinner = new Spinner({ name: "line" }, manager);

spinner.start("Connecting to database...");

try {
    await connectDB();
    spinner.succeed("Connected!");
} catch (error) {
    spinner.failed(`Failed: ${error.message}`);
}

With Styling

// Declarative style — uses Node.js util.styleText
const spinner = new Spinner(
    {
        name: "breathe",
        style: { bold: true, color: "cyan" },
    },
    manager,
);

// Function style — full control
const spinner = new Spinner(
    {
        name: "breathe",
        style: (text) => `\x1b[1m\x1b[36m${text}\x1b[0m`,
    },
    manager,
);

Custom Icons

const spinner = new Spinner(
    {
        name: "dots",
        icons: {
            success: "DONE",
            error: "FAIL",
            warning: "WARN",
            info: "NOTE",
        },
    },
    manager,
);

spinner.start("Loading...");
spinner.succeed(); // Shows "DONE" icon

Available Spinners

Get all available spinner names:

import { getSpinnerNames } from "@visulima/spinner";

const names = getSpinnerNames();
console.log(names); // ['aesthetic', 'arc', 'arrow', ...]

Check out the Spinner Reference to see all 109 spinners with previews and details.

Disabling Output

// Disable spinner output (useful in CI/testing)
const spinner = new Spinner({ name: "dots", verbose: false }, manager);

See Also

Support

Contribute to our work and keep us going

Community is the heart of open source. The success of our packages wouldn't be possible without the incredible contributions of users, testers, and developers who collaborate with us every day.Want to get involved? Here are some tips on how you can make a meaningful impact on our open source projects.

Ready to help us out?

Be sure to check out the package's contribution guidelines first. They'll walk you through the process on how to properly submit an issue or pull request to our repositories.

Submit a pull request

Found something to improve? Fork the repo, make your changes, and open a PR. We review every contribution and provide feedback to help you get merged.

Good first issues

Simple issues suited for people new to open source development, and often a good place to start working on a package.
View good first issues