Skip to content

Dialog

Copy editable source into an initialized application:

Terminal window
pnpm dlx @simurgh-ui/cli add dialog

For package consumption, import from the component subpath and load its optional recipe CSS:

import {
Dialog,
DialogTrigger,
DialogPortal,
DialogOverlay,
DialogContent,
DialogTitle,
DialogDescription,
DialogClose,
} from '@simurgh-ui/react/dialog';
import '@simurgh-ui/styles/dialog.css';
import {
Dialog,
DialogTrigger,
DialogContent,
DialogTitle,
DialogDescription,
DialogClose,
} from '@simurgh-ui/vue/dialog';
import '@simurgh-ui/styles/dialog.css';
import { DialogComponent } from '@simurgh-ui/angular/dialog';
import '@simurgh-ui/styles/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.

The optional component stylesheet provides a complete default recipe, including visual hierarchy and interaction states. Consumers can override semantic tokens or omit the recipe.

Live component Dialog

Dialog, trigger, portal/overlay, content, title, description, and close. The title and description provide the accessible name and description. Escape closes the modal; Tab remains contained; focus returns to the opener.

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.

FrameworkExact state contract and reset behavior
ReactControlled: open + onOpenChange. Uncontrolled: defaultOpen. Reset controlled state by assigning the initial value; reset uncontrolled state by changing a React key.
VueControlled: v-model:open (open + update:open). Uncontrolled: defaultOpen. Reset the model ref to its initial value; reset uncontrolled state with a changed Vue :key.
AngularControlled two-way binding: [(open)] (open + openChange). Angular exposes no separate default input; initialize and reset the bound class field explicitly.

React

const initialOpen = false;
const [open, setOpen] = useState(initialOpen);
const [resetKey, setResetKey] = useState(0);
<Dialog open={open} onOpenChange={setOpen}></Dialog>
<button onClick={() => setOpen(initialOpen)}>Reset controlled</button>
<Dialog key={resetKey} defaultOpen={initialOpen}></Dialog>
<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>
<Dialog v-model:open="state"></Dialog>
<button @click="state = initial">Reset controlled</button>
<Dialog :key="resetKey" :defaultOpen="initial"></Dialog>
<button @click="resetKey++">Reset uncontrolled</button>

Angular

initial = false;
open = this.initial;
reset() { this.open = this.initial; }
<simurgh-dialog [(open)]="open"></simurgh-dialog>
<button type="button" (click)="reset()">Reset</button>

Use the recipe classes for the default modal treatment, or remove them and style the semantic parts directly.

<Dialog><DialogTrigger>Edit profile</DialogTrigger><DialogPortal><DialogOverlay /><DialogContent><DialogTitle>Profile</DialogTitle><DialogDescription>Change public details.</DialogDescription><DialogClose>Done</DialogClose></DialogContent></DialogPortal></Dialog>

Real-world example: async profile submission

Section titled “Real-world example: async profile submission”

Keep the dialog controlled while saving so success can close it and failure can leave the form open. Disable repeated submission and announce the result without moving focus unexpectedly.

const [open, setOpen] = useState(false);
const [saving, setSaving] = useState(false);
const [message, setMessage] = useState('');
async function submitProfile(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
setSaving(true);
setMessage('');
try {
await saveProfile(new FormData(event.currentTarget));
setOpen(false);
} catch {
setMessage('Could not save the profile. Try again.');
} finally {
setSaving(false);
}
}
<Dialog open={open} onOpenChange={setOpen}>
<form onSubmit={submitProfile}>
<Button type="submit" loading={saving}>
Save
</Button>
<p aria-live="polite">{message}</p>
</form>
</Dialog>;

Vue uses v-model:open="open" and Angular uses [(open)]="open"; apply the same pending, error, and close-on-success flow in the component script or class.

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 / keysBehavior
Focus entry and exit (Tab / Shift+Tab)Tab enters the open dialog and cycles within it; closing restores the trigger.
Navigation and activationEnter or Space activates the focused control.
EscapeCloses the dialog and restores trigger focus.
RTL differencesNo RTL-specific key mapping.
TypeaheadNot supported.

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.

  • React exports: Dialog, DialogTrigger, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogDescription, DialogClose
  • Vue exports: Dialog, DialogTrigger, DialogContent, DialogTitle, DialogDescription, DialogClose
  • Angular exports: DialogComponent

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.

Complete props type: PropsWithChildren<OpenProps>.

PropTypeDefault / requirement
childrenReactNodeundefined
defaultOpenbooleanundefined
onOpenChange(open: boolean) => voidundefined
openbooleanundefined

Inherited attributes: ButtonHTMLAttributes<HTMLButtonElement> & RefAttributes<HTMLButtonElement>.

PropTypeDefault / requirement
childrenReactNodeundefined
refRef<HTMLButtonElement> | undefinedundefined

Complete props type: { children?: ReactNode; }.

PropTypeDefault / requirement
childrenReactNodeundefined

Inherited attributes: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>.

PropTypeDefault / requirement
childrenReactNodeundefined
refRef<HTMLDivElement> | undefinedundefined

Inherited attributes: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLDivElement>.

PropTypeDefault / requirement
childrenReactNodeundefined
refRef<HTMLDivElement> | undefinedundefined

Inherited attributes: HTMLAttributes<HTMLHeadingElement>.

PropTypeDefault / requirement
childrenReactNodeundefined

Inherited attributes: HTMLAttributes<HTMLParagraphElement>.

PropTypeDefault / requirement
childrenReactNodeundefined

Inherited attributes: ButtonHTMLAttributes<HTMLButtonElement> & RefAttributes<HTMLButtonElement>.

PropTypeDefault / requirement
childrenReactNodeundefined
refRef<HTMLButtonElement> | undefinedundefined
Vue API reference

Boolean props without explicit defaults use Vue’s false default. Undeclared attributes follow the fallthrough behavior stated for each component.

Vue attribute fallthrough is enabled for the rendered root.

PropTypeDefault / requirement
openbooleanundefined
defaultOpenbooleanfalse
EventPayload
update:openboolean

Slots: default.

Exposed methods: none.

Vue attribute fallthrough is enabled for the rendered root.

No declared props.

No emitted events.

Slots: default.

Exposed methods: none.

Vue attribute fallthrough is enabled for the rendered root.

No declared props.

No emitted events.

Slots: default.

Exposed methods: none.

Vue attribute fallthrough is enabled for the rendered root.

No declared props.

No emitted events.

Slots: default.

Exposed methods: none.

Vue attribute fallthrough is enabled for the rendered root.

No declared props.

No emitted events.

Slots: default.

Exposed methods: none.

Vue attribute fallthrough is enabled for the rendered root.

No declared props.

No emitted events.

Slots: default.

Exposed methods: none.

Angular API reference

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.

Component selector: simurgh-dialog. The template’s first native element is ng-content.

InputTypeDefault / requirement
openbooleanfalse
labelledBystringundefined
describedBystringundefined
OutputPayload
openChangeboolean

Content projection: [trigger], default.

Public method
show(): void
close(): void
onKeydown(event: KeyboardEvent): void

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.

FrameworkRequired parent/child relationshipConditional partsSupporting types
ReactRender Dialog as the ancestor. Nest the listed parts inside that root so they can read its shared state/context.DialogTrigger, DialogPortal, DialogOverlay, DialogContent, DialogTitle, DialogDescription, DialogClose 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.
VueRender Dialog as the ancestor. Nest the listed parts inside that root so they can read its shared state/context.DialogTrigger, DialogContent, DialogTitle, DialogDescription, DialogClose 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.
AngularCreate DialogComponent first and project descendants into its named regions.[trigger], default are projection regions; default is the main body and named selectors such as [trigger] are required only for that interaction.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.

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.

ConcernContract
Public compositionReact exports 8 parts, Vue 6, and Angular 1. These are intentional composition differences; use each framework’s example rather than translating symbol-for-symbol.
State and change eventsReact uses controlled/default props and callbacks for open; Vue uses v-model:open; Angular uses [(open)].
Children and contentReact uses children; Vue uses the slots listed above; Angular uses the documented content projection selectors.
Native attributesReact 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 accessReact 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.

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.

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.

StateReactVueAngular
LoadingNot 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.
EmptyNot 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.
InvalidNot 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-onlyNot 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.
DisabledSupported 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.
ErrorNot 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

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.

SurfaceStable hooks
Recipe classes.simurgh-content, .simurgh-dialog, .simurgh-item, .simurgh-overlay, .simurgh-sheet, .simurgh-trigger
Stable DOM parts[data-slot="button"], [data-slot="checkbox"], [data-slot="dialog-close"], [data-slot="dialog-content"], [data-slot="dialog-description"], [data-slot="dialog-overlay"], [data-slot="dialog-title"], [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-duration, --simurgh-foreground, --simurgh-muted-foreground, --simurgh-radius, --simurgh-ring, --simurgh-scrim, --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.

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.