maxeth / react-type-animation

A React typewriter animation based on typical with extended functionality and customization.
https://react-type-animation.netlify.app/
MIT License
353 stars 25 forks source link

Forward role attribute #35

Closed openscript closed 9 months ago

openscript commented 11 months ago

Thank you for your work on this package!

I've followed your accessibility guide and added a aria-label. If we add an aria-label also a role should be added:

image

So I suggest to also accept a role prop and forward it to the created wrapping element.

maxeth commented 11 months ago

Hey,

I don't think setting an aria-label is the optimal solution, because – as your error message suggests — it's intended to be used on interactive elements that are supposed to be accessible via assistive technologies.

Since such an animation is for decorative purposes and has 0 interaction, I think the only proper role for it would be "presentation", and in that case, all ARIA semantics will be automatically removed from the element, including aria-label, similarly to just setting a css display none.

So if you set an aria-label, it would contradict with setting the component's true role "presentation", since this role erases the meaning of the aria-label.

At this point I'd just go with the visually-hidden class if you want to get rid of the lighthouse warnings.


Regarding your feature request: Which role do you think would be meaningful for this component? If it's presentation or none, then passing the role prop would do nothing as described above.

maxeth commented 9 months ago

Added in react-type-animation@3.2.0.