Skip to main content

Page Action | Confirm Modal

Use page.confirm() to display a confirmation modal to the user. This is particularly useful for actions that require user verification before proceeding, such as deletions or other irreversible operations.

async function onClickDeleteCompany(companyId) {
const companyName = companies[companyId].name;

const confirmed = await page.confirm({
message: `Are you sure you want to delete ${companyName}?`
typeToConfirmText: companyName,
appearance: "danger",
});

if (confirmed === true) {
await db.company.deleteById(companyId);
page.add(() => ui.text(`${companyName} was successfully deleted`))
}
}

API reference

Function signature

page.confirm(properties?: Partial<{
title: string,
message: string,
appearance: "primary" | "outline" | "warning" | "danger",
typeToConfirmText: string,
confirmButtonLabel: string,
cancelButtonLabel: string,
}>): Promise<boolean>

Parameters

properties.title

optional string
The title of the confirmation dialog. Defaults to "Confirm".

properties.message

optional string
The main message or question presented to the user. Defaults to "Are you sure you want to do this?".

properties.appearance

optional string literal

Sets the visual style of the dialog. For example, use "danger" for destructive actions. Defaults to "primary".

Options:

  • "primary"
  • "outline"
  • "warning"
  • "danger"

properties.typeToConfirmText

optional string
If provided, the user must type this text to enable the confirm button.

properties.confirmButtonLabel

optional string
Custom label for the confirm button. Defaults to 'Yes'.

properties.cancelButtonLabel

optional string
Custom label for the cancel button. Defaults to 'No'.

Returns

Promise<boolean>

A promise that resolves to true if the user confirms the action, or false if they cancel.