Flip a Toggle Switch
Write the code, see it run, pass the checks.
The problem
- easy
- Code
Build a dark mode switch: a button with role="switch" named "Dark mode", with aria-checked="false" while it's off and aria-checked="true" while it's on, and a line under it reading "Dark mode is off" or "Dark mode is on". It starts off. Clicking it flips it, and so does pressing Space while it has focus.
Your code must pass
- It starts off
- Clicking turns it on and off again
- Space flips it from the keyboard