termprompt

confirm

Yes or no question.

Preview

Active state (Yes focused)

confirm
Deploy to production?
Yes / No

After submit

confirm
Deploy to production?
Yes

Usage

import { confirm, isCancel } from 'termprompt';

const shouldContinue = await confirm({
  message: 'Deploy to production?',
});

if (isCancel(shouldContinue)) process.exit(0);

if (shouldContinue) {
  console.log('Deploying...');
}

Props

PropTypeDefaultDescription
messagestringrequiredQuestion text
initialValuebooleanfalsePre-selected value
activestring"Yes"Label for the true option
inactivestring"No"Label for the false option

Custom Labels

const gitInit = await confirm({
  message: 'Initialize a git repository?',
  active: 'Yeah',
  inactive: 'Nah',
  initialValue: true,
});

Keyboard

KeyAction
Left / hToggle
Right / lToggle
TabToggle
y / YSet to yes
n / NSet to no
EnterSubmit
EscCancel

On this page