GitHub

Confirmation Dialog

Destructive action dialog requiring text confirmation

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { ConfirmationDialog } from "@corew500/ui/confirmation-dialog"

<ConfirmationDialog>Content</ConfirmationDialog>

API Reference

Props

PropTypeDefaultDescription
open*enumWhether the dialog is open
onOpenChange*(open: boolean) => voidCallback when open state changes
title*stringDialog title text
descriptionstringDialog description text
confirmPhrase*stringThe exact phrase the user must type to enable the action button
confirmLabelstringConfirmLabel for the action button
cancelLabelstringCancelLabel for the cancel button
inputLabelenumCustom label for the confirmation input. Defaults to "Type {phrase} to confirm"
inputPlaceholderstringPlaceholder text for the confirmation input
variantenumdestructiveVisual variant affecting the action button and warnings styling
onConfirm*() => void | Promise<void>Callback when the action is confirmed. Can return a Promise for async operations.
loadingenumExternal loading state. When provided, overrides internal loading management.
iconenumOptional icon displayed in the dialog header
warningsstring[]Optional list of warning messages displayed above the confirmation input
classNameenumCSS class applied to the element, or a function that returns a class based on the component’s state.
styleenumStyle applied to the element, or a function that returns a style object based on the component’s state.
initialFocusenumDetermines the element to focus when the dialog is opened. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (first tabbable element or popup). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.
finalFocusenumDetermines the element to focus when the dialog is closed. - `false`: Do not move focus. - `true`: Move focus based on the default behavior (trigger or previously focused element). - `RefObject`: Move focus to the ref element. - `function`: Called with the interaction type (`mouse`, `touch`, `pen`, or `keyboard`). Return an element to focus, `true` to use the default behavior, or `false`/`undefined` to do nothing.
sizeenum

Accessibility

Focus Management

  • Focus trapped within dialog when open
  • Confirmation input receives focus when dialog opens

Screen Readers

  • - Inherits AlertDialog ARIA: role="alertdialog", aria-labelledby, aria-describedby
  • Live region announces loading state

Additional

  • Action button clearly indicates disabled state

Localization

Translatable Content

  • - All text props should be pre-translated
  • `inputLabel`, `confirmLabel`, `cancelLabel`, `inputPlaceholder` are customizable

Additional

  • `confirmPhrase` is displayed to the user and used for matching

Related

Related Components