--- title: Prompts --- Prompts are specialized [React components](./components.md) for handling `process.stdin` input. All components can be imported from `@boost/cli/react`. ## Confirm The [`Confirm`](/api/cli-react/function/Confirm) component provides a binary choice through the input of a single character. On submission, either a `true` or `false` value will be passed. ```tsx import { Confirm } from '@boost/cli'; ; ``` ![Confirm example](/img/cli/prompts/confirm.gif) ## HiddenInput The [`HiddenInput`](/api/cli-react/function/HiddenInput) component is a specialized [`Input`](#input) that accepts user input, hides it from the console, and returns the entered string on submission. ```tsx import { HiddenInput } from '@boost/cli'; ; ``` ![Hidden input example](/img/cli/prompts/hidden-input.gif) ### Controls - Inherits all the same keyboard controls as [Input](#input). ## Input The [`Input`](/api/cli-react/function/Input) component is a simple text prompt that takes user input and returns a string. Supports standard typing, backspacing. On submission, the final `string` will be trimmed of whitespace. ```tsx import { Input } from '@boost/cli'; ; ``` ![Input example](/img/cli/prompts/input.gif) ### Controls - ↑, ↓ - Move cursor to the beginning or end of the entered text. - ←, → - Move cursor forward or backward 1 character. - delete, backspace - Remove the previous character at the current cursor position. - return - Submit the currently entered text. ## MultiSelect The [`MultiSelect`](/api/cli-react/function/MultiSelect) component works in a similar fashion to [`Select`](#select), but allows for multiple values to be selected before submission. ```tsx import { MultiSelect } from '@boost/cli'; ; ``` ![Multiple select example](/img/cli/prompts/multiselect.gif) ### Controls - ↑, ↓ - Move forward or backward through options in the list. - ←, → - Move to the beginning or end of the list. - space - Select or unselect the currently highlighted option. - return - Submit the currently selected options. ## PasswordInput The [`PasswordInput`](/api/cli-react/function/PasswordInput) component is a specialized [`Input`](#input) that masks user input and replaces each character with a star (`*`). ```tsx import { PasswordInput } from '@boost/cli'; ; ``` ![Password input example](/img/cli/prompts/password-input.gif) ### Controls - Inherits all the same keyboard controls as [Input](#input). ## Select The [`Select`](/api/cli-react/function/Select) component allows a value to be selected from a pre-defined list of options. Supports standard keyboard navigation. To select or unselect a value, press the space bar, or on submission, the currently highlighted option will be chosen. ```tsx import { Select } from '@boost/cli'; ; ``` ![Select with labels example](/img/cli/prompts/select-labels.gif) ### Controls - ↑, ↓ - Move forward or backward through options in the list. - ←, → - Move to the beginning or end of the list. - space - Select or unselect the currently highlighted option. - return - Submit the currently selected option, or the currently highlighted option if none are selected. ## Non-React If you would like to use prompts outside of React components and within the command space, sadly, there is no built-in Boost solution. However, you can easily use a third-party solution like [enquirer](https://github.com/enquirer/enquirer). Just be sure to set `stdin` and `stdout` streams correctly! ```tsx import { prompt } from 'enquirer'; import { Command } from '@boost/cli'; export default class InitCommand extends Command { async run() { const { stdin, stdout } = this.getProgram().streams; const { username } = await prompt({ type: 'input', name: 'username', message: 'What is your username?', stdin, stdout, }); } } ```