diff --git a/packages/checkbox/src/index.ts b/packages/checkbox/src/index.ts index 67de61ade..61ec9a79c 100644 --- a/packages/checkbox/src/index.ts +++ b/packages/checkbox/src/index.ts @@ -23,13 +23,14 @@ export type Choice = { type State = { prefix?: string; pageSize?: number; + instructions?: string | boolean; message: string; choices: ReadonlyArray>; }; export default createPrompt( (state: State, done: (value: Array) => void): string => { - const { prefix, pageSize = 7 } = state; + const { prefix, pageSize = 7, instructions } = state; const paginator = useRef(new Paginator()).current; const [status, setStatus] = useState('pending'); @@ -103,13 +104,17 @@ export default createPrompt( } let helpTip = ''; - if (showHelpTip !== false) { - const keys = [ - `${chalk.cyan.bold('')} to select`, - `${chalk.cyan.bold('')} to toggle all`, - `${chalk.cyan.bold('')} to invert selection`, - ]; - helpTip = ` (Press ${keys.join(', ')})`; + if (showHelpTip && (instructions === undefined || instructions)) { + if (typeof instructions === 'string') { + helpTip = instructions; + } else { + const keys = [ + `${chalk.cyan.bold('')} to select`, + `${chalk.cyan.bold('')} to toggle all`, + `${chalk.cyan.bold('')} to invert selection`, + ]; + helpTip = ` (Press ${keys.join(', ')})`; + } } const allChoices = choices