Skip to content

Accessible icons: labels, contrast and the code for each case

An eye icon with a purple check badge on its corner

An accessible icon starts with one question: what is it doing? A decorative icon sits beside text that already says the same thing, so hide it from screen readers with aria-hidden="true". An informative icon carries meaning on its own, like a status marker in a table, so give it a text alternative and at least 3:1 contrast. An interactive icon is the only content of a button or link, so the button needs an accessible name, usually through aria-label, and a target of at least 24 by 24 CSS pixels.

Behind all three sits the advice that helps everyone, including people who never use a screen reader: put a visible text label next to the icon wherever there's room.

The three kinds of icon, and the code for each

Decorative: hide it

Most icons in a product sit next to words: a trash can beside "Delete", a gear beside "Settings". The text already gives the meaning, so a screen reader announcing the icon too would just add noise. Hide the icon and let the text speak.

<button type="button">
  <svg aria-hidden="true" focusable="false">…</svg>
  Delete
</button>

aria-hidden="true" removes the icon from the accessibility tree. focusable="false" is for older browsers that could put an SVG in the tab order; it does no harm in current ones. Some icon libraries now do this by default: Lucide made aria-hidden the default for its icons in version 1.

Informative: give it a text alternative

An icon that carries meaning with no text beside it needs its own name. Typical cases are a green check in a status column, a warning sign in a form summary, or a lock beside a file name to say it's private.

<svg role="img" aria-label="Private">…</svg>

role="img" makes the whole SVG one image, so a screen reader doesn't try to read its paths, and aria-label gives it a name. MDN documents the pattern under the img role. Visually hidden text next to a hidden icon works just as well, and is easier to translate in some setups.

Under WCAG 2.2, this is success criterion 1.1.1, Non-text Content: non-text content needs a text alternative that serves the same purpose, and decorative content should be ignorable by assistive technology.

Interactive: name the control

An icon-only button, like a close ×, a menu or a "more" button, has no text, so the button itself needs a name. Put it on the button and hide the icon inside.

<button type="button" aria-label="Close dialog">
  <svg aria-hidden="true" focusable="false">…</svg>
</button>

Name the action, not the picture. "Close dialog" tells a screen reader user what happens; "X" or "Cross icon" doesn't. The same applies to links: a share icon that links to a sharing page needs a name like "Share this post".

When a button shows text too, its accessible name should contain that text. That's success criterion 2.5.3, Label in Name, and it matters for voice control users, who say what they see. An aria-label of "Remove item" on a button that shows "Delete" breaks the command "click Delete".

Contrast: 3:1 for icons that carry meaning

Text needs 4.5:1 contrast, but icons fall under a separate rule. Success criterion 1.4.11, Non-text Contrast, asks for at least 3:1 against adjacent colours for graphics that are required to understand the content and for what identifies a control or its state. W3C's own examples include a print icon with no text and status icons on a dashboard without text.

In practice:

  • An icon-only button's icon needs 3:1 against its background, because it's the only thing that identifies the button.
  • A decorative icon beside a text label doesn't, because the text carries the meaning. Pale decorative icons are allowed, though most interfaces look better with icons close to the text colour.
  • An icon that shows state, like a filled star for "favourited" or a chevron that marks a dropdown, needs 3:1 for the part that shows the state.

Check icons in every theme you ship. Grey icons that pass on white often fail on a dark background, and the reverse.

Don't let colour or shape alone carry the meaning

A red icon for "error" and a green one for "success" tell nothing to someone who can't tell red from green. Success criterion 1.4.1, Use of Color, says colour can't be the only way information is conveyed. Use different icons for different states (a check and an alert, not one circle in two colours), and pair them with words.

The same thinking applies to swapping an outline icon for a filled one to show selection. The change of shape helps, but a selected tab should also be marked in code, with aria-selected or aria-current, so assistive technology knows which one is active. Outline vs filled icons covers the visual side.

Target size for icon buttons

A 16 or 20px icon is too small to tap reliably, so the button around it needs padding. Success criterion 2.5.8, Target Size (Minimum), asks for targets of at least 24 by 24 CSS pixels at level AA, with an exception for smaller targets that have enough space around them. Apple and Android recommend larger targets for touch. Icon sizes compares the numbers and shows them drawn to scale.

Tooltips aren't labels

A tooltip on hover helps sighted mouse users learn what an icon means, but it doesn't help screen reader users unless the same text is the button's accessible name, and it never appears on a touch screen. Use a tooltip as a hint, keep the name in aria-label or visible text, and make the tooltip text match it.

If you do show tooltips, success criterion 1.4.13, Content on Hover or Focus, asks that they can be dismissed without moving the pointer, that the pointer can move onto them without them vanishing, and that they stay until the user moves away.

The label is the best accessibility feature

Most icons aren't as clear as designers hope. Nielsen Norman Group's icon usability guidance says "a text label must be present alongside an icon to clarify its meaning", and that only a few icons, such as home, print and search, are widely recognised on their own. Its rule of thumb for designers: if it takes you more than five seconds to think of an icon for something, the icon is unlikely to communicate it.

A visible label helps people with cognitive disabilities, people using voice control, people new to your product and people reading in a second language, all at once. Keep icon-only buttons for the handful of actions everyone recognises, and for toolbars where space is tight and a tooltip explains the rest.

Icon fonts need extra care

If you use an icon font, every icon is a character, and screen readers may read it out. Add aria-hidden="true" to every decorative font icon, and give meaningful ones visually hidden text. Users who override fonts for readability see boxes instead of icons, which is one of the reasons icon fonts vs SVG recommends SVG for new work.

How to test your icons

  • Read the accessibility tree. In Chrome or Firefox developer tools, the Accessibility panel shows each element's name and role. Every icon-only button should have a name, and decorative icons shouldn't appear.
  • Use a screen reader. VoiceOver is built into macOS and iOS, and NVDA is free on Windows. Tab through the page and listen to what each button is called.
  • Turn the colours off. A greyscale filter in your operating system shows whether states depend on colour alone.
  • Check contrast in each theme. Measure icon colours against their real backgrounds, hover and selected states included.

In code, with our icons

The free Pikaicons React package, @pikaicons/react, hides every icon from assistive technology by default, and passing aria-label makes an icon announced instead. SVG icons in React shows how to build the same behaviour into your own icon component, and there are 900+ free icons to try it with.

Frequently asked questions

How do I make an icon accessible?

Decide what it does. Hide decorative icons next to text with aria-hidden="true". Give informative icons a text alternative, for example role="img" with aria-label. Give icon-only buttons an accessible name with aria-label on the button. Icons that carry meaning need 3:1 contrast against their background.

Should icons have aria-hidden?

Yes, when the icon is decorative, meaning text next to it already says the same thing. Don't hide an icon that is the only content of a button without naming the button, or an icon that carries information no text gives.

What contrast do icons need under WCAG?

At least 3:1 against adjacent colours, under success criterion 1.4.11, for icons required to understand content or to identify a control or its state. Decorative icons next to text are exempt.

How do I label an icon-only button?

Put aria-label on the button with the action it performs, such as "Close dialog" or "Add to favourites", and add aria-hidden="true" to the icon inside it. A visible tooltip with the same text helps sighted users.

Do icons need text labels?

Wherever there's room, yes. Usability research from Nielsen Norman Group found that only a few icons, such as home, print and search, are widely understood without a label. Visible labels help everyone, not only screen reader users.

What size should an icon button be for accessibility?

At least 24 by 24 CSS pixels to meet WCAG 2.2 level AA, unless it has enough space around it. For touch, Apple recommends 44 by 44 points and Android 48 by 48 dp.

Try Pikaicons in your own UI

The quickest way to judge an icon set is to drop it into your own interface. The 900+ free icons are yours to copy and ship, and the full library has 6,000+ icons across five styles for one payment from $99.

Browse icons

Ash