ora vs cli-spinners vs progress vs cli-progress
Node.js CLI Progress Indicators Comparison
1 Year
oracli-spinnersprogresscli-progressSimilar Packages:
What's Node.js CLI Progress Indicators?

These packages provide various ways to display progress indicators in command-line interfaces (CLI) for Node.js applications. They enhance user experience by visually representing ongoing processes, making it easier for users to understand the status of long-running tasks. Each package offers unique features and styles for progress indicators, allowing developers to choose one that best fits their application's needs.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
ora33,358,0119,30127.5 kB212 months agoMIT
cli-spinners27,936,7192,49132.8 kB37 months agoMIT
progress21,596,6492,985-716 years agoMIT
cli-progress4,137,5631,17462.2 kB232 years agoMIT
Feature Comparison: ora vs cli-spinners vs progress vs cli-progress

Customization

  • ora:

    ora allows for some customization of spinner styles and text, but it is primarily designed for simplicity and ease of use. You can change the spinner type and add messages, but it does not offer as much flexibility as cli-progress.

  • cli-spinners:

    cli-spinners provides a selection of predefined spinner styles but offers limited customization compared to cli-progress. It focuses on simplicity and ease of use, allowing you to quickly add spinners without much configuration.

  • progress:

    progress is straightforward with minimal customization options. It allows you to set the total value and current progress but does not support advanced styling or multiple progress indicators.

  • cli-progress:

    cli-progress offers extensive customization options, allowing you to define the format, colors, and behavior of the progress bar. You can create multiple progress bars and control their appearance and updates individually, making it suitable for complex applications.

Ease of Use

  • ora:

    ora is designed for simplicity and ease of use, allowing developers to quickly add loading indicators with minimal code. It is user-friendly and suitable for all experience levels.

  • cli-spinners:

    cli-spinners is very easy to use and requires minimal setup. You can quickly implement it in your application with just a few lines of code, making it ideal for beginners.

  • progress:

    progress is also very easy to use, with a simple API that allows you to create a basic progress bar with just a few lines of code. It is perfect for quick implementations.

  • cli-progress:

    cli-progress has a steeper learning curve due to its extensive features and customization options. However, once understood, it provides powerful tools for creating complex progress indicators.

Visual Appeal

  • ora:

    ora features a clean and minimalist design for loading indicators, making it visually appealing without being overwhelming. It focuses on providing a pleasant user experience with simple animations.

  • cli-spinners:

    cli-spinners provides a variety of animated spinner styles that can enhance the visual appeal of your CLI application. The animations are smooth and can add a professional touch to your interface.

  • progress:

    progress offers a basic progress bar that is functional but less visually appealing compared to cli-progress. It is straightforward but may not stand out in terms of design.

  • cli-progress:

    cli-progress offers a visually appealing and highly customizable progress bar that can be styled to fit the aesthetics of your application. It supports colors and formatting, making it suitable for polished applications.

Performance

  • ora:

    ora is also lightweight and performs well, providing a responsive loading indicator that does not impact the application's performance. It is suitable for applications that require minimal resource usage.

  • cli-spinners:

    cli-spinners is lightweight and performs well, providing quick and responsive animations without significant overhead. It is ideal for applications where performance is a concern.

  • progress:

    progress is efficient for basic use cases, but it may not perform as well as cli-progress when handling multiple progress indicators or complex updates.

  • cli-progress:

    cli-progress is optimized for performance, allowing for smooth updates even with multiple progress bars. It efficiently handles rendering and updates, making it suitable for high-performance applications.

Use Cases

  • ora:

    ora is perfect for command-line applications that require a simple loading indicator while waiting for asynchronous operations, such as API calls or database queries.

  • cli-spinners:

    cli-spinners is ideal for applications that need simple loading indicators, such as CLI tools that perform quick tasks or asynchronous operations.

  • progress:

    progress is suitable for basic applications where you need to provide feedback on the progress of a task, such as batch processing or simple file operations.

  • cli-progress:

    cli-progress is best suited for applications that require detailed progress tracking, such as file uploads, downloads, or long-running tasks where multiple indicators are needed.

How to Choose: ora vs cli-spinners vs progress vs cli-progress
  • ora:

    Opt for ora if you require a straightforward and elegant way to show loading indicators with a focus on simplicity and minimalism. It is particularly useful for displaying status messages alongside spinners, making it great for tasks that involve waiting for asynchronous operations.

  • cli-spinners:

    Select cli-spinners if you want a simple way to add animated spinners to your CLI applications. It offers a variety of spinner styles and is easy to implement, making it ideal for lightweight applications needing basic loading indicators.

  • progress:

    Use progress if you need a simple and straightforward progress bar that is easy to implement and requires minimal configuration. It is suitable for basic use cases where you want to provide feedback on the progress of a task without extensive customization.

  • cli-progress:

    Choose cli-progress if you need a highly customizable and flexible progress bar that supports multiple bars, can be styled, and provides detailed control over the output format and behavior.

README for ora

ora

Elegant terminal spinner



Install

npm install ora

Check out yocto-spinner for a smaller alternative.

Usage

import ora from 'ora';

const spinner = ora('Loading unicorns').start();

setTimeout(() => {
	spinner.color = 'yellow';
	spinner.text = 'Loading rainbows';
}, 1000);

API

ora(text)

ora(options)

If a string is provided, it is treated as a shortcut for options.text.

options

Type: object

text

Type: string

The text to display next to the spinner.

prefixText

Type: string | () => string

Text or a function that returns text to display before the spinner. No prefix text will be displayed if set to an empty string.

suffixText

Type: string | () => string

Text or a function that returns text to display after the spinner text. No suffix text will be displayed if set to an empty string.

spinner

Type: string | object
Default: 'dots'

The name of one of the provided spinners. See example.js in this repo if you want to test out different spinners. On Windows (except for Windows Terminal), it will always use the line spinner as the Windows command-line doesn't have proper Unicode support.

Or an object like:

{
	frames: ['-', '+', '-'],
	interval: 80 // Optional
}
color

Type: string | boolean
Default: 'cyan'
Values: 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | boolean

The color of the spinner.

hideCursor

Type: boolean
Default: true

Set to false to stop Ora from hiding the cursor.

indent

Type: number
Default: 0

Indent the spinner with the given number of spaces.

interval

Type: number
Default: Provided by the spinner or 100

Interval between each frame.

Spinners provide their own recommended interval, so you don't really need to specify this.

stream

Type: stream.Writable
Default: process.stderr

Stream to write the output.

You could for example set this to process.stdout instead.

isEnabled

Type: boolean

Force enable/disable the spinner. If not specified, the spinner will be enabled if the stream is being run inside a TTY context (not spawned or piped) and/or not in a CI environment.

Note that {isEnabled: false} doesn't mean it won't output anything. It just means it won't output the spinner, colors, and other ansi escape codes. It will still log text.

isSilent

Type: boolean
Default: false

Disable the spinner and all log text. All output is suppressed and isEnabled will be considered false.

discardStdin

Type: boolean
Default: true

Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on Enter key presses, and prevents buffering of input while the spinner is running.

This has no effect on Windows as there is no good way to implement discarding stdin properly there.

Instance

.text get/set

Change the text displayed after the spinner.

.prefixText get/set

Change the text before the spinner.

No prefix text will be displayed if set to an empty string.

.suffixText get/set

Change the text after the spinner text.

No suffix text will be displayed if set to an empty string.

.color get/set

Change the spinner color.

.spinner get/set

Change the spinner.

.indent get/set

Change the spinner indent.

.isSpinning get

A boolean indicating whether the instance is currently spinning.

.interval get

The interval between each frame.

The interval is decided by the chosen spinner.

.start(text?)

Start the spinner. Returns the instance. Set the current text if text is provided.

.stop()

Stop and clear the spinner. Returns the instance.

.succeed(text?)

Stop the spinner, change it to a green and persist the current text, or text if provided. Returns the instance. See the GIF below.

.fail(text?)

Stop the spinner, change it to a red and persist the current text, or text if provided. Returns the instance. See the GIF below.

.warn(text?)

Stop the spinner, change it to a yellow and persist the current text, or text if provided. Returns the instance.

.info(text?)

Stop the spinner, change it to a blue and persist the current text, or text if provided. Returns the instance.

.stopAndPersist(options?)

Stop the spinner and change the symbol or text. Returns the instance. See the GIF below.

options

Type: object

symbol

Type: string
Default: ' '

Symbol to replace the spinner with.

text

Type: string
Default: Current 'text'

Text to be persisted after the symbol.

prefixText

Type: string | () => string
Default: Current prefixText

Text or a function that returns text to be persisted before the symbol. No prefix text will be displayed if set to an empty string.

suffixText

Type: string | () => string
Default: Current suffixText

Text or a function that returns text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.

.clear()

Clear the spinner. Returns the instance.

.render()

Manually render a new frame. Returns the instance.

.frame()

Get a new frame.

oraPromise(action, text)

oraPromise(action, options)

Starts a spinner for a promise or promise-returning function. The spinner is stopped with .succeed() if the promise fulfills or with .fail() if it rejects. Returns the promise.

import {oraPromise} from 'ora';

await oraPromise(somePromise);

action

Type: Promise | ((spinner: ora.Ora) => Promise)

options

Type: object

All of the options plus the following:

successText

Type: string | ((result: T) => string) | undefined

The new text of the spinner when the promise is resolved.

Keeps the existing text if undefined.

failText

Type: string | ((error: Error) => string) | undefined

The new text of the spinner when the promise is rejected.

Keeps the existing text if undefined.

spinners

Type: Record<string, Spinner>

All provided spinners.

FAQ

How do I change the color of the text?

Use chalk or yoctocolors:

import ora from 'ora';
import chalk from 'chalk';

const spinner = ora(`Loading ${chalk.red('unicorns')}`).start();

Why does the spinner freeze?

JavaScript is single-threaded, so any synchronous operations will block the spinner's animation. To avoid this, prefer using asynchronous operations.

Related

Ports