Skip to content
Xerobi Icons

Accessibility guide

How to use icons so everyone can use your interface: decorative and informative icons, accessible names, contrast, target size and motion.

Last updated

An icon file does not know whether it is decoration, information or a button. The page that uses it does. This guide is for people using Xerobi Icons. If you are drawing icons, read Design accessibility.

What the packages do for you

Icons from @xerobi/icons-react, @xerobi/icons-vue, @xerobi/icons-react-native and the web component are decorative by default. They render with aria-hidden="true" (or the React Native equivalent), so a screen reader skips them. That is right most of the time: an icon beside the word “Save” adds nothing for someone who hears “Save”.

Give an icon a label and it becomes a named image:

<House aria-label="Home" />

Decorative icons

The icon sits next to text that already says the same thing. Do nothing; it is hidden.

<button type="button"><Download /> Download report</button>

Icon-only buttons

The control needs a name, and the name belongs on the button, not on the drawing:

<button type="button" aria-label="Close dialog"><X /></button>

Name the action, not the picture. Use “Close dialog”, “Delete file”, “Show password”. Do not use “X icon”, “Trash can” or “Three lines”.

In React Native:

<Pressable accessibilityRole="button" accessibilityLabel="Close dialog"><X /></Pressable>

A tooltip is not a replacement for an accessible name. Where there is room, a visible text label helps everyone, including people who do not know the icon.

Informative icons

The icon carries information that is not in nearby text, such as a status:

<CheckCircle aria-label="Synchronization complete" weight="fill" />

Color

Icons use currentColor, so they take the color of the text around them. You are responsible for the contrast.

  • Graphics that identify a control or carry information should meet at least a 3:1 contrast against the background (WCAG 2.2, success criterion 1.4.11).
  • Never use color alone to show state. A red icon and a green icon of the same shape are the same icon to someone who cannot tell them apart. Change the shape (x-circle and check-circle) or add text.
  • The duotone weight uses a lighter second tone. Make sure the icon still reads if that tone disappears.

Size and target area

The icon’s size and the control’s size are different things. A 16 px icon can sit inside a 44 px button. Make the button at least 24 by 24 CSS pixels (WCAG 2.2 AA), and prefer 44 by 44 points on touch screens.

Right-to-left languages

Icons that point in a direction should flip in right-to-left layouts: arrows, chevrons, back and forward, and things that show progress. Use the mirrored prop:

<ArrowRight mirrored={isRtl} />

Do not mirror icons of real objects or brand logos (a clock, a phone, a check mark).

Motion

If you animate icons, respect prefers-reduced-motion, do not flash, and do not let meaning depend on the animation alone.

Checklist

  • Decorative icons stay hidden. Informative ones have a label.
  • Every icon-only control has a name that describes its action.
  • State is shown by more than color.
  • Contrast is at least 3:1 where the icon carries meaning.
  • The control, not the icon, meets the target-size requirement.
  • Direction-sensitive icons mirror in right-to-left layouts.
  • Motion respects the user’s preference.

References