Tally UI
UI

ConfirmDialog

ConfirmDialog asks for confirmation before running an action and lets the user cancel instead.

Import

import { ConfirmDialog } from '@tallyui/components';

Usage

import { Button, Text } from '@tallyui/components';

function DiscardDraft({ discard }: { discard: () => void }) {
  return (
    <ConfirmDialog title="Discard this draft?" confirmLabel="Discard" testID="discard-draft"
      trigger={<Button><Text>Discard draft</Text></Button>} onConfirm={discard} />
  );
}

Confirm calls onConfirm and closes the dialog. Cancel closes without calling onConfirm. There is no busy state or wait for an asynchronous result.

Props

PropTypeDefaultDescription
titlestringRequiredDialog heading
descriptionstring—Explanatory text below the heading
cancelLabelstring'Cancel'Cancel button text
confirmLabelstringRequiredConfirm button text
tone'destructive' | 'default''destructive'Styles the confirm button
onConfirm() => voidRequiredRuns when the user confirms
testIDstringRequiredIdentifies the dialog content and supplies the default button ID prefix
cancelTestIDstringtestID + -cancelOverrides the cancel button ID
confirmTestIDstringtestID + -confirmOverrides the confirm button ID
triggerReact.ReactElement—Element that opens the dialog; omit it when controlling open externally
openbooleanUncontrolledControls whether the dialog is open
onOpenChange(open: boolean) => void—Receives open and close requests; update open here in controlled usage

Tones

ToneConfirm button variantCancel button variant
destructivedestructiveoutline
defaultdefaultoutline