| title | Dialog |
|---|---|
| description | A window overlaid on either the primary window or another dialog window, rendering the content underneath inert. |
| source | packages/raystack/components/dialog |
import { playground, closeDemo, customDemo, controlledDemo, onlyHeaderDemo, onlyFooterDemo, nestedDemo } from "./demo.ts";
Import and assemble the component:
import { Dialog } from '@raystack/apsara'
<Dialog>
<Dialog.Trigger />
<Dialog.Content>
<Dialog.Header>
<Dialog.Title />
<Dialog.CloseButton />
</Dialog.Header>
<Dialog.Body>
<Dialog.Description />
</Dialog.Body>
<Dialog.Footer />
</Dialog.Content>
</Dialog>Groups all parts of the dialog.
Renders the dialog panel overlay.
Renders the dialog header section.
Renders the dialog title text.
Renders the main content area of the dialog.
Renders supplementary text within the dialog body.
Renders the element that opens the dialog.
Renders a button that closes the dialog.
Renders the dialog footer section.
Example of a controlled dialog with custom state management.
Example with custom width and overlay styling.
Example with header and body.
Example with header and body.
You can nest dialogs within one another. When a nested dialog opens, the parent dialog automatically scales down and becomes slightly transparent. The nested dialog's backdrop won't be rendered, allowing you to see the parent dialog behind it.
- Dialog has
role="dialog"andaria-modal="true" - Uses
aria-labeloraria-labelledbyto identify the dialog - Uses
aria-describedbyto provide additional context - Respects motion preferences: dialog panel motion is enabled only when
prefers-reduced-motion: no-preference