axe-core "button-name" buttons must have discernible text in CI
axe-core rule button-name found a <button> with no accessible name. WCAG 4.1.2 requires interactive controls to expose a name; an icon-only button needs an aria-label or visually hidden text.
What this error means
axe reports "button-name: Buttons must have discernible text" for a button whose only child is an icon or SVG with no text and no aria-label.
axe-core
button-name: Buttons must have discernible text (critical)
Fix any of the following:
Element does not have inner text that is visible to screen readers
aria-label attribute does not exist or is empty
Element's default semantics were not overridden with role="none"
<button class="icon-btn"><svg>...</svg></button>Common causes
An icon-only button has no text alternative
The button contains only an SVG or icon font with no aria-label, so screen readers announce nothing meaningful.
The SVG conveys the name but is not exposed
The icon is not marked aria-hidden and carries no <title>, leaving the button with no reliable accessible name.
How to fix it
Give the button an aria-label
- Add an
aria-labeldescribing the action, for example "Delete item". - Mark the decorative icon
aria-hidden="true"so it is not double-announced. - Re-run axe to confirm the button now has a name.
Component.jsx
<button aria-label="Delete item">
<svg aria-hidden="true">...</svg>
</button>Use visually hidden text as an alternative
A visually hidden span provides the name while keeping the button icon-only for sighted users.
Component.jsx
<button>
<svg aria-hidden="true">...</svg>
<span class="sr-only">Delete item</span>
</button>How to prevent it
- Require an accessible name on every icon-only control.
- Mark decorative icons aria-hidden to avoid noise.
- Add axe checks for interactive components in the test suite.
Related guides
axe-core "link-name" links must have discernible text in CIFix axe-core "link-name: Links must have discernible text" in CI - an anchor has no text or accessible name,…
axe-core "label" form element has no label in CIFix axe-core "label: Form elements must have labels" in CI - an input, select, or textarea has no associated…
jest-axe "Expected the HTML found at $X to have no violations" in CIFix jest-axe "Expected the HTML found at $X to have no violations" in CI - the toHaveNoViolations matcher fou…