Dialog
Importing
Add rh-dialog to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-dialog/rh-dialog.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Usage
rh-dialog
A dialog displays important information to users without requiring them to navigate away from the page.
Slot Name | Summary | Description |
---|---|---|
header |
The header is an optional slot that appears at the top of the dialog window. It should be a header tag (h2-h6). |
|
description |
||
|
The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the dialog window (to the left of the close button). Otherwise it will appear beneath the header. |
|
footer |
Optional footer content. Good place to put action buttons. |
Attribute | DOM Property | Description | Type | Default |
---|---|---|---|---|
variant |
variant |
The |
|
|
position |
position |
|
|
|
accessible-label |
accessibleLabel |
Use |
|
|
open |
open |
|
|
|
trigger |
trigger |
Optional ID of the trigger element |
|
|
type |
type |
Use |
|
|
Method Name | Description |
---|---|
cancel(returnValue: string) |
|
setTrigger(element: HTMLElement) |
|
toggle() |
Manually toggles the dialog.
|
show() |
Manually opens the dialog.
|
showModal() |
|
close(returnValue: string) |
Manually closes the dialog. |
Event Name | Description |
---|---|
open |
Fires when a user clicks on the trigger or manually opens a dialog. |
close |
Fires when either a user clicks on either the close button or manually closes a dialog. |
cancel |
Fires when a user clicks outside the dialog or hits ESC on their keyboard. |
Part Name | Summary | Description |
---|---|---|
dialog |
The dialog element |
|
close-button |
The dialog's close button |
|
content |
The container for the dialog content |
|
header |
The container for the optional dialog header |
|
description |
The container for the optional dialog description in the header |
|
body |
||
footer |
Actions footer container |
CSS Property | Description | Default |
---|---|---|
--rh-dialog-close-button-color |
Sets the dialog close button color. |
var(--rh-color-surface-lightest, #ffffff)
|
--rh-dialog-video-aspect-ratio |
16/9
|
Token | Copy |
---|---|
--rh-color-surface-darker
|
|
--rh-font-family-body-text
|
|
--rh-box-shadow-xl
|
|
--rh-color-text-primary
|
|
--rh-space-3xl
|
|
--rh-font-family-heading
|
|
--rh-font-size-heading-sm
|
|
--rh-font-weight-body-text-regular
|
|
--rh-space-lg
|
|
--rh-space-xl
|
|
--rh-color-icon-secondary
|
|
--rh-color-surface-dark
|
|
--rh-border-radius-default
|
|
--rh-length-xl
|
|
--rh-space-2xl
|
|
--rh-color-gray-90
|
|
--rh-opacity-60
|
|
--rh-space-md
|
|
--rh-space-sm
|
|
--rh-color-surface-lightest
|
|
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.