Toolforge Docs
DocsIO Primitivesconfirm

confirm

Prompts the user for confirmation with OK/Cancel buttons.

Usage

confirm

const confirmed = await io.confirm({
  title: 'Delete Item',
  description:
    'Are you sure you want to delete this item? This action cannot be undone.',
})

if (confirmed) {
  await deleteItem()
}

Props

PropDescriptionTypeRequiredDefault
titleTitle of the confirmation boxstringYes
descriptionOptional description of the confirmation boxstringNoundefined
blockOptional block to show additional information in the confirmation boxBlockOutputNoundefined
okButtonLabelOptional label for the OK buttonstringNo'OK'
cancelButtonLabelOptional label for the Cancel buttonstringNo'Cancel'

Returns

Returns Promise<boolean>. true if the user clicked OK, false if Cancel.

Examples

Custom button labels

confirm-custom-buttom

const proceed = await io.confirm({
  title: 'Continue Processing',
  description: 'This will process all pending items.',
  okButtonLabel: 'Process All',
  cancelButtonLabel: 'Cancel',
})

Confirmation with rich content

confirm-with-data

const approve = await io.confirm({
  title: 'Approve Transaction',
  description: 'Please review the transaction details below:',
  block: {
    type: 'table',
    data: [{ Recipient: 'John Do', Amount: '$1,000.00', Account: '****1234' }],
  },
  okButtonLabel: 'Approve',
  cancelButtonLabel: 'Reject',
})

On this page