Simple interactive command line prompt to gather boolean input from users. Inspired by [prompts](https://www.npmjs.com/package/prompts#togglemessage-initial-active-inactive).
npm install date-input-promptinquirer-toggleSimple interactive command line prompt to gather boolean input from users. Inspired by prompts.
``sh
npm install inquirer-toggle
yarn add inquirer-toggle
`
`js
import toggle from 'inquirer-toggle';
const answer = await toggle({ message: 'Continue?' });
`
| Property | Type | Required | Default | Description |
|-----------------------|----------------------| -------- |--------------------|----------------------------------------------------------|
| message | string | yes | - | The question to be displayed to the user. |boolean
| default | | no | false | The default answer when the user doesn't provide one. |Object
| theme | | no | - | An object to customize the look of the prompt. |string
| theme.active | | no | "yes" | The text to display for the active part of the toggle. |string
| theme.inactive | | no | "no" | The text to display for the inactive part of the toggle. |string
| theme.prefix | | no | chalk.green('?') | The prefix to display before the message. |Object
| theme.style | | no | - | An object to customize the styles of the prompt. |(string) => string
| theme.style.message | | no | chalk.bold | A function to style the message. |(string) => string
| theme.style.answer | | no | chalk.cyan | A function to style the answer. |(string) => string
| theme.style.highlight | | no | chalk.cyan | A function to style the highlighted user selection. |
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.
`ts``
type Theme = {
message: string;
default?: boolean;
theme?: {
active?: string;
inactive?: string;
prefix?: Theme["prefix"];
style?: {
message?: Theme["style"]["message"];
answer?: Theme["style"]["answer"];
highlight?: Theme["style"]["highlight"];
}
};
};
Copyright (c) 2024 Sertac Karahoda
Licensed under the MIT license.