Skip to main content

Labeling Interactive Elements

Moss identifies interactive elements on the page by their accessible names. When a button contains only an SVG icon and no visible text, Moss cannot determine what the button does and will be unable to reference it in guided instructions. Adding an aria-label to icon-only buttons fixes this and also improves accessibility for screen reader users.

The Problem

Buttons that contain only an SVG icon have no accessible name:
When Moss encounters these elements, it cannot generate clear instructions like “Click the Delete button” because there is no label to reference.

The Fix

Add an aria-label attribute that describes what the button does:
Adding aria-hidden="true" to the SVG marks it as decorative. The button’s aria-label carries the meaning instead.

Using Component Libraries

If you use a component library and don’t manage raw HTML elements directly, aria-label still works. React forwards all aria-* props to the underlying DOM element, so this applies to any component that renders a clickable element.

Custom Icon Button Components

If your team has a shared icon button wrapper, make sure it passes through aria-label by spreading rest props onto the underlying element:

Buttons With Tooltips

If a button already has a tooltip, use that same text as the aria-label:

Writing Good Labels

  • Describe the action, not the icon. Users and Moss need to know what the button does.
  • Keep it concise — 1 to 3 words is usually enough.
  • Skip the label if visible text exists. A button that already says “Save” next to an icon does not need aria-label.

Finding Unlabeled Buttons

Run this snippet in your browser console to find buttons that need labels:
Run this on each major page of your application to get a full inventory of buttons that need labeling.

Summary

This is also a WCAG 2.1 requirement (Success Criterion 4.1.2: Name, Role, Value), so adding these labels improves accessibility for all users.