Interactive list prompt implementation for Inquirer.js
npm install inquirer-interactive-list-promptAn 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.
``javascript`
? Choose an option:
> Run command (r)
Quit (q)
`sh`
npm install inquirer-interactive-list-prompt
`js
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: line => chalk.green(❯ ${line}), // optional ${line}
renderUnselected: line => , // optional
});
console.log(Selected option: ${answer});`
})();
Prompts the user with an interactive list prompt.
#### options
Type: object
##### message
Type: stringtrue
Required:
The message to display to the user.
##### choices
Type: Array<{ name: string, value: any }>true
Required:
An array of choices to display to the user.
##### renderer
Type: (line: string, index: number) => string(line) => line
Default:
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.
##### hideCursor
Type: booleantrue`
Default:
Whether to hide the cursor while the prompt is active.
MIT