@inquirer/rawlist
Inquirer rawlist prompt
Last updated 17 days ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @inquirer/rawlist 
SYNC missed versions from official npm registry.

@inquirer/rawlist

Simple interactive command line prompt to display a raw list of choices (single value select) with minimal interaction.

rawlist prompt

Installation

yarn pnpm
yarn add @inquirer/prompts
pnpm add @inquirer/prompts
bun deno
bun add @inquirer/prompts
deno add npm:@inquirer/prompts
npm
npm install @inquirer/prompts
Or
yarn pnpm
yarn add @inquirer/rawlist
pnpm add @inquirer/rawlist
bun deno
bun add @inquirer/rawlist
deno add npm:@inquirer/rawlist
npm
npm install @inquirer/rawlist

On Deno, prompts detect the terminal's unicode and color support from the environment, so run your script with --allow-env.

Usage

import { rawlist } from '@inquirer/prompts';
// Or
// import rawlist from '@inquirer/rawlist';

const answer = await rawlist({
  message: 'Select a package manager',
  choices: [
    { name: 'npm', value: 'npm' },
    { name: 'yarn', value: 'yarn' },
    { name: 'pnpm', value: 'pnpm' },
  ],
});

Options

Property Type Required Description
message string yes The question to ask
choices Choice[] yes List of the available choices.
loop boolean no Defaults to true. When set to false, the cursor will be constrained to the top and bottom of the choice list without looping.
default Value no The value of the choice to preselect. If the value is not found, no choice is preselected.
theme See Theming no Customize look of the prompt.

Separator objects can be used in the choices array to render non-selectable lines in the choice list. By default it'll render a line, but you can provide the text as argument (new Separator('-- Dependencies --')). This option is often used to add labels to groups within long list of options.

Choice object

The Choice object is typed as

type Choice<Value> = {
  value: Value;
  name?: string;
  short?: string;
  key?: string;
  description?: string;
};

Here's each property:

  • value: The value is what will be returned by await rawlist().
  • name: This is the string displayed in the choice list.
  • short: Once the prompt is done (press enter), we'll use short if defined to render next to the question. By default we'll use name.
  • key: The key of the choice. Displayed as key) name.
  • description: Option description which appears below the list when the choice is selected.

choices can also be an array of string, in which case the string will be used both as the value and the name.

Keybindings

Set INQUIRER_KEYBINDINGS=vim, INQUIRER_KEYBINDINGS=emacs, or INQUIRER_KEYBINDINGS=vim,emacs to enable alternative navigation keybindings globally.

You can override the environment setting per prompt with theme.keybindings.

Theming

You can theme a prompt by passing a theme object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.

type Theme = {
  prefix: string | { idle: string; done: string };
  spinner: {
    interval: number;
    frames: string[];
  };
  style: {
    answer: (text: string) => string;
    message: (text: string, status: 'idle' | 'done' | 'loading') => string;
    error: (text: string) => string;
    highlight: (text: string) => string;
    description: (text: string) => string;
  };
  keybindings: readonly ('emacs' | 'vim')[];
};

License

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

Current Tags

  • 5.4.0                                ...           latest (17 days ago)

117 Versions

  • 5.4.0                                ...           17 days ago
  • 5.3.8                                ...           a month ago
  • 5.3.7                                ...           a month ago
  • 5.3.6                                ...           2 months ago
  • 5.3.5                                ...           3 months ago
  • 5.3.4                                ...           3 months ago
  • 5.3.3                                ...           3 months ago
  • 5.3.2                                ...           3 months ago
  • 5.3.1                                ...           6 months ago
  • 5.3.0                                ...           6 months ago
  • 5.2.9                                ...           7 months ago
  • 5.2.8                                ...           7 months ago
  • 5.2.7                                ...           8 months ago
  • 5.2.6                                ...           8 months ago
  • 5.2.5                                ...           8 months ago
  • 5.2.4                                ...           9 months ago
  • 5.2.3                                ...           9 months ago
  • 5.2.2                                ...           9 months ago
  • 5.2.1                                ...           9 months ago
  • 5.2.0                                ...           a year ago
  • 5.1.0                                ...           a year ago
  • 5.0.2                                ...           a year ago
  • 5.0.1                                ...           a year ago
  • 5.0.0                                ...           a year ago
  • 4.1.11                                ...           a year ago
  • 4.1.10                                ...           a year ago
  • 4.1.9                                ...           a year ago
  • 4.1.8                                ...           a year ago
  • 4.1.7                                ...           a year ago
  • 4.1.6                                ...           a year ago
  • 4.1.5                                ...           a year ago
  • 4.1.4                                ...           a year ago
  • 4.1.3                                ...           2 years ago
  • 4.1.2                                ...           2 years ago
  • 4.1.1                                ...           2 years ago
  • 4.1.0                                ...           2 years ago
  • 4.0.12                                ...           2 years ago
  • 4.0.11                                ...           2 years ago
  • 4.0.10                                ...           2 years ago
  • 4.0.9                                ...           2 years ago
  • 4.0.8                                ...           2 years ago
  • 4.0.7                                ...           2 years ago
  • 4.0.6                                ...           2 years ago
  • 4.0.5                                ...           2 years ago
  • 4.0.4                                ...           2 years ago
  • 4.0.3                                ...           2 years ago
  • 4.0.2                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.3.0                                ...           2 years ago
  • 2.2.4                                ...           2 years ago
  • 2.2.3                                ...           2 years ago
  • 2.2.2                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.18                                ...           2 years ago
  • 2.1.17                                ...           2 years ago
  • 2.1.16                                ...           2 years ago
  • 2.1.15                                ...           2 years ago
  • 2.1.14                                ...           2 years ago
  • 2.1.13                                ...           2 years ago
  • 2.1.12                                ...           2 years ago
  • 2.1.11                                ...           2 years ago
  • 2.1.10                                ...           2 years ago
  • 2.1.9                                ...           2 years ago
  • 2.1.8                                ...           3 years ago
  • 2.1.7                                ...           3 years ago
  • 2.1.6                                ...           3 years ago
  • 2.1.5                                ...           3 years ago
  • 2.1.4                                ...           3 years ago
  • 2.1.3                                ...           3 years ago
  • 2.1.2                                ...           3 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 1.2.16                                ...           3 years ago
  • 1.2.15                                ...           3 years ago
  • 1.2.14                                ...           3 years ago
  • 1.2.13                                ...           3 years ago
  • 1.2.12                                ...           3 years ago
  • 1.2.11                                ...           3 years ago
  • 1.2.10                                ...           3 years ago
  • 1.2.9                                ...           3 years ago
  • 1.2.8                                ...           3 years ago
  • 1.2.7                                ...           3 years ago
  • 1.2.6                                ...           3 years ago
  • 1.2.5                                ...           3 years ago
  • 1.2.4                                ...           3 years ago
  • 1.2.3                                ...           3 years ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.3                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           4 years ago
  • 1.0.4                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.11-alpha.0                                ...           4 years ago
  • 0.0.10-alpha.0                                ...           4 years ago
  • 0.0.9-alpha.0                                ...           4 years ago
  • 0.0.7-alpha.0                                ...           4 years ago
  • 0.0.6-alpha.0                                ...           4 years ago
  • 0.0.5-alpha.0                                ...           4 years ago
  • 0.0.4-alpha.0                                ...           4 years ago
  • 0.0.3-alpha.0                                ...           5 years ago
  • 0.0.2-alpha.0                                ...           5 years ago
Maintainers (2)
Downloads
Total 259
Today 0
This Week 1
This Month 251
Last Day 0
Last Week 118
Last Month 4
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE