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 group 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 Readtime Scheme toggle Select Site status Skeleton Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed OverviewColor PalettesCustomizingDevelopers All PatternsAccordionAlertCall to ActionCardFilterFormLink with iconLogo wallSearch barSticky bannerSticky cardTabsTagTile All Personalization PatternsAnnouncement FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers Design/code status Release notes Get support

Alert

OverviewStyleGuidelinesCodeAccessibilityDemos
ImportingUsageRhAlert.toast()rh-alertImportingUsageRhAlert.toast()rh-alert

Importing

Add rh-alert to your page with this import statement:

<script type="module">
  import '@rhds/elements/rh-alert/rh-alert.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-alert>
  <h3 slot="header">Default</h3>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam eleifend elit sed est
    egestas, a sollicitudin mauris tincidunt.</p>
  <rh-button slot="actions" variant="secondary" data-action="confirm">Confirm</rh-button>
  <rh-button slot="actions" variant="link" data-action="dismiss">Cancel</rh-button>
</rh-alert>

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

RhAlert.toast()

Accessibility considerations

There are accessibility considerations to keep in mind when using toasts. See our toast pattern accessibility guidelines for more information.

Toast alerts are created with the static RhAlert.toast() method. Full API options, accessibility considerations, layout, and a live demo are documented on the Alert pattern page. Do not author <rh-alert variant="toast"> directly in HTML; use the JavaScript API.

import { RhAlert } from '@rhds/elements/rh-alert/rh-alert.js';

await RhAlert.toast({ state: 'success', message: 'Saved!' });

rh-alert

An alert provides a banner for status changes or messages. It uses ARIA role="alert" so screen readers must announce its content. Authors should provide a heading and must avoid nesting alerts. Users may Tab to interactive elements and press Enter to activate them. Meets WCAG 2.4.3.

Theming

Themable

This element uses Red Hat design system theming and can be used in themable contexts.

Slots 3

Slot Name Summary Description
actions

Up to two rh-button action elements. Each must have a data-action attribute. Buttons are keyboard-focusable via Tab and should use ARIA labels when text is not descriptive.

header

Alert heading; must be a heading element (e.g. <h3>) so screen readers convey the alert's ARIA structure.

[default]

Body content for the alert; accepts block elements like <p>. Should be concise so screen reader users quickly understand it.
Note: [default] unnamed slots do not have a slot="name" attribute.

Attributes 3

Attribute DOM Property Description Type Default
state state

Communicates the urgency of a message and is denoted by various styling configurations.

  • neutral - Indicates generic information or a message with no severity.
  • danger - Indicates a danger state, like an error that is blocking a user from completing a task.
  • warning - Indicates a warning state, like a non-blocking error that might need to be fixed.
  • caution - Indicates an action or notice which should immediately draw the attention
  • info - Indicates helpful information or a message with very little to no severity.
  • success - Indicates a success state, like if a process was completed without errors.

Note: 'note', 'default', and 'error' will also work, but are deprecated

'danger' | 'warning' | 'caution' | 'neutral' | 'info' | 'success'
'neutral'
variant variant

The alternate Inline alert style includes a border instead of a line which can be used to express more urgency or better grab the attention of a user.

A Toast alert is used to present a global message about an event, update, or confirmation, like the result of a user action that cannot be presented within a specific layout or component. Toast alerts often appear away from what triggered them, may time out, automatically, and can be hard to discover in linear reading order. Toast alerts pose significant accessibility concerns and are not recommended for use.

'alternate' | 'toast' | 'inline'
unknown
dismissable dismissable

Alert variants have different rules regarding their ability to be dismissed by a user. Default, Info, and Success Inline alerts can be dismissed by a user selecting the close button. Warning and Danger Inline alerts can be dismissed by a user resolving the issues caused by the alert. All Toast alerts can be dismissed by a user selecting the close button or waiting for them to time out.

boolean
false

Methods 0

None

Events 1

Event Name Description
close

Fires when dismissed via close button or action click. AlertCloseEvent.action contains the action string (e.g. 'close', 'confirm', 'dismiss'). Cancelable: call preventDefault() to keep the alert in the DOM.

CSS Shadow Parts 0

None

CSS Custom Properties 0

None

Design Tokens 38

Token Description Copy
--rh-space-xl

Action button inline end margin

24px spacer

Full CSS Variable Permalink to this token
--rh-color-interactive-primary-default

Action link color

Full CSS Variable Permalink to this token
--rh-color-interactive-primary-hover

Action link hover/focus color

Full CSS Variable Permalink to this token
--rh-color-teal-10

Default surface color

Alert - Default background

Full CSS Variable Permalink to this token
--rh-color-teal-50

Default border color

Default icon color

Alert - Default accent

Full CSS Variable Permalink to this token
--rh-border-width-md

Alert border width

2px border width: Example: Alert

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

Alert dark mode surface color

Tertiary surface (dark theme)

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

Footer block start margin

Alert padding

16px spacer

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

Alert font weight

Regular font weight

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

Alert font family

Header font family

Body text font family

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

Header font weight

Medium font weight

Full CSS Variable Permalink to this token
--rh-line-height-body-text

Alert line height

Header line height

Line height for body text

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

Action button font size

Alert font size

Header font size

Description font size

14px font size

Full CSS Variable Permalink to this token
--rh-color-status-neutral

Neutral state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-neutral

Neutral state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-neutral

Neutral state surface color

Full CSS Variable Permalink to this token
--rh-color-status-info

Info state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-info

Info state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-info

Info state surface color

Full CSS Variable Permalink to this token
--rh-color-status-success

Success state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-success

Success state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-success

Success state surface color

Full CSS Variable Permalink to this token
--rh-color-status-caution

Caution state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-caution

Caution state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-caution

Caution state surface color

Full CSS Variable Permalink to this token
--rh-color-status-warning

Warning state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-warning

Warning state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-warning

Warning state surface color

Full CSS Variable Permalink to this token
--rh-color-status-danger

Danger state border color

Full CSS Variable Permalink to this token
--rh-color-icon-status-danger

Danger state icon color

Full CSS Variable Permalink to this token
--rh-color-surface-status-danger

Danger state surface color

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

Toast surface color

Primary surface (light theme)

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

Toast box shadow

Extra large box shadow

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

Header block end margin

Grid gap

Heading block end padding

Close button area inline end margin

4px spacer

Full CSS Variable Permalink to this token
--rh-size-icon-02

Status icon inline size

Status icon block size

24px icon box

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

Close button color

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

Close button block size

Close button inline size

24px length token

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

Header text color

Close button hover color

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