Skip to main content Home
About About the Design SystemRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridIconographyInteractionsSpacingTypography
Tokens Overview Global colorbox shadowTypographyborderopacityspacelengthIconBreakpointsMedia Queries
Elements All elements Accordion Alert Announcement Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Card Chip Code block Call to action Dialog Disclosure Footer Health index Icon Jump links Navigation (primary) Navigation (secondary) Pagination PopoverPlanned Progress stepsPlanned Site status Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Theming OverviewColor PalettesCustomizingDevelopers
Patterns All PatternsCardTabsFilterFormLinkLink with iconLogo wallSearch barSkip navigationSticky bannerSticky cardTileVideo thumbnail
Personalization All Personalization PatternsAnnouncement
Accessibility FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers
Design/code status Release notes Get support

Dialog

OverviewStyleGuidelinesCodeAccessibilityDemos
ImportingUsagerh-dialogImportingUsagerh-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 Wrap lines

To learn more about installing RHDS elements on your site using an import map read our getting started docs.

Usage

<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>

<script type="module">
  import '@rhds/elements/rh-button/rh-button.js';
  import '@rhds/elements/rh-cta/rh-cta.js';
  import '@rhds/elements/rh-dialog/rh-dialog.js';
</script>
Copy to Clipboard Wrap lines

rh-dialog

A dialog displays important information to users without requiring them to navigate away from the page.

Slots 3
Slot Name 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.

header

The header is an optional slot that appears at the top of the dialog window. It should be a header tag (h2-h6).

footer

Optional footer content. Good place to put action buttons.

Attributes 6
Attribute DOM Property Description Type Default
variant variant

The variant controls the width of the dialog. There are three options: small, medium and large. The default is large.

'small' | 'medium' | 'large' | undefined
unknown
position position

position="top" aligns the dialog with the top of the page

'top' | undefined
unknown
accessible-label accessibleLabel

Use accessible-label="My custom label" to specify the dialog's accessible name. Defaults to the name of the dialog trigger if no attribute is set and no headings exist in the modal. See Dialog's Accessibility page for more info.

string | undefined
unknown
open open

open / open="open" declaratively opens the dialog

boolean
false
trigger trigger

Optional ID of the trigger element

string | undefined
unknown
type type

Use type="video" to embed a video player into a dialog.

'video' | undefined
unknown
Methods 5
Method Name Description
setTrigger(element: HTMLElement)
toggle()

Manually toggles the dialog.

dialog.toggle();
show()

Manually opens the dialog.

dialog.show();
showModal()
close(returnValue: string)

Manually closes the dialog.

Events 3
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.

CSS Shadow Parts 6
Part Name Description
dialog

The dialog element

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

close-button

The dialog's close button

footer

Actions footer container

CSS Custom Properties 2
CSS Property Description Default
--rh-dialog-video-aspect-ratio

Aspect ratio for the video inside the dialog

16/9
--rh-dialog-close-button-color

Sets the dialog close button color.

var(--rh-color-icon-secondary-on-dark, #ffffff)
Design Tokens 20
Token Copy
--rh-border-radius-default
Full CSS Variable Permalink to this token
--rh-box-shadow-xl
Full CSS Variable Permalink to this token
--rh-color-gray-90-rgb
Full CSS Variable Permalink to this token
--rh-color-icon-secondary
Full CSS Variable Permalink to this token
--rh-color-surface-dark
Full CSS Variable Permalink to this token
--rh-color-surface-darker
Full CSS Variable Permalink to this token
--rh-color-surface-lightest
Full CSS Variable Permalink to this token
--rh-color-text-primary
Full CSS Variable Permalink to this token
--rh-font-family-body-text
Full CSS Variable Permalink to this token
--rh-font-family-heading
Full CSS Variable Permalink to this token
--rh-font-size-heading-sm
Full CSS Variable Permalink to this token
--rh-font-weight-body-text-regular
Full CSS Variable Permalink to this token
--rh-length-xl
Full CSS Variable Permalink to this token
--rh-opacity-60
Full CSS Variable Permalink to this token
--rh-space-2xl
Full CSS Variable Permalink to this token
--rh-space-3xl
Full CSS Variable Permalink to this token
--rh-space-lg
Full CSS Variable Permalink to this token
--rh-space-md
Full CSS Variable Permalink to this token
--rh-space-sm
Full CSS Variable Permalink to this token
--rh-space-xl
Full CSS Variable Permalink to this token
© 2021-2025 Red Hat, Inc. Deploys by Netlify