Repository navigation
feat(ui): declare color scheme and add forced-colors fallbacks - #22577
Open
slick-daddy wants to merge 1 commit into
Open
slick-daddy wants to merge 1 commit into
slick-daddy wants to merge 1 commit into
Conversation
slick-daddy
marked this pull request as ready for review
November 19, 2026 02:28
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.
Why
Lichess has no
forced-colorssupport, nocolor-schemedeclaration, and nofont-size-adjust. This adds all three so high-contrast users get readable colors, native controls match the chosen theme, and text stays stable when Noto Sans loads.What changed
<meta name="color-scheme" content="light dark">to the shared page head.color-scheme: light darkon:rootandcolor-scheme: lightonhtml.light.@media (forced-colors: active).font-size-adjust: from-fontto thehtmlfont rule.Scope
Lichess lets users pick system, light, or dark themes, and OS preference only drives the theme in system mode. A bare
light darkdeclaration would let the OS pick native control colors even when a user chose a different Lichess theme. That flips scrollbars and form controls to dark for light-theme users on a dark OS. Thehtml.lightoverride prevents that. Users who pick dark keep the existing scoped input override in_form.scss.The forced-colors block names each theme class explicitly.
html.lightoutranks:root, so a:root-only override would not apply to light themes. Existing scopedcolor-schemerules for inputs, boards, date pickers, and the PayPal iframe stay as they are.No tests were added. These are declarative CSS and meta changes that need visual verification under a high-contrast OS setting and with both light and dark themes.
Modern Web Guidance
color: I mapped text, background, border, link, and primary tokens toCanvasText,Canvas,LinkText, andHighlight, and leftforced-color-adjustalone. The guide says "Define system color fallbacks for color tokens using@media (forced-colors: active)", which keeps native high-contrast colors without preserving aesthetics at the cost of readability.dark-mode: I added both the head meta tag and the root declaration, then pinnedhtml.lightso UA surfaces follow the chosen theme. The guide requires "MANDATORY: Apply color-scheme to :root or html for viewport-wide theming", and the pin avoids a regression for users whose site theme differs from their OS.visually-stable-font-fallbacks: I putfont-size-adjust: from-fontonhtmlso every descendant inherits it. The guide marks it "MANDATORY: Normalize the font size based on the primary font's x-height", which prevents layout shift while the local Noto Sans font loads.AI assistance
AI-assisted with OpenCode.