Skip to main content Home About the Design SystemRoadmap OverviewDesignersDevelopers OverviewColorGridIconographyInteractionsSpacingTypography Overview Global colorBox shadowTypographyBorderOpacitySpaceLengthIconBreakpointsMedia queries 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 Menu dropdown Navigation link Navigation (primary) Navigation (secondary) Navigation (vertical) Pagination PopoverPlanned Progress stepper Scheme toggle Site status Skeleton Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed OverviewColor PalettesCustomizingDevelopers All PatternsAccordionCall to ActionCardFilterFormLink with iconLogo wallSearch barSticky bannerSticky cardTabsTagTile All Personalization PatternsAnnouncement 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

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.

Slots 4

Slot Name Summary Description
header

Dialog heading

Should contain an h2-h6 describing the dialog's purpose. The heading becomes the accessible name via aria-labelledby. Sticks to the top when content overflows.

description

Supplementary text below the heading

Brief context supporting the header. Hidden when empty.

[default]

Primary dialog content

Accepts text, forms, images, or interactive elements. Scrolls vertically on overflow. For video dialogs, slot a video or YouTube iframe here.
Note: [default] unnamed slots do not have a slot="name" attribute.

footer

Action buttons at the bottom of the dialog

Primary and secondary action buttons (e.g. confirm, cancel). Hidden when empty. Focusable elements here are part of the dialog's Tab focus cycle.

Attributes 6

Attribute DOM Property Description Type Default
variant variant

Fixed width: small (35 rem), medium (52.5 rem), or large (70 rem). Defaults to min(90%, 1140px) when unset.

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

Vertical placement. Set to top to align to the top of the viewport instead of center.

'top'
unknown
accessible-label accessibleLabel

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

string
unknown
open open

Whether the dialog is currently open.

boolean
false
trigger trigger

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.

string
unknown
type type

Set to video for a 16:9 video dialog. Removes padding and pauses <video> or YouTube <iframe> elements on close.

'video'
unknown

Methods 6

Method Name Description
cancel(returnValue: string)

Cancels and closes the dialog, dispatching a cancel event.

setTrigger(element: HTMLElement)

Sets the trigger element programmatically.

toggle()

Toggles the dialog open or closed.

show()

Opens the dialog as a modal.

showModal()

Opens the dialog as a modal.

close(returnValue: string)

Closes the dialog.

Events 3

Event Name Description
open

Fires when the dialog opens. The event's trigger property (HTMLElement | null) holds the element that opened it.

close

Fires when the dialog closes via close button or programmatic close(). No detail properties.

cancel

Fires when the user dismisses via backdrop click or Escape. No detail properties.

CSS Shadow Parts 7

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

The container for the dialog body content

footer

Actions footer container

CSS Custom Properties 2

CSS Property Description Default
--rh-dialog-close-button-color

Close button icon color; in video mode defaults to lightest surface token for contrast against the dark backdrop.

var(--rh-color-surface-lightest, #ffffff)
--rh-dialog-video-aspect-ratio

Video dialog aspect ratio. Defaults to 16/9. Override for non-standard video dimensions (e.g. 4/3 or 21/9).

16/9

Design Tokens 20

Token Description Copy
--rh-color-surface-darker

Secondary surface (dark theme)

Full CSS Variable Permalink to this token
--rh-font-family-body-text

Dialog typeface

Body text font family

Full CSS Variable Permalink to this token
--rh-box-shadow-xl

Dialog box-shadow

Extra large box shadow

Full CSS Variable Permalink to this token
--rh-color-text-primary

Dialog text color

Full CSS Variable Permalink to this token
--rh-space-3xl

Header and body inline-end padding for close button clearance

48px spacer

Full CSS Variable Permalink to this token
--rh-font-family-heading

Heading typeface

Heading font family

Full CSS Variable Permalink to this token
--rh-font-size-heading-sm

Heading text size

h5 heading font size

Full CSS Variable Permalink to this token
--rh-font-weight-body-text-regular

Heading font weight

Regular font weight

Full CSS Variable Permalink to this token
--rh-space-lg

Header bottom margin

Header pseudo-element height for sticky overlap

16px spacer

Full CSS Variable Permalink to this token
--rh-space-xl

Dialog inner padding

Last body paragraph bottom margin

24px spacer

Full CSS Variable Permalink to this token
--rh-color-icon-secondary

Default close button icon color

Full CSS Variable Permalink to this token
--rh-color-surface-dark

Tertiary surface (dark theme)

Full CSS Variable Permalink to this token
--rh-border-radius-default

Dialog box corner rounding

Close button corner rounding

3px border radius; Example: Card

Full CSS Variable Permalink to this token
--rh-length-xl

Close button hit area height

Close button hit area width

24px length token

Full CSS Variable Permalink to this token
--rh-space-2xl

Dialog box inner padding at wide viewports

32px spacer

Full CSS Variable Permalink to this token
--rh-color-gray-90

Secondary surface (dark theme)

Full CSS Variable Permalink to this token
--rh-opacity-60

60% opacity

Full CSS Variable Permalink to this token
--rh-space-md

Footer action button gap

8px spacer

Full CSS Variable Permalink to this token
--rh-space-sm

6px spacer

Full CSS Variable Permalink to this token
--rh-color-surface-lightest

Primary surface (light theme)

Full CSS Variable Permalink to this token
© 2026 Red Hat Deploys by Netlify