-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Accessibility improvement / tooltip support #67
Comments
I'd also be a big supporter of this! An option would also be to allow passing |
Is it possible to confirm if support for title / desc / aria-labelledby is planned? We have started using react-feather-icons but as a11y is a hard requirement for us; without this we may have to explore other accessible versions instead. Be grateful for any info / guidance on this |
I believe attributes such as import { Trash } from "react-feather";
const Component = () => {
return (
<Trash title="Delete" />
);
}; Additional child elements don't, however. |
I'm using TS in my project, trying the above gives: |
That might be a problem indeed. The list of allowed attributes and types can be found here: Lines 4 to 7 in c9698fa
and here: Unfortunately, this library doesn't seem to be actively maintained, so if you want a response you might try the fork, Lucide Icons |
I dug into the above types some more. The type of |
Another way I added a tooltip to those icons is by wrapping them in a |
In case you're here wondering how to add the tooltip-text, I did what Ikapoura suggested, I added a span wrapping my icon component like here:
|
I confirm @rupeshbhatti suggestion, an accessible way to do is to add directly an import { Trash } from "react-feather";
const Component = () => {
return (
<Trash aria-label="Delete" />
);
}; The label is attached to the graphic element by the screen reader, which is what we expect: In other aforementioned solutions, a label is added but the graphic element itself is still considered as not being described/labed. |
I have been using react-feather for a lot of my internal administration apps over the last year or so. It's very straight forward to work with and works well on all the devices that I develop for. Lately, we have been doing an accessibility audit on some of the applications and one of the things came up is the fact that when icons are used as "buttons" they are missing "alt text" / helpful info on what will happen.
I have been reading up on what seems to be the common way to achieve this with the inline SVGs as those react-feather produces. The most common option seems to be using a <title>-tag inside the element with the alt text that you want to show. I would love it if it was possible to set the "alt" attribute (like that used for
If the user does not specify the alt attribute, the icon should render as it always has to make sure it's backward compatible.
If the alt attribute is specified, I imagine that using, for example, the File icon like this:
<File alt="Navigate to report" />
should produce HTML along the following, the change being the <title>-tag inserted:
This will allow Chrome to display a tooltip when you mouse over the icon, just like the alt text of img tags:
Do you think this sounds like a reasonable change?
The text was updated successfully, but these errors were encountered: