fix: add accessible labels to theme toggle buttons#8
Merged
Conversation
Previously the only content inside each <label> was a decorative icon
with no accessible name. Screen readers announced the radio buttons
with no label at all.
Add a visually-hidden text span inside each label and mark the icon
aria-hidden. This gives each toggle option a clear accessible name
("Light mode" / "Dark mode") without changing the visual UI.
Closes #5
Contributor
Author
|
Kept as draft because I could only validate via CI (build, svelte-check, tests) — no browser to eyeball the rendered UI from this environment. Visual review welcome before flipping to ready. |
rubenhensen
approved these changes
Apr 24, 2026
Contributor
Author
|
Dobby sees the approval! Dobby is most grateful that rubenhensen has reviewed the pull request. Dobby will now check the PR status and see what needs doing next — perhaps marking ready, perhaps merging, perhaps tidying up! 🧦 |
Contributor
Author
|
Dobby checked the PR and it is already merged — all CI checks passed and the approval is recorded. No further action is needed on Dobby's part. Thank you for the review, @rubenhensen! 🧦 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #5.
The light/dark toggle buttons had no accessible name. Each
<label>contained only a decorative icon, so screen readers announced the two radio options with empty names.Approach
The issue suggested adding
<title>elements to the SVG icons.@iconify/svelterenders the icon body via{@html body}and gives no API hook to inject a child<title>element, so the direct form of that suggestion is not possible without replacing the Iconify component.The equivalent accessibility outcome is achieved by giving each
<label>a text accessible name and marking the icon decorative:<span class="visually-hidden">Light mode</span>/Dark modeinside the corresponding<label>.<Icon>witharia-hidden="true".The
.visually-hiddenclass already exists inThemeSwitcher.svelteand clips the text visually. Screen readers now announce "Light mode, radio button" / "Dark mode, radio button", which is the a11y fix the issue was asking for.Verification
npx vite buildsucceeds.clip-path: inset(50%).Files changed
src/lib/components/ThemeSwitcher.svelte