Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dark Mode Toggle: Add Role #72

Closed
0xTheProDev opened this issue Dec 13, 2023 · 1 comment
Closed

Dark Mode Toggle: Add Role #72

0xTheProDev opened this issue Dec 13, 2023 · 1 comment

Comments

@0xTheProDev
Copy link

https://github.com/markteekman/accessible-astro-components/blob/ea8f2426c38607b61f7e99c203513eaaf47a61f4/DarkMode.astro#L5
Should this button have switch role?

@markteekman
Copy link
Member

@0xTheProDev, thanks for submitting the issue! There are certainly more ways to approach this (as it is with many things in accessibility!). This button uses the approach of Hidde de Vries which was recently updated thanks to @garyb1 #68. 🙂

In this case, we're using a standard button element, which exists in HTML. But there is one detail about it that doesn't exist in HTML, which is that this is the type of button that toggles. We can add this by setting the aria-pressed with a "true" or "false" value.

This brings a known benefit to end users, specifically to users of screenreaders, who will now hear this is a toggle button. For toggle buttons, it is important that the content doesn't change. As the button text, I have used “Toggle dark mode”.

More on it here: https://hidde.blog/dark-light/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants