Overview
Accessible Icon provides an accessible label for icons by rendering visually hidden text. This ensures screen reader users understand the purpose of icon-only UI elements.Features
- Hides the icon from the accessibility tree
- Provides a text alternative for screen readers
- Works with any icon component or SVG
Installation
Anatomy
API Reference
Root
Wraps an icon to make it accessible.The accessible label for the icon. This label will be visually hidden but announced to screen reader users.
The icon element to make accessible. Should be a single child element.
Examples
Basic Usage
With SVG
In Navigation
How It Works
Accessible Icon works by:- Setting
aria-hidden="true"on the icon element to hide it from screen readers - Rendering a visually hidden span with the label text that screen readers will announce
- Ensuring the icon cannot receive focus in SVG elements
When to Use
Use Accessible Icon when:- You have icon-only buttons or links
- Icons are used for navigation
- Icons represent actions or states
- You want to provide context for decorative icons that convey meaning
Accessibility
This component follows the best practices for making icon-only interfaces accessible:- Icons are hidden from the accessibility tree with
aria-hidden="true" - A text alternative is provided using visually hidden text
- SVG icons are marked as
focusable="false"to prevent keyboard focus issues in older browsers