Skip to main content Home
About About the Design SystemRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridIconographySpacingTypography
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

Icon

OverviewStyleGuidelinesCodeAccessibilityDemos
ImportingUsagerh-iconImportingUsagerh-icon

Loading

Icons load lazily by default, meaning that the browser will not attempt to fetch and render the icon until it scrolls into view. You can change this with the loading attribute, which has three values:

  1. lazy (the default): load icons when they scroll into view
  2. idle: load each icon on the page as soon as the browser enters an idle state Or, on less-capable browsers, at the next frame
  3. eager: each icon will begin to load and render the moment it connects to the DOM.

You might choose to enable eager rendering for "above-the-fold" content, but keep lazy loading for the rest of the page.

<rh-icon icon="alert" loading="eager"></rh-icon>

Importing

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

<script type="module">
  import '@rhds/elements/rh-icon/rh-icon.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-icon icon="hat"></rh-icon>

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

Loading

Icons load lazily by default, meaning that the browser will not attempt to fetch and render the icon until it scrolls into view. You can change this with the loading attribute, which has three values:

  1. lazy (the default): load icons when they scroll into view
  2. idle: load each icon on the page as soon as the browser enters an idle state Or, on less-capable browsers, at the next frame
  3. eager: each icon will begin to load and render the moment it connects to the DOM.

You might choose to enable eager rendering for "above-the-fold" content, but keep lazy loading for the rest of the page.

<rh-icon icon="alert" loading="eager"></rh-icon>

rh-icon

Icons represents general concepts and can support text as a decorative element. The icon element is a container that allows users to add icons of varying dimensions in the same area without shifting surrounding content.

Slots 1
Slot Name Description

Slotted content is used as a fallback in case the icon doesn't load

Attributes 4
Attribute DOM Property Description Type Default
set set

Icon set

IconSetName | undefined
unknown
icon icon

Icon name

IconNameFor<IconSetName> | undefined
unknown
accessible-label accessibleLabel

Defines a string value that labels the icon element. Adds role="img" to element.

string | undefined
unknown
loading loading

Controls how eager the element will be to load the icon data

  • eager: eagerly load the icon, blocking the main thread
  • idle: wait for the browser to attain an idle state before loading
  • lazy (default): wait for the element to enter the viewport before loading
'idle' | 'lazy' | 'eager' | undefined
'lazy'
Methods 0
None
Events 3
Event Name Description
load

Fired when an icon is loaded and rendered

set
error

Fired when an icon fails to load

CSS Shadow Parts 1
Part Name Description
fallback

Container for the fallback (i.e. slotted) content

CSS Custom Properties 1
CSS Property Description Default
--rh-icon-size

Override default icon size

Design Tokens 2
Token Copy
--rh-size-icon-01
Full CSS Variable Permalink to this token
--rh-size-icon-04
Full CSS Variable Permalink to this token
© 2021-2025 Red Hat, Inc. Deploys by Netlify