React

Alert Dialog

A component used as a strong expression and warning means when user confirmation is essential.

Available since@seed-design/react@0.0.1, @seed-design/css@0.0.1

Stackflow

Learn how to use Stackflow and Alert Dialog together.

Installation

npx @seed-design/cli@latest add ui:alert-dialog

Props

AlertDialogRoot

Prop

Type

childrenReact.ReactNode
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean, details?: DialogChangeDetails) => void) | undefined

AlertDialogTrigger

Prop

Type

AlertDialogContent

Prop

Type

layerIndex?number | undefined

AlertDialogHeader

Prop

Type

AlertDialogTitle

Prop

Type

AlertDialogDescription

Prop

Type

AlertDialogFooter

Prop

Type

Examples

Trigger

<AlertDialogTrigger> sets the aria-haspopup="dialog" attribute and automatically sets the aria-expanded attribute based on AlertDialog's open state. This attribute is useful for assistive technologies such as screen readers.

Responsive Wrapping

Using the <ResponsivePair> component, when button content becomes long, you can fold the layout vertically.

Single Action

Neutral Secondary Action

Nonpreferred

Critical Action

Controlled

You can open and close AlertDialog in ways other than Trigger. In this case, use the open prop to control AlertDialog's state.

Prevent Close

Calling e.preventDefault() in AlertDialogAction's onClick prevents the dialog from closing.

onOpenChange Details

The details is provided as the second argument to onOpenChange.

reason

When opening (open: true)

  • "trigger": Opened by AlertDialogTrigger (Dialog.Trigger)

When closing (open: false)

  • "closeButton": Closed by AlertDialogAction
  • "escapeKeyDown": ESC key pressed
  • "interactOutside": Clicked outside area
    • AlertDialogRoot defaults to closeOnInteractOutside={false}. interactOutside can only occur when this option is set to true.
  • "cascadeDismiss": Cascade closing due to parent layer closing

Portalled

Portal renders by default on document.body.

Skip Animation

You can skip AlertDialog's enter/exit animation using the skipAnimation prop.

Stackflow

Loading...

Table of contents