GithubHelp home page GithubHelp logo

Comments (7)

rektdeckard avatar rektdeckard commented on April 19, 2024 2

Noted! Though, as our library docs mention, any and all valid SVG attributes you add to an icon will be applied to the rendered DOM node, so the real solution for you to just add that attribute to the icon yourself. Our title fix was specifically a convenience to address <svg> elements not respecting this attribute in the same way that HTML elements do, IE will not show a native tooltip on hover.

<House size={32} aria-label="An icon of a house" />

This will do you right. If you want both a tooltip and aria-label, add both, using alt for the title. Working example.

from react.

rektdeckard avatar rektdeckard commented on April 19, 2024 1

That's a good shout-out. We'll add this to the upcoming 2.0 release. Thanks @brandonleboeuf!

from react.

brandonleboeuf avatar brandonleboeuf commented on April 19, 2024 1

Thank you!

I think having the alt prop makes it feel like an <img> rather than an<svg> element, which would also make me think that the alt text would be all that's needed vs adding the aria-label?

It would be nice to have aria-label? added to Props section of the readme.md so that it eliminates that confusion since the docs currently state that the alt prop will "add accessible alt text to an icon".

from react.

rektdeckard avatar rektdeckard commented on April 19, 2024 1

This is good by me 👍

from react.

rektdeckard avatar rektdeckard commented on April 19, 2024

Wait, it looks like this attribute is for use when the element is labeled by visible text, which is not the case with icons. Are you sure there is an accessibility concern? I am pretty sure the <title> element achieves the desired effect for screen readers.

from react.

brandonleboeuf avatar brandonleboeuf commented on April 19, 2024

Good catch @rektdeckard ! I did mean aria-label, not aria-labelledby.

It is needed, as the icons are currently being skipped by the screen reader, even when there is something passed via the phosphor alt prop. As a work around, I have been adding a wrapper div with the aria-label around any phosphor icon that needs to be read by the screen reader.

From MDN on the title not being read by screen readers: "Text in a <title> element is not rendered as part of the graphic, but browsers usually display it as a tooltip. If an element can be described by visible text, it is recommended to reference that text with an aria-labelledby attribute rather than using the <title> element."

Though, looking at aria-labelledby, it does state to use aria-label instead if there is no visible text to reference, as you pointed out.

from react.

benface avatar benface commented on April 19, 2024

I am a bit confused by the resolution here. What is the point of the alt prop if it's not to provide an accessible label to screen readers? 🤔 I feel pretty strongly that it should set aria-label on the <svg>, not a <title> (which is accessible in some browsers but not all, e.g. Safari based on my tests). Would you please reconsider @rektdeckard? 🙏 Happy to submit a PR.

from react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.