Component
Icon
Published on
Description
The Icon component renders an SVG icon from a sprite sheet using the <use> element. Icons are decorative by default with aria-hidden="true". Pass alt to make an icon meaningful: it then renders with role="img" and aria-label set to the alt text.
Use icons alongside text labels to provide visual context. Avoid using icons as the sole means of conveying meaning without an accessible text alternative.
Example
Accessibility
- Icons are set to
aria-hidden="true"by default, hiding them from screen readers. - Icons with an
altprop getrole="img"and anaria-labelfrom thealttext, so screen readers announce them as images. - Always pair icons with visible text or provide an accessible label on the parent element.
References
- Alternative Text for CSS Generated Content(opens in new tab) — Adrian Roselli
- My Approach to Alt Text(opens in new tab) — Adrian Roselli
Related
- Badge — for count or status indicators
Variables
None