markteekman / accessible-astro-components

A set of Accessible, easy to use, Front-end UI Components for Astro.

Home Page:https://accessible-astro.netlify.app/accessible-components/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dark Mode Button - Changing accessible name

garyb1 opened this issue · comments

As it stands the button toggles from aria-pressed="false" and aria-label="Enable dark mode" to aria-pressed="true" and aria-label="Disable dark mode" but we should not change the accessible name content.

References:

  1. Hidde De Vries How I built a dark mode toggle

For toggle buttons, it is important that the content doesn't change. As the button text, I have used “Toggle dark mode”. If we would update the label of the button from “Turn on light” to “Turn on dark”, we kind of have a toggle (as MDN suggests), but that way, it wouldn't be recognised by the browser and set in the accessibility tree to be a toggle, and, because of that, not announced as a toggle by screenreaders.

Resolution:
Leave the aria-label as "Toggle Dark Mode"