An interactive list prompt implementation for Inquirer.
You can select a choice by using the arrow keys + Enter or by pressing the key associated with the choice.
? Choose an option:
> Run command (r)
Quit (q)
npm install inquirer-interactive-list-prompt
import prompt from 'inquirer-interactive-list-prompt';
(async () => {
const answer = await prompt({
message: 'Select an option:',
choices: [
{ name: 'Run', value: 'run', key: 'r' },
{ name: 'Quit', value: 'quit', key: 'q' },
],
renderSelected: choice => `❯ ${choice.name} (${choice.key})`, // optional
renderUnselected: choice => ` ${choice.name} (${choice.key})`, // optional
});
console.log(`Selected option: ${answer}`);
})();
Prompts the user with an interactive list prompt.
Type: object
Type: string
Required: true
The message to display to the user.
Type: Array<{ name: string, value: any }>
Required: true
An array of choices to display to the user.
Type: (line: string, index: number) => string
Default: (line) => line
A function that is called to render each choice in the prompt. The function should return a string that will be displayed to the user.
Type: boolean
Default: true
Whether to hide the cursor while the prompt is active.
MIT