Skip to content
uiify

Alert dialog

Dialog that asks the user to confirm or cancel an action.

Browsers
Chrome 123+, Firefox 121+, Safari 17.5+
Tier
0
Bundle compressed
659 B
Forced layout budget
0 ms
Axe budget
0
SSR compatible
Yes
Published contract
Test harness

Playground

Delete item?

This action cannot be undone.

Delete item?

This action cannot be undone.

import { AlertDialog } from "@gunkin/uiify";

export default function Example() {
  return (
    <AlertDialog
      id="delete-dialog"
      trigger="Delete item"
      title="Delete item?"
      description="This action cannot be undone."
    />
  );
}

API

AlertDialog

PropTypeDefaultDescription
idstring——
triggerReactNode——
titleReactNode——
descriptionReactNode——
childrenReactNode——
actionLabelReactNode"Confirm"—
cancelLabelReactNode"Cancel"—
slotPropsAlertDialogSlotProps—Native props for each generated part; the AlertDialog root takes props directly.

AlertDialogAction

PropTypeDefaultDescription
childrenReactNode——
targetstring——
commandstring——
commandforstring——
asElementType & ("button" | ComponentType<any>)—`"button"` (default) or a component that forwards props and ref to a native <button>.
rendernever——

AlertDialogCancel

PropTypeDefaultDescription
childrenReactNode——
targetstring——
commandstring——
commandforstring——
asElementType & ("button" | ComponentType<any>)—`"button"` (default) or a component that forwards props and ref to a native <button>.
rendernever——

AlertDialogContent

PropTypeDefaultDescription
childrenReactNode——
idstring——

AlertDialogTrigger

PropTypeDefaultDescription
childrenReactNode——
targetstring—`id` of the `AlertDialogContent` this button opens.
commandstring——
commandforstring——
asElementType & ("button" | ComponentType<any>)—`"button"` (default) or a component that forwards props and ref to a native <button>.
rendernever——

Keyboard

KeyAction
EscapeCancel and close the dialog
TabCycle focus between Cancel and Action

Accessibility

Native <dialog role="alertdialog"> opened by a command="show-modal" invoker before any JavaScript runs. The browser owns modality, focus containment, Escape and focus return. Cancel renders before Action, so focus starts on the safe choice; both close the dialog, and the application action belongs on Action. When composing parts, point aria-labelledby and aria-describedby on AlertDialogContent at the title and description ids.

Styling hooks

  • --uiify-trigger-openinside .uiify-alert-dialog