Alert dialog: Controlled
Pass open and onOpenChange to open it from code, without a trigger. Focus still lands on Cancel.
This adds the example as components/examples/alert-dialog/controlled.tsx, together with the Alert dialog component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/alert-dialog-controlled.jsonTo add only the component, follow the Alert dialog installation.
Props in this example
The Alert dialog props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
open | boolean | – |
onOpenChangeNot called for closes blocked by a pending action. | (open: boolean, details) => void | – |
Every prop is in the Alert dialog API reference.
See them all, with keyboard support and accessibility notes, on the Alert dialog page.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- SheetA panel that slides in from any edge, with swipe-to-dismiss, scroll lock and stacked nesting.
- CommandA searchable list of actions, inline or as a ⌘K palette, with pages, shortcuts and highlighted matches.
- Context menuA menu of actions on right click or long press, with submenus, checkbox and radio items, and hold feedback on touch.
- DialogA window over the page for forms and focused tasks, with a pinned header and footer, nesting, and a swipeable bottom sheet on phones.
- DrawerA panel that slides in from any edge and follows your finger, with snap points, a working handle and nested drawers that stack.