Dialog
On this page
Overview
Modal overlay for confirming decisions or collecting input. Traps focus and
blocks page interaction. Must have a heading or accessible-label for screen
readers. Uses native <dialog> with aria-labelledby. Escape closes the
dialog; Tab cycles focus within it. Use sparingly to avoid disrupting workflow.
Edit element properties
import '@rhds/elements/rh-button/rh-button.js';
import '@rhds/elements/rh-cta/rh-cta.js';
import '@rhds/elements/rh-dialog/rh-dialog.js';
<rh-button id="first-modal-trigger">Open</rh-button>
<rh-dialog trigger="first-modal-trigger">
<h2 slot="header">Modal dialog with a header</h2>
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<rh-cta slot="footer" href="#bar">Call to Action</rh-cta>
</rh-dialog>
import { Button } from "@rhds/elements/react/rh-button/rh-button.js";
import { Cta } from "@rhds/elements/react/rh-cta/rh-cta.js";
import { Dialog } from "@rhds/elements/react/rh-dialog/rh-dialog.js";
// NOTE: React 19+ does not require these wrapper imports.
// You can use the custom elements directly as-is.
export const Demo = () => (
<Button id="first-modal-trigger">Open</Button>
<Dialog trigger="first-modal-trigger">
<h2 slot="header">Modal dialog with a header</h2>
<p>
Lorem ipsum dolor sit amet,
<a href="#foo">consectetur adipisicing</a>
elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.
</p>
<Cta slot="footer" href="#bar">Call to Action</Cta>
</Dialog>
);
Fixed width: small (35 rem), medium (52.5 rem), or large (70 rem).
Defaults to min(90%, 1140px) when unset.
Vertical placement. Set to top to align to the top of the viewport
instead of center.
Accessible name for the dialog. Must be provided when no heading
exists in the header or default slot. Maps to aria-label on the
native <dialog>.
Whether the dialog is currently open.
ID of the element that opens the dialog on click. Should exist in
the same document or shadow root. Its text is used as a fallback
accessible name when no heading or accessible-label is present.
Set to video for a 16:9 video dialog. Removes padding and pauses
<video> or YouTube <iframe> elements on close.
Status
- Figma library:
-
Ready - RH Elements:
-
Ready - RH Shared Libs:
-
Ready
When to use
- When you need to confirm user decisions
- When you need an immediate response from users
- When you need to notify users of urgent information concerning their current workflow
Status checklist
| Property | Status | Meaning |
|---|---|---|
| Figma library |
|
Component is available in the Figma library |
| RH Elements |
|
Component is available in RH Elements |
| RH Shared Libs |
|
Component is available in RH Shared Libs |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.