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

@inquirer/number

Interactive free number input component for command line interfaces. Supports validation, filtering, transformation, etc.

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

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

Usage

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

const answer = await number({ message: 'Enter your age' });

Options

Property Type Required Description
message string yes The question to ask
default number no Default value if no answer is provided (clear it by pressing backspace)
min number no The minimum value to accept for this input.
max number no The maximum value to accept for this input.
step number \| 'any' no The step option is a number that specifies the granularity that the value must adhere to. Only values which are equal to the basis for stepping (min if specified) are valid. This value defaults to 1, meaning by default the prompt will only allow integers.
required boolean no Defaults to false. If set to true, undefined (empty) will not be accepted for this.
validate (number \| undefined) => boolean \| string \| Promise<boolean \| string> no On submit, validate the filtered answered content. When returning a string, it'll be used as the error message displayed to the user. Note: returning a rejected promise, we'll assume a code error happened and crash.
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[];
  };
  style: {
    answer: (text: string) => string;
    message: (text: string, status: 'idle' | 'done' | 'loading') => string;
    error: (text: string) => string;
    defaultAnswer: (text: string) => string;
  };
};

License

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

Current Tags

  • 4.3.0                                ...           latest (17 days ago)

62 Versions

  • 4.3.0                                ...           17 days ago
  • 4.2.6                                ...           a month ago
  • 4.2.5                                ...           a month ago
  • 4.2.4                                ...           2 months ago
  • 4.2.3                                ...           3 months ago
  • 4.2.2                                ...           3 months ago
  • 4.2.1                                ...           3 months ago
  • 4.2.0                                ...           3 months ago
  • 4.1.1                                ...           6 months ago
  • 4.1.0                                ...           6 months ago
  • 4.0.13                                ...           7 months ago
  • 4.0.12                                ...           7 months ago
  • 4.0.11                                ...           8 months ago
  • 4.0.10                                ...           8 months ago
  • 4.0.9                                ...           8 months ago
  • 4.0.8                                ...           9 months ago
  • 4.0.7                                ...           9 months ago
  • 4.0.6                                ...           9 months ago
  • 4.0.5                                ...           9 months ago
  • 4.0.4                                ...           a year ago
  • 4.0.3                                ...           a year ago
  • 4.0.2                                ...           a year ago
  • 4.0.1                                ...           a year ago
  • 4.0.0                                ...           a year ago
  • 3.0.23                                ...           a year ago
  • 3.0.22                                ...           a year ago
  • 3.0.21                                ...           a year ago
  • 3.0.20                                ...           a year ago
  • 3.0.19                                ...           a year ago
  • 3.0.18                                ...           a year ago
  • 3.0.17                                ...           a year ago
  • 3.0.16                                ...           a year ago
  • 3.0.15                                ...           2 years ago
  • 3.0.14                                ...           2 years ago
  • 3.0.13                                ...           2 years ago
  • 3.0.12                                ...           2 years ago
  • 3.0.11                                ...           2 years ago
  • 3.0.10                                ...           2 years ago
  • 3.0.9                                ...           2 years ago
  • 3.0.8                                ...           2 years ago
  • 3.0.7                                ...           2 years ago
  • 3.0.6                                ...           2 years ago
  • 3.0.5                                ...           2 years ago
  • 3.0.4                                ...           2 years ago
  • 3.0.3                                ...           2 years ago
  • 3.0.2                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (2)
Downloads
Total 132
Today 0
This Week 17
This Month 80
Last Day 0
Last Week 63
Last Month 28
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

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