Skip to content

components/ConfirmDialog

import { … } from 'zidane-ui'ui/src/components/ConfirmDialog.tsx

ConfirmDialog in an Overlay
Overlay + zg-float dialog
Lightbox

Components#

ConfirmDialogComponent#

Renders a short yes / no alertdialog with a title, an optional message, a Cancel button and a confirm button. Focus starts on confirm, or on Cancel when destructive, so a stray Enter never confirms a deletion. It draws the panel only; the host puts it on a modal layer and resolves the answer.

TypeScript
function ConfirmDialog(props: ConfirmDialogProps): Element
Parameters
NameTypeDescription
propsConfirmDialogProps

ConfirmOptions plus the callbacks below.

Element
ConfirmDialog props
NameTypeDescription
cancelLabel?from ConfirmOptionsstring

Text of the cancel button. Defaults to the cancel label from useLabels.

className?string

Extra classes on the dialog panel, such as the host layer's entry animation class.

confirmLabel?from ConfirmOptionsstring

Text of the confirm button. Defaults to the confirm label from useLabels.

destructive?from ConfirmOptionsboolean

Danger-toned confirm button; focus starts on Cancel.

message?from ConfirmOptionsReactNode

Body text under the title. When set, it describes the dialog.

onCancel() => void

Called when the Cancel button is pressed.

onConfirm() => void

Called when the confirm button is pressed.

style?CSSProperties

Inline styles on the dialog panel, merged after the component's own.

titlefrom ConfirmOptionsstring

Heading of the dialog. It names the alertdialog.

titleId?string

The title's id, when a host layer's aria-labelledby names it; unique by default.

ui/src/components/ConfirmDialog.tsx:59

Constants#

CONFIRM_TITLE_IDConstantDeprecated#

Deprecated. Titles get a unique id (two dialogs can be open at once). A host layer that is still labelled by this id passes it back as titleId.

The fixed id that earlier versions gave the dialog title.

TypeScript
const CONFIRM_TITLE_ID = 'zg-confirm-title'

ui/src/components/ConfirmDialog.tsx:35

Interfaces#

ConfirmDialogPropsInterface#

Props for ConfirmDialog: ConfirmOptions plus the callbacks.

TypeScript
interface ConfirmDialogProps extends ConfirmOptions
ConfirmDialogProps properties
NameTypeDescription
cancelLabel?from ConfirmOptionsstring

Text of the cancel button. Defaults to the cancel label from useLabels.

className?string

Extra classes on the dialog panel, such as the host layer's entry animation class.

confirmLabel?from ConfirmOptionsstring

Text of the confirm button. Defaults to the confirm label from useLabels.

destructive?from ConfirmOptionsboolean

Danger-toned confirm button; focus starts on Cancel.

message?from ConfirmOptionsReactNode

Body text under the title. When set, it describes the dialog.

onCancel() => void

Called when the Cancel button is pressed.

onConfirm() => void

Called when the confirm button is pressed.

style?CSSProperties

Inline styles on the dialog panel, merged after the component's own.

titlefrom ConfirmOptionsstring

Heading of the dialog. It names the alertdialog.

titleId?string

The title's id, when a host layer's aria-labelledby names it; unique by default.

ui/src/components/ConfirmDialog.tsx:38

ConfirmOptionsInterface#

Content of a ConfirmDialog: its title, message, button labels and tone.

TypeScript
interface ConfirmOptions
ConfirmOptions properties
NameTypeDescription
cancelLabel?string

Text of the cancel button. Defaults to the cancel label from useLabels.

confirmLabel?string

Text of the confirm button. Defaults to the confirm label from useLabels.

destructive?boolean

Danger-toned confirm button; focus starts on Cancel.

message?ReactNode

Body text under the title. When set, it describes the dialog.

titlestring

Heading of the dialog. It names the alertdialog.

ui/src/components/ConfirmDialog.tsx:16