fix(desktop): bind Tailwind dark variant to the theme class#2849
Open
oscarjpicazo wants to merge 1 commit into
Open
fix(desktop): bind Tailwind dark variant to the theme class#2849oscarjpicazo wants to merge 1 commit into
oscarjpicazo wants to merge 1 commit into
Conversation
Tailwind v4's dark: variant defaults to the prefers-color-scheme media query, but the app's ThemeProvider drives theming by setting .dark/.light on <html>. Without a @custom-variant binding, all dark: utilities followed the OS appearance instead of the selected theme: picking an explicit light theme while the OS is in dark mode (or vice versa) rendered mixed styling, e.g. the composer's dark glass treatment over a light theme. Bind dark: to the theme class in both Tailwind entry points (desktop and web). The desktop's synchronous theme bootstrap in index.html already guarantees the class exists before first paint. Signed-off-by: oscarjpicazo <n.oscarjuanpicazo@gmail.com>
oscarjpicazo
force-pushed
the
fix/tailwind-dark-variant-theme-class
branch
from
July 25, 2026 14:57
5b9a0a9 to
619f3fa
Compare
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.
Fixes #2848
What problem this solves
The app themes itself by class —
ThemeProvidersets.dark/.lighton<html>, seeded before first paint by the synchronous bootstrap indesktop/index.html. But on Tailwind v4 thedark:variant defaults to theprefers-color-schememedia query, and nothing in the repo rebinds it: the@config-loadedtailwind.config.jshas nodarkModekey and there is no@custom-variantdeclaration.So the 127
dark:utilities indesktop/src(and 166 inweb/src) followthe OS appearance while every CSS-variable style follows the selected
theme. Pinning a light theme with the OS in dark mode (or the reverse)
renders mixed styling — e.g. the composer's dark glass treatment
(
dark:bg-background/70 dark:backdrop-blur-xl) over a light theme.How it was implemented
One
@custom-variantline (plus a comment) in each Tailwind entry point:desktop/src/shared/styles/globals.cssweb/src/shared/styles/globals.cssThis is Tailwind v4's canonical way to switch
dark:to class-driven darkmode.
:where()keeps specificity at zero, so no existing selector wins orloses against other rules — the only change is when
dark:applies.Both entry points are fixed in one PR because it is one logical defect (the
missing variant binding) in the two places the same pattern exists. The web
client's
ThemeProvidersets the same class; today it always resolves"system" in production, so this is a latent correctness fix there rather than
a visible behavior change.
How to test it manually
theme. Before: composer/header/settings surfaces show dark-mode treatments.
After: fully light rendering.
dark:styling neverapplies. After: dark treatments apply.
query agree by construction).
Compiled-CSS verification: building
globals.csswith the repo config(Tailwind CLI 4.3.x) previously emitted every
dark:utility inside@media (prefers-color-scheme: dark); after this change zeroprefers-color-schemeoccurrences remain and utilities compile to.dark\:…:where(.dark, .dark *).Why no automated test
The defect lives in the Tailwind build's variant expansion, not in runtime
code — asserting it would mean compiling the stylesheet and string-matching
generated CSS, which pins Tailwind's output format rather than app behavior.
The compiled-CSS before/after above documents the verification performed.
Regression audit performed
Every
dark:usage was audited against the new binding:WebviewWindowBuilderanywhere), so theindex.htmlbootstrap covers allfirst paints. Web's
ThemeProviderapplies the class synchronously insideits
useStateinitializer and is the outermost rendered node, so nothingpaints before the class exists.
data-system-color-scheme+.buzz-onboarding-neutral-theme) contain nodark:utilities, so they areunaffected.
darkclass(
shared/ui/markdown.tsxlightbox,shared/ui/VideoPlayer.tsxreviewoverlay) now get
dark:utilities active inside them — which is what theirown stylesheet documents as intended (
globals/video-review.css: "theshadcn neutral dark palette regardless of the app theme"). Before this fix
those overlays were internally inconsistent (dark variables, OS-driven
utilities).
@media (prefers-color-scheme)and no@apply dark:exists,so there is nothing left half-bound.
pinned to "system", so class ⟺ media query), and it makes the dev-only
?previewTheme=override actually preview correctly.Follow-up deferred
web/index.htmlcould seed the theme class before first paint likedesktop/index.htmldoes — defense in depth for whenever web exposes its(currently unmounted)
ThemeToggle.globals/components.cssnoting that.buzz-onboarding-neutral-themesubtrees should use semantic variables,not
dark:utilities, since those surfaces intentionally follow the OS.