SVG attributes and ARIA attributes with different pattern
See original GitHub issueI have the following JSX sample, which is a SVG element:
<svg className={className} viewBox="0 0 48 48" version="1.1"
onClick={this.props.onClick} aria-label="Some random label">
<g fill="none">
<line strokeWidth="2" x1="24" y1="14" x2="24" y2="34"/>
<line strokeWidth="2" x1="14" y1="24" x2="34" y2="24"/>
</g>
</svg>
In raw HTML strokeWidth
is represented as stroke-width
. It seems to me that all JSX attributes follow the camel-case format. So, I immediately thought on adding ariaLabel
instead of aria-label
.
Question: Is there a pattern for JSX attributes? If yes, why aria-*
does not follow this pattern?
In fact, I like the idea of having stroke-*
so that I don’t have to preprocess my raw svg to reactjs.
I understand that this could be the expected behavior, but I’m just trying to understand why the patterns are different for aria and svg.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Using ARIA to enhance SVG accessibility - TPGi
It is possible to enhance the information exposed through the browser accessibility APIs with a handful of ARIA attributes.
Read more >Accessible SVGs: Perfect Patterns For Screen Reader Users
This article outlines twelve distinct SVG patterns found “in the wild” and each alternative description announced when accessed by different ...
Read more >SVG Accessibility/ARIA roles for charts - W3C Wiki
A graphical object that represents specific data values. Elements with a role that inherits from graphics-data can be annotated with various data-related ......
Read more >Accessible SVGs | CSS-Tricks
Scalable Vector Graphic (SVG) is emerging as the preferred graphic format to use on ... All <img> tags need the alt attribute to...
Read more >SVG Elements and Attributes - O'Reilly Design System
A unique identifier for distinguishing this element from all other elements in the document. Used in SVG element cross-references, link targets, the JavaScript ......
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 Free
Top 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
Hi, related to this issue I’m trying to use a SVG with aria-* attributes as a component and React is complaining about unknown props on <svg> tag:
Looking at the docs it seems both
role
andaria-*
attributes are not allowed on SVG, but to enhance accessibility they’d be a good practice.Right now my workaround is to use
dangerouslySetInnerHTML
but that’s not ideal.Hi,
My bad! I investigated further the issue and I’ve found this issue. Looks like is something related to the loader I’m using.
Sorry!