github/a11y-svg-has-accessible-name
June 26, 2026 ยท View on GitHub
๐ Require SVGs to have an accessible name.
๐ผ This rule is enabled in the โ๏ธ react config.
Rule Details
An <svg> must have an accessible name. Set aria-label or aria-labelledby, or nest a <title> element as the first child of the <svg> element.
However, if the <svg> is purely decorative, hide it with aria-hidden="true" or role="presentation".
Resources
Examples
Incorrect code for this rule ๐
<svg height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg height='100' width='100' title='Circle with a black outline and red fill'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
<title>Circle with a black outline and red fill</title>
</svg>
Correct code for this rule ๐
<svg height='100' width='100'>
<title>Circle with a black outline and red fill</title>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg aria-label='Circle with a black outline and red fill' height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg aria-labelledby='circle_text' height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg aria-hidden='true' height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>
<svg role='presentation' height='100' width='100'>
<circle cx='50' cy='50' r='40' stroke='black' stroke-width='3' fill='red'/>
</svg>