Alert Dialog
Installation
Section titled “Installation”Copy editable source into an initialized application:
pnpm dlx @simurgh-ui/cli add alert-dialogFor package consumption, import from the component subpath and load its optional recipe CSS:
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel,} from '@simurgh-ui/react/alert-dialog';import '@simurgh-ui/styles/alert-dialog.css';import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel,} from '@simurgh-ui/vue/alert-dialog';import '@simurgh-ui/styles/alert-dialog.css';Angular
Section titled “Angular”import { AlertDialogComponent, AlertDialogActionDirective, AlertDialogCancelDirective,} from '@simurgh-ui/angular/alert-dialog';import '@simurgh-ui/styles/alert-dialog.css';Omit the component stylesheet for fully headless styling. CLI-copied components use the local path
written to simurgh.json and the copied application styles instead of these package imports.
Purpose
Section titled “Purpose”Alert Dialog interrupts a workflow to confirm an important or destructive action. It focuses the safe cancel action when opened, contains keyboard focus, and restores focus to its trigger after dismissal.
Default presentation: styled
Section titled “Default presentation: styled”The optional component stylesheet provides a complete default recipe, including visual hierarchy and interaction states. Consumers can override semantic tokens or omit the recipe.
Basic usage
Section titled “Basic usage”Anatomy
Section titled “Anatomy”The public component parts are listed in API surface below. Use only the parts needed by the example; compound components depend on their documented parent/child nesting.
State model
Section titled “State model”Controlled state remains the application’s source of truth and must be updated from every change event. Uncontrolled state reads its default only when the component mounts. Do not pass both forms of the same state at once.
| Framework | Exact state contract and reset behavior |
|---|---|
| React | Controlled: open + onOpenChange. Uncontrolled: defaultOpen. Reset controlled state by assigning the initial value; reset uncontrolled state by changing a React key. |
| Vue | Controlled: v-model:open (open + update:open). Uncontrolled: defaultOpen. Reset the model ref to its initial value; reset uncontrolled state with a changed Vue :key. |
| Angular | No public two-way state binding is exposed. |
React
const initialOpen = false;const [open, setOpen] = useState(initialOpen);const [resetKey, setResetKey] = useState(0);
<AlertDialog open={open} onOpenChange={setOpen}>…</AlertDialog><button onClick={() => setOpen(initialOpen)}>Reset controlled</button><AlertDialog key={resetKey} defaultOpen={initialOpen}>…</AlertDialog><button onClick={() => setResetKey((key) => key + 1)}>Reset uncontrolled</button>Vue
<script setup lang="ts">import { ref } from 'vue';const initial = false;const state = ref(initial);const resetKey = ref(0);</script>
<AlertDialog v-model:open="state">…</AlertDialog><button @click="state = initial">Reset controlled</button><AlertDialog :key="resetKey" :defaultOpen="initial">…</AlertDialog><button @click="resetKey++">Reset uncontrolled</button>Reserve Alert Dialog for decisions that genuinely require interruption. Use Dialog for ordinary modal content and Alert for nonmodal status messages.
Examples
Section titled “Examples”<AlertDialog> <AlertDialogTrigger>Delete project</AlertDialogTrigger> <AlertDialogContent> <AlertDialogTitle>Delete project?</AlertDialogTitle> <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction onClick={removeProject}>Delete</AlertDialogAction> </AlertDialogContent></AlertDialog><AlertDialog> <AlertDialogTrigger>Delete project</AlertDialogTrigger> <AlertDialogContent> <AlertDialogTitle>Delete project?</AlertDialogTitle> <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction @select="removeProject">Delete</AlertDialogAction> </AlertDialogContent></AlertDialog><simurgh-alert-dialog #dialog labelledBy="delete-title" describedBy="delete-description"> <button trigger (click)="dialog.show()">Delete project</button> <h2 id="delete-title">Delete project?</h2> <p id="delete-description">This action cannot be undone.</p> <button simurghAlertDialogCancel>Cancel</button> <button simurghAlertDialogAction (action)="removeProject()">Delete</button></simurgh-alert-dialog>Keyboard interactions
Section titled “Keyboard interactions”These keys describe behavior implemented by the adapters. Native Tab, Enter, and Space behavior still applies to descendant links, buttons, and form controls unless the component overrides it.
| Concern / keys | Behavior |
|---|---|
| Focus entry and exit (Tab / Shift+Tab) | Tab enters the open dialog and cycles within it; closing restores the trigger. |
| Navigation and activation | Enter or Space activates the focused action or cancel button. |
| Escape | Closes the dialog and restores trigger focus. |
| RTL differences | No RTL-specific key mapping. |
| Typeahead | Not supported. |
Accessibility
Section titled “Accessibility”Preserve the documented composition and accessible names when wrapping or restyling this component. See accessibility and RTL guidance for keyboard, focus, labeling, and directionality requirements.
API surface
Section titled “API surface”- React exports:
AlertDialog,AlertDialogTrigger,AlertDialogContent,AlertDialogTitle,AlertDialogDescription,AlertDialogAction,AlertDialogCancel - Vue exports:
AlertDialog,AlertDialogTrigger,AlertDialogContent,AlertDialogTitle,AlertDialogDescription,AlertDialogAction,AlertDialogCancel - Angular exports:
AlertDialogComponent,AlertDialogActionDirective,AlertDialogCancelDirective
Import these public symbols from the component subpath shown in Installation. Framework-specific props, events, slots, directives, methods, defaults, and native-attribute behavior belong in the API tables on this page; use the linked source only to verify the current implementation.
React API reference
An inherited-attributes entry means the component accepts the complete named React native interface, including its event handlers and ARIA and data attributes. Remaining attributes are forwarded to the rendered element unless the component behavior described on this page overrides them.
AlertDialog
Section titled “AlertDialog”Complete props type: PropsWithChildren<OpenProps>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
defaultOpen | boolean | undefined |
onOpenChange | (open: boolean) => void | undefined |
open | boolean | undefined |
AlertDialogTrigger
Section titled “AlertDialogTrigger”Inherited attributes: ButtonHTMLAttributes<HTMLButtonElement> & RefAttributes<HTMLButtonElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
ref | Ref<HTMLButtonElement> | undefined | undefined |
AlertDialogContent
Section titled “AlertDialogContent”Inherited attributes: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
ref | Ref<HTMLDivElement> | undefined | undefined |
AlertDialogTitle
Section titled “AlertDialogTitle”Inherited attributes: HTMLAttributes<HTMLHeadingElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
AlertDialogDescription
Section titled “AlertDialogDescription”Inherited attributes: HTMLAttributes<HTMLParagraphElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
AlertDialogAction
Section titled “AlertDialogAction”Inherited attributes: ButtonHTMLAttributes<HTMLButtonElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
AlertDialogCancel
Section titled “AlertDialogCancel”Inherited attributes: ButtonHTMLAttributes<HTMLButtonElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
Vue API reference
Boolean props without explicit defaults use Vue’s false default. Undeclared attributes follow
the fallthrough behavior stated for each component.
AlertDialog
Section titled “AlertDialog”Vue attribute fallthrough is enabled for the rendered root.
| Prop | Type | Default / requirement |
|---|---|---|
open | boolean | undefined |
defaultOpen | boolean | false |
| Event | Payload |
|---|---|
update:open | boolean |
Slots: default.
Exposed methods: none.
AlertDialogTrigger
Section titled “AlertDialogTrigger”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
No emitted events.
Slots: default.
Exposed methods: none.
AlertDialogContent
Section titled “AlertDialogContent”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
No emitted events.
Slots: default.
Exposed methods: none.
AlertDialogTitle
Section titled “AlertDialogTitle”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
No emitted events.
Slots: default.
Exposed methods: none.
AlertDialogDescription
Section titled “AlertDialogDescription”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
No emitted events.
Slots: default.
Exposed methods: none.
AlertDialogAction
Section titled “AlertDialogAction”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
| Event | Payload |
|---|---|
select | none |
Slots: default.
Exposed methods: none.
AlertDialogCancel
Section titled “AlertDialogCancel”Vue attribute fallthrough is enabled for the rendered root.
No declared props.
| Event | Payload |
|---|---|
select | none |
Slots: default.
Exposed methods: none.
Angular API reference
Angular
Section titled “Angular”Inputs and outputs use their public template names. Public methods are callable through a template
reference or ViewChild. Native attributes apply to the documented template root or directive host;
they are not automatically forwarded through component hosts.
AlertDialogComponent
Section titled “AlertDialogComponent”Component selector: simurgh-alert-dialog. The template’s first native element is ng-content.
No inputs.
No outputs.
Content projection: [trigger], default.
| Public method |
|---|
show(): void |
AlertDialogActionDirective
Section titled “AlertDialogActionDirective”Attribute directive selector: button[simurghAlertDialogAction]; behavior applies to its host element.
No inputs.
| Output | Payload |
|---|---|
action | void |
Content projection: none.
| Public method |
|---|
choose(): void |
AlertDialogCancelDirective
Section titled “AlertDialogCancelDirective”Attribute directive selector: button[simurghAlertDialogCancel]; behavior applies to its host element.
No inputs.
No outputs.
Content projection: none.
| Public method |
|---|
cancel(): void |
Composition contract
Section titled “Composition contract”Follow the framework example as a structural contract. Root components own shared state; parts that consume that state must stay under the root (or be attached to projected descendants in Angular). Parts described as conditional are optional until their corresponding interaction or semantic region is used. Do not render a state-consuming part by itself.
| Framework | Required parent/child relationship | Conditional parts | Supporting types |
|---|---|---|---|
| React | Render AlertDialog as the ancestor. Nest the listed parts inside that root so they can read its shared state/context. | AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
| Vue | Render AlertDialog as the ancestor. Nest the listed parts inside that root so they can read its shared state/context. | AlertDialogTrigger, AlertDialogContent, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
| Angular | Create AlertDialogComponent first. Attach listed directives to elements inside its projected content; nested component parts must remain inside it. | AlertDialogActionDirective, AlertDialogCancelDirective are conditional parts: include only those needed by the documented anatomy. A trigger/control and its matching content/item are required when that interaction is used. | None. |
Accessible names, descriptions, and form labels remain required whenever the component’s purpose cannot otherwise be determined, even when the corresponding visual part is optional.
Framework parity and differences
Section titled “Framework parity and differences”The adapters target the same user-visible behavior and accessibility contract. Their public shapes follow each framework’s conventions and are not expected to be symbol-for-symbol identical.
| Concern | Contract |
|---|---|
| Public composition | React exports 7 parts, Vue 7, and Angular 3. These are intentional composition differences; use each framework’s example rather than translating symbol-for-symbol. |
| State and change events | React uses controlled/default props and callbacks for open; Vue uses v-model:open; Angular uses inputs and outputs. |
| Children and content | React uses children; Vue uses the slots listed above; Angular uses the documented content projection selectors. |
| Native attributes | React forwards the named native interface; Vue follows the stated fallthrough rule; Angular attributes apply to the component host unless an input, directive, or documented native root consumes them. |
| Imperative access | React forwards native refs; Vue exposes no methods; Angular exposes the listed class methods through a template reference or ViewChild. |
These differences are intentional adapter design. Behavioral or accessibility differences not stated on this page are parity defects rather than supported variations.
Form integration
Section titled “Form integration”This component is not a form control and does not contribute a named value to FormData. Use it
to structure or describe a form only when its purpose and accessibility guidance apply.
Supported states
Section titled “Supported states”The table distinguishes component behavior from application-owned presentation. “Not supported” means there is no public state contract for that adapter; do not invent one with an undocumented attribute. Keep status and error messages accessible when they are rendered outside the component.
| State | React | Vue | Angular |
|---|---|---|---|
| Loading | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Empty | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Invalid | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Read-only | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Disabled | Supported with disabled={true} on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Error | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
Styling contract
Styling contract
Section titled “Styling contract”The selectors below are used by the published component recipe or emitted consistently by an adapter. Treat these as the supported styling surface. Element order, anonymous wrappers, and undocumented descendants are implementation details and should not be targeted.
| Surface | Stable hooks |
|---|---|
| Recipe classes | .simurgh-content, .simurgh-item, .simurgh-overlay, .simurgh-trigger |
| Stable DOM parts | [data-slot="alert-dialog-content"], [data-slot="button"], [data-slot="checkbox"], [data-slot="input"], [data-slot="input-otp"], [data-slot="native-select"], [data-slot="pagination-link"], [data-slot="select-trigger"], [data-slot="toggle-group-item"], [data-slot="toolbar-button"] |
| Stable data attributes | [data-density], [data-slot] |
| ARIA/state selectors used by the recipe | [aria-disabled] |
| CSS custom properties consumed | --simurgh-border, --simurgh-control-height, --simurgh-control-padding, --simurgh-foreground, --simurgh-radius, --simurgh-ring, --simurgh-shadow, --simurgh-surface |
Prefer a semantic token override for theme-wide changes. Use the listed class or part selectors for a component-scoped override. When omitting recipe CSS, preserve state attributes and ARIA semantics even if your replacement styles use different selectors.
Customization
Section titled “Customization”Load the optional component stylesheet for the default recipe, override semantic tokens for broad theme changes, or omit the recipe CSS for headless styling. See theming and styling hooks for import order, selectors, dark mode, RTL, and reduced-motion guidance.
Last verified on 2026-08-13 against Simurgh registry 0.1.1.
Related components
Section titled “Related components”- Review the shared accessibility and RTL guidance and theming and styling hooks.
- Use the component chooser and component overview to compare related primitives.
- Inspect the registry manifest and framework source for React, Vue, or Angular.