React SVG accessibility
Accessible SVG icons in React
Accessible SVG icons in React need a clear decision: decorative icons should be hidden from assistive tech, while meaningful icons need a useful label.
Accessible SVG icons in React are not about adding every aria attribute. Start by deciding whether the icon adds meaning. Decorative icons can use aria-hidden="true". Meaningful icons need a label, usually through aria-label, title, or nearby visible text.
The short answer
Use aria-hidden="true" for decorative SVG icons that repeat nearby text or add visual style only. Use aria-label or a clear title when the icon carries meaning by itself, such as a standalone search, close, warning, or download icon.
| Icon type | React SVG treatment | Example |
|---|---|---|
| Decorative icon beside text | Use aria-hidden="true". | A check icon next to the word "Saved". |
| Icon-only button | Label the button or the SVG. | A search button with no visible text. |
| Status icon | Give the status visible text or a label. | Warning, error, success, or locked state. |
| Logo mark | Use a text label nearby or add a clear label. | A brand mark without the brand name in text. |
Decorative SVG icons
A decorative SVG icon does not add information. If a trash icon sits next to the text "Delete", the text already tells the user what the control does. In that case, hide the SVG from assistive tech and let the text or button label do the work.
<TrashIcon aria-hidden="true" /> Meaningful SVG icons
A meaningful SVG icon carries information on its own. Icon-only buttons, warning symbols, and status marks need a name that assistive tech can announce. In React, that label can live on the button or on the SVG component, depending on how the component is used.
<button aria-label="Search">
<SearchIcon aria-hidden="true" />
</button> What to review after conversion
- Check whether the icon is decorative or meaningful.
- Keep
aria-hidden="true"only for decorative icons. - Add or preserve
aria-label,title, or visible text for meaningful icons. - Review duplicate IDs if the icon appears more than once on a page.
- Check color-only status icons, because color alone may not explain the state.
Common questions
How do I make SVG icons accessible in React?
Decide whether the SVG is decorative or meaningful. Decorative icons can use aria-hidden="true". Meaningful icons need a useful label through visible text, aria-label, title, or the parent button.
Should decorative SVG icons use aria-hidden in React?
Yes. If the icon only supports nearby text or visual styling, aria-hidden="true" keeps assistive tech from announcing duplicate or unhelpful content.
Should React SVG icons use aria-label or title?
Use aria-label or title when the SVG carries meaning by itself. For icon-only buttons, labeling the button is often clearer than labeling the SVG.
Do converted SVG icons need accessibility review?
Yes. After conversion, review labels, aria-hidden, title, desc, duplicate IDs, color-only states, and whether the icon appears with visible text.