@inquirer/ansi
A lightweight package providing ANSI escape sequences for terminal cursor manipulation and screen clearing.
Last updated 4 days ago by sboudrias .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @inquirer/ansi 
SYNC missed versions from official npm registry.

@inquirer/ansi

A lightweight package providing ANSI escape sequences for terminal cursor manipulation and screen clearing.

Installation

npm yarn
npm install @inquirer/ansi
yarn add @inquirer/ansi

Usage

import {
  cursorUp,
  cursorDown,
  cursorTo,
  cursorLeft,
  cursorHide,
  cursorShow,
  eraseLines,
} from '@inquirer/ansi';

// Move cursor up 3 lines
process.stdout.write(cursorUp(3));

// Move cursor to specific position (x: 10, y: 5)
process.stdout.write(cursorTo(10, 5));

// Hide/show cursor
process.stdout.write(cursorHide);
process.stdout.write(cursorShow);

// Clear 5 lines
process.stdout.write(eraseLines(5));

Or when used inside an inquirer prompt:

import { cursorHide } from '@inquirer/ansi';
import { createPrompt } from '@inquirer/core';

export default createPrompt((config, done: (value: void) => void) => {
  return `Choose an option${cursorHide}`;
});

API

Cursor Movement

  • cursorUp(count?: number) - Move cursor up by count lines (default: 1)
  • cursorDown(count?: number) - Move cursor down by count lines (default: 1)
  • cursorTo(x: number, y?: number) - Move cursor to position (x, y). If y is omitted, only moves horizontally
  • cursorLeft - Move cursor to beginning of line

Cursor Visibility

  • cursorHide - Hide the cursor
  • cursorShow - Show the cursor

Screen Manipulation

  • eraseLines(count: number) - Clear count lines and position cursor at the beginning of the first cleared line

License

Copyright (c) 2025 Simon Boudrias (twitter: @vaxilart)
Licensed under the MIT license.

Current Tags

  • 2.0.5                                ...           latest (4 days ago)

9 Versions

  • 2.0.5                                ...           4 days ago
  • 2.0.4                                ...           a month ago
  • 2.0.3                                ...           3 months ago
  • 2.0.2                                ...           4 months ago
  • 2.0.1                                ...           5 months ago
  • 2.0.0                                ...           5 months ago
  • 1.0.2                                ...           5 months ago
  • 1.0.1                                ...           6 months ago
  • 1.0.0                                ...           7 months ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |