Skip to main content Red Hat Design System logo Contribute on Github v1.4.5

Icon

Overview Style Guidelines Code Demos Accessibility

Installation

Usage

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

Slots 1
Slot Name Description

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

Attributes 4
DOM Property Description Type Default
set

Icon set

IconSetName | undefined
unknown
icon

Icon name

IconNameFor<IconSetName> | undefined
unknown
accessibleLabel

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

string | undefined
unknown
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 0

None

© 2021-2024 Red Hat, Inc. Deploys by Netlify