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

@inquirer/expand

Compact single select prompt. Every option is assigned a shortcut key, and selecting h will expand all the choices and their descriptions.

Expand prompt closed Expand prompt expanded

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/expand
pnpm add @inquirer/expand
bun deno
bun add @inquirer/expand
deno add npm:@inquirer/expand
npm
npm install @inquirer/expand

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

Usage

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

const answer = await expand({
  message: 'Conflict on file.js',
  default: 'y',
  choices: [
    {
      key: 'y',
      name: 'Overwrite',
      value: 'overwrite',
    },
    {
      key: 'a',
      name: 'Overwrite this one and all next',
      value: 'overwrite_all',
    },
    {
      key: 'd',
      name: 'Show diff',
      value: 'diff',
    },
    {
      key: 'x',
      name: 'Abort',
      value: 'abort',
    },
  ],
});

Options

Property Type Required Description
message string yes The question to ask
choices Choice[] yes Array of the different allowed choices. The h/help option is always provided by default
default string no Default choices to be selected. (value must be one of the choices key)
expanded boolean no Expand the choices by default
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;
  key: string;
};

Here's each property:

  • value: The value is what will be returned by await expand().
  • name: The string displayed in the choice list. It'll default to the stringify value.
  • key: The input the use must provide to select the choice. Must be a lowercase single alphanumeric character string.

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;
    defaultAnswer: (text: string) => string;
    highlight: (text: string) => string;
  };
};

License

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

Current Tags

  • 5.2.0                                ...           latest (17 days ago)

130 Versions

  • 5.2.0                                ...           17 days ago
  • 5.1.8                                ...           a month ago
  • 5.1.7                                ...           a month ago
  • 5.1.6                                ...           2 months ago
  • 5.1.5                                ...           3 months ago
  • 5.1.4                                ...           3 months ago
  • 5.1.3                                ...           3 months ago
  • 5.1.2                                ...           3 months ago
  • 5.1.1                                ...           6 months ago
  • 5.1.0                                ...           6 months ago
  • 5.0.14                                ...           7 months ago
  • 5.0.13                                ...           7 months ago
  • 5.0.12                                ...           8 months ago
  • 5.0.11                                ...           8 months ago
  • 5.0.10                                ...           8 months ago
  • 5.0.9                                ...           8 months ago
  • 5.0.8                                ...           9 months ago
  • 5.0.7                                ...           9 months ago
  • 5.0.6                                ...           9 months ago
  • 5.0.5                                ...           9 months ago
  • 5.0.4                                ...           a year ago
  • 5.0.3                                ...           a year ago
  • 5.0.2                                ...           a year ago
  • 5.0.1                                ...           a year ago
  • 5.0.0                                ...           a year ago
  • 4.0.23                                ...           a year ago
  • 4.0.22                                ...           a year ago
  • 4.0.21                                ...           a year ago
  • 4.0.20                                ...           a year ago
  • 4.0.19                                ...           a year ago
  • 4.0.18                                ...           a year ago
  • 4.0.17                                ...           a year ago
  • 4.0.16                                ...           a year ago
  • 4.0.15                                ...           2 years ago
  • 4.0.14                                ...           2 years ago
  • 4.0.13                                ...           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.0                                ...           2 years ago
  • 2.1.22                                ...           2 years ago
  • 2.1.21                                ...           2 years ago
  • 2.1.20                                ...           2 years ago
  • 2.1.19                                ...           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.1.16                                ...           3 years ago
  • 1.1.15                                ...           3 years ago
  • 1.1.14                                ...           3 years ago
  • 1.1.13                                ...           3 years ago
  • 1.1.12                                ...           3 years ago
  • 1.1.11                                ...           3 years ago
  • 1.1.10                                ...           3 years ago
  • 1.1.9                                ...           3 years ago
  • 1.1.8                                ...           3 years ago
  • 1.1.7                                ...           3 years ago
  • 1.1.6                                ...           3 years ago
  • 1.1.5                                ...           3 years ago
  • 1.1.4                                ...           3 years ago
  • 1.1.3                                ...           3 years ago
  • 1.1.2                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.11                                ...           4 years ago
  • 1.0.10                                ...           4 years ago
  • 1.0.9                                ...           4 years ago
  • 1.0.8                                ...           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.28-alpha.0                                ...           4 years ago
  • 0.0.27-alpha.0                                ...           4 years ago
  • 0.0.26-alpha.0                                ...           4 years ago
  • 0.0.24-alpha.0                                ...           4 years ago
  • 0.0.23-alpha.0                                ...           4 years ago
  • 0.0.22-alpha.0                                ...           4 years ago
  • 0.0.21-alpha.0                                ...           4 years ago
  • 0.0.20-alpha.0                                ...           5 years ago
  • 0.0.19-alpha.0                                ...           5 years ago
  • 0.0.18-alpha.0                                ...           5 years ago
  • 0.0.17-alpha.0                                ...           5 years ago
  • 0.0.16-alpha.0                                ...           5 years ago
  • 0.0.15-alpha.0                                ...           6 years ago
  • 0.0.14-alpha.0                                ...           6 years ago
  • 0.0.13-alpha.0                                ...           6 years ago
  • 0.0.12-alpha.0                                ...           6 years ago
  • 0.0.11-alpha.0                                ...           6 years ago
  • 0.0.10-alpha.0                                ...           6 years ago
  • 0.0.9-alpha.0                                ...           7 years ago
  • 0.0.7-alpha.0                                ...           7 years ago
  • 0.0.6-alpha.0                                ...           7 years ago
  • 0.0.5-alpha.0                                ...           7 years ago
Maintainers (2)
Downloads
Total 322
Today 1
This Week 122
This Month 308
Last Day 21
Last Week 135
Last Month 7
Dependencies (2)
Dev Dependencies (2)

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