put role="img", if missing, to produced svg element
See original GitHub issueš Feature Proposal
Consider setting role="img"
to <svg>
.
Motivation
Because out-of-the-box, Illustrator and many others donāt add it, and developers have to do it manually.
Example
Putting role=āimgā on the svg element ensures it is identified as a graphic.
Pitch
Why does this feature belong in the SVGR ecosystem? Itās a no-brainer, a quick improvement to accessibility.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
ARIA: img role - Accessibility - MDN Web Docs
The ARIA img role can be used to identify multiple elements inside page content that should be considered as a single image.
Read more >SVG element with explicit role has non-empty accessible ...
This rule checks that each SVG image element that is explicitly included in the accessibility tree has a non-empty accessible name.
Read more >5 Gotchas You're Gonna Face Getting Inline SVG Into ...
Since pointer-events are inherited, this will cause any of the SVG āsub-elementsā to also not respond to pointer-events . Once you've set thisĀ ......
Read more >Do I use <img>, <object>, or <embed> for SVG files?
After the image is loaded the onload="SVGInject(this) will trigger the injection and the <img> element will be replaced by the contents of the...
Read more >Using SVG and Vue.js: A complete guide - LogRocket Blog
If that happens, it's fairly straightforward to add another <path> to the SVG file and another color to the colors object. Another benefit...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not a huge fan of this being defaulted in the way it is. While I appreciate the sentiment this is problematic since now this requires alt text or a role=āpresentationalā override on every SVG (to my understanding, I could be wrong that a label would be required now - https://dequeuniversity.com/rules/axe/4.4/svg-img-alt?application=axeAPI). Most of our usages of SVGs are for icons used in buttons that already configured for accessibility and the SVG doesnāt need to be focusable or explained to the non visual user.
It would at the least be nice if we could
opt-out
of this default behavior, I noticed we do parse thesvgProps
but since thatās a spread/merge it wont override if we setrole
to undefined to attempt to unset it.While not breaking code-wise, this feels like a breaking change in terms of behavior.
I agree with @pachuka, it wouldāve been nice to be able to opt-out of this behaviour. Our use-case is the same and the vast majority of SVGs used in our project are icons or presentational only. Could almost argue that all SVG should be set to
role=presentational
instead and then give the option to set it toimg
where needed.