React spinner component for Ink CLI applications with customizable spinner types from cli-spinners
npx @tessl/cli install tessl/npm-ink-spinner@5.0.0Ink Spinner is a React component that provides animated loading indicators for Ink CLI applications. It uses the extensive collection of spinners from cli-spinners, offering various animation styles like dots, lines, stars, and more to create polished command-line interfaces with visual feedback during long-running operations.
npm install ink-spinnerimport Spinner from "ink-spinner";
import type { SpinnerName } from "cli-spinners";For CommonJS:
const Spinner = require("ink-spinner");import React from 'react';
import { render, Text } from 'ink';
import Spinner from 'ink-spinner';
render(
<Text>
<Text color="green">
<Spinner type="dots" />
</Text>
{' Loading'}
</Text>
);A React functional component that renders animated spinner frames with configurable animation types.
/**
* Spinner component that displays animated loading indicators
* @param props - Component props containing spinner configuration
* @returns React component displaying the animated spinner
*/
function Spinner({ type = 'dots' }: Props): React.JSX.Element;
interface Props {
/**
* Type of spinner animation to display.
* See cli-spinners for available options (dots, line, star, etc.)
* @default 'dots'
*/
type?: SpinnerName;
}Usage Examples:
import React from 'react';
import { Text } from 'ink';
import Spinner from 'ink-spinner';
// Default dots spinner
<Spinner />
// Line spinner
<Spinner type="line" />
// Star spinner
<Spinner type="star" />
// Circle spinner
<Spinner type="circle" />
// Pipe spinner
<Spinner type="pipe" />/**
* Type representing all available spinner names from cli-spinners library
* Imported from cli-spinners package
* Includes options like: 'dots', 'line', 'star', 'circle', 'pipe', 'flip', etc.
*/
type SpinnerName = import('cli-spinners').SpinnerName;
interface Props {
/**
* Type of spinner animation to display
* @default 'dots'
*/
type?: SpinnerName;
}The Spinner component automatically:
The component supports all spinner types from the cli-spinners library, including but not limited to:
dots (default): Simple dot animationline: Horizontal line animationstar: Rotating star animationcircle: Circle segments animationpipe: Pipe character animationflip: Flipping animationhamburger: Hamburger icon animationgrowVertical: Growing vertical barsballoon: Balloon animationnoise: Random noise patternbounce: Bouncing animationboxBounce: Box bouncing animationFor the complete list of available spinners, refer to the cli-spinners repository.