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

@inquirer/confirm

Simple interactive command line prompt to gather boolean input from users.

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

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

Usage

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

const answer = await confirm({ message: 'Continue?' });

Options

Property Type Required Description
message string yes The question to ask
default boolean no Default answer (true or false)
transformer (boolean) => string no Transform the prompt printed message to a custom string
theme See Theming no Customize look of the prompt.

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[];
  };
  keywords: {
    yes: string;
    no: string;
    error: (keywords: { yes: string; no: string }) => string;
  };
  style: {
    answer: (text: string) => string;
    message: (text: string, status: 'idle' | 'done' | 'loading') => string;
    defaultAnswer: (text: string) => string;
    confirmDefault: (text: string) => string;
  };
};

The keywords property defines the words accepted as "yes" and "no". Matching is prefix-based and case-insensitive, and the first character of each word is shown in the hint (e.g. Y/n). The matched word is also displayed once the prompt is answered.

The built-in y/n/yes/no answers are always accepted, whatever the keywords are. Unrecognized input shows the keywords.error message instead of silently falling back on the default answer.

Overriding keywords is how @inquirer/i18n localizes the prompt:

confirm({
  message: '¿Continuar?',
  theme: {
    keywords: { yes: 'Sí', no: 'No' },
  },
});

The confirmDefault style marks the character representing the default answer in the hint. By default it uppercases the character (Y/n); for scripts without case (e.g. Chinese) it highlights the character with a color instead.

License

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

Current Tags

  • 6.4.0                                ...           latest (17 days ago)

130 Versions

  • 6.4.0                                ...           17 days ago
  • 6.3.5                                ...           a month ago
  • 6.3.4                                ...           a month ago
  • 6.3.3                                ...           2 months ago
  • 6.3.2                                ...           3 months ago
  • 6.3.1                                ...           3 months ago
  • 6.3.0                                ...           3 months ago
  • 6.2.0                                ...           3 months ago
  • 6.1.1                                ...           6 months ago
  • 6.1.0                                ...           6 months ago
  • 6.0.13                                ...           7 months ago
  • 6.0.12                                ...           7 months ago
  • 6.0.11                                ...           8 months ago
  • 6.0.10                                ...           8 months ago
  • 6.0.9                                ...           8 months ago
  • 6.0.8                                ...           9 months ago
  • 6.0.7                                ...           9 months ago
  • 6.0.6                                ...           9 months ago
  • 6.0.5                                ...           9 months ago
  • 6.0.4                                ...           a year ago
  • 6.0.3                                ...           a year ago
  • 6.0.2                                ...           a year ago
  • 6.0.1                                ...           a year ago
  • 6.0.0                                ...           a year ago
  • 5.1.21                                ...           a year ago
  • 5.1.20                                ...           a year ago
  • 5.1.19                                ...           a year ago
  • 5.1.18                                ...           a year ago
  • 5.1.17                                ...           a year ago
  • 5.1.16                                ...           a year ago
  • 5.1.15                                ...           a year ago
  • 5.1.14                                ...           a year ago
  • 5.1.13                                ...           a year ago
  • 5.1.12                                ...           2 years ago
  • 5.1.11                                ...           2 years ago
  • 5.1.10                                ...           2 years ago
  • 5.1.9                                ...           2 years ago
  • 5.1.8                                ...           2 years ago
  • 5.1.7                                ...           2 years ago
  • 5.1.6                                ...           2 years ago
  • 5.1.5                                ...           2 years ago
  • 5.1.4                                ...           2 years ago
  • 5.1.3                                ...           2 years ago
  • 5.1.2                                ...           2 years ago
  • 5.1.1                                ...           2 years ago
  • 5.1.0                                ...           2 years ago
  • 5.0.2                                ...           2 years ago
  • 5.0.1                                ...           2 years ago
  • 5.0.0                                ...           2 years ago
  • 4.0.1                                ...           2 years ago
  • 4.0.0                                ...           2 years ago
  • 3.2.0                                ...           2 years ago
  • 3.1.22                                ...           2 years ago
  • 3.1.21                                ...           2 years ago
  • 3.1.20                                ...           2 years ago
  • 3.1.19                                ...           2 years ago
  • 3.1.18                                ...           2 years ago
  • 3.1.17                                ...           2 years ago
  • 3.1.16                                ...           2 years ago
  • 3.1.15                                ...           2 years ago
  • 3.1.14                                ...           2 years ago
  • 3.1.13                                ...           2 years ago
  • 3.1.12                                ...           2 years ago
  • 3.1.11                                ...           2 years ago
  • 3.1.10                                ...           2 years ago
  • 3.1.9                                ...           2 years ago
  • 3.1.8                                ...           3 years ago
  • 3.1.7                                ...           3 years ago
  • 3.1.6                                ...           3 years ago
  • 3.1.5                                ...           3 years ago
  • 3.1.4                                ...           3 years ago
  • 3.1.3                                ...           3 years ago
  • 3.1.2                                ...           3 years ago
  • 3.1.1                                ...           3 years ago
  • 3.1.0                                ...           3 years ago
  • 3.0.2                                ...           3 years ago
  • 3.0.1                                ...           3 years ago
  • 3.0.0                                ...           3 years ago
  • 2.0.17                                ...           3 years ago
  • 2.0.16                                ...           3 years ago
  • 2.0.15                                ...           3 years ago
  • 2.0.14                                ...           3 years ago
  • 2.0.13                                ...           3 years ago
  • 2.0.12                                ...           3 years ago
  • 2.0.11                                ...           3 years ago
  • 2.0.10                                ...           3 years ago
  • 2.0.9                                ...           3 years ago
  • 2.0.8                                ...           3 years ago
  • 2.0.7                                ...           3 years ago
  • 2.0.6                                ...           3 years ago
  • 2.0.5                                ...           3 years ago
  • 2.0.4                                ...           3 years ago
  • 2.0.3                                ...           3 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.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.25-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                                ...           4 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                                ...           5 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                                ...           6 years ago
  • 0.0.8-alpha.0                                ...           7 years ago
  • 0.0.6-alpha.0                                ...           7 years ago
  • 0.0.5-alpha.0                                ...           7 years ago
  • 0.0.4-alpha.0                                ...           7 years ago
Maintainers (2)
Downloads
Total 207
Today 0
This Week 0
This Month 197
Last Day 0
Last Week 134
Last Month 1
Dependencies (2)
Dev Dependencies (2)
Dependents (2)

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