feat: add dark mode#1343
Draft
Brett-Best wants to merge 1 commit into
Draft
Conversation
Open
Member
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.

Important
This draft is explicitly an AI-driven experiment exploring dark mode as an accessibility improvement. The implementation, tooling research, browser checks, APCA comparison, and initial code review were AI-assisted. It is not a claim of WCAG or APCA compliance, and it should receive human accessibility and design review before being considered ready.
Problem
Addresses #974.
The docs currently provide only a light appearance. Dark mode can reduce discomfort for people who are sensitive to bright interfaces or who browse in low-light environments, but adding it here is more involved than enabling a MkDocs setting.
Why this needs a custom approach
MkDocs' native
color_modeanduser_color_mode_toggleoptions apply only to its built-inmkdocstheme. This site uses a substantially customizedreadthedocstheme instead, including a forked base template, RTD-specific.wy-*and.rst-contentstyling, custom navigation, Algolia DocSearch, plugin-quality pages, and project-specific components.The earlier discussion in #974 and the unfinished Material-theme migration in #696 illustrate the tradeoff: switching themes to gain a built-in toggle would mean reworking the site's existing templates and thousands of lines of theme-specific CSS. It would be a broad redesign rather than a contained accessibility experiment.
This draft therefore keeps the current theme and adds color-mode support around its existing structure. That requires handling several pieces explicitly:
Auto/Light/Darkchoice and react to live system changesWhat changed
No documentation routes or navigation entries were changed in
mkdocs.yml; it only registers the new CSS and JavaScript assets.Accessibility and browser validation
This was evaluated as an experiment rather than certified as compliant:
prefers-color-schemechanges, Algolia search, code blocks, tables, admonitions, plugin-quality pages, and print renderingThe APCA comparison found contrast parity with the existing light theme: 17 unique failing dark-mode style clusters versus 14 pre-existing light-mode clusters, with a similar minimum contrast around Lc 51. The remaining dark clusters are primarily muted secondary text, GitHub's shipped dark syntax palette, and link colors; their light-theme counterparts also fall below the same bronze thresholds. No dark-mode regression was identified, but these results should not be interpreted as formal compliance.
Repository checks
bundle exec fastlane testnode --check docs/js/color-mode.jsgit diff --check upstream/master...HEADMaintenance notes
The small inline head script intentionally duplicates the storage key and valid preference values from
color-mode.js; this prevents a flash of the wrong theme, but those values must remain synchronized.The CSS is deliberately comprehensive because it sits on top of a heavily customized legacy theme. A possible follow-up would extract more of the existing light-theme colors into semantic tokens and use dedicated per-mode syntax-highlighting stylesheets, which would reduce the number of targeted overrides over time.
Human review is especially welcome on accessibility priorities, palette choices, and whether this incremental approach is preferable to a future full theme migration.