Skip to content

How to add aria-label in Menu.Button #495

Answered by RobinMalfait
yudyananda asked this question in Help
Discussion options

You must be logged in to vote

Hey! Thank you for your suggestion!
Much appreciated! 🙏

You should be able to just add aria-label to the Menu.Button, but keep in mind that adding aria-label means that the contents becomes unreadable. So if you at one point at actual text next to your icon, then that won't be "visible" to screenreader users.

Another and preferred solution is to do something like this:

<Menu.Button>
  <svg />
  <span class="sr-only">User actions</span>
</Menu.Button>

Where you add an element that is marked with the sr-only class. This makes it invisible visually, but keeps it for screen readers. Checkout: https://tailwindcss.com/docs/screen-readers for more information,

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yudyananda
Comment options

Answer selected by yudyananda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants