Show confirm

Display a confirmation dialog to the client

Displays a confirmation dialog to the client and returns the client's response.

Parameter

ParameterTypeDescription
argsObjectDialog configuration. See the properties listed below.

The args object accepts the following properties:

PropertyTypeDescription
titleStringThe dialog title.
contentStringThe body text of the dialog.
okTextStringLabel for the confirm button (default: "Ok").
cancelTextStringLabel for the cancel button (default: "Cancel").

Syntax

kf.client.showConfirm({ title, content, okText, cancelText }).then(({ action }) => {...})

or

const { action } = await kf.client.showConfirm({ title, content });

Returns

Returns a promise that resolves with an object { action }, where action is "OK" when the user confirms, or "CANCEL" when the user cancels or dismisses the dialog.

Example

To configure a confirmation dialog before submitting a form.

kf.client
  .showConfirm({
    title: "Submit form",
    content: "Are you sure you want to submit the form?",
    okText: "Continue",
    cancelText: "Cancel",
  })
  .then(function ({ action }) {
    if (action === "OK") {
      // code block to be executed if the user confirmed
    } else {
      // code block to be executed if the user cancelled
    }
  });

Output

{ action: "OK" }

On this page