Skip to content

fix: scope tailwind dark mode to .class - #20

Merged
hovanhoa merged 1 commit into
mainfrom
fix/darkmode-class
Jun 9, 2026
Merged

fix: scope tailwind dark mode to .class#20
hovanhoa merged 1 commit into
mainfrom
fix/darkmode-class

Conversation

@hovanhoa

@hovanhoa hovanhoa commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Add `darkMode: 'class'` to `tailwind.config.js`.

Why

Tailwind's default is `darkMode: 'media'`, which makes every `dark:` utility track the user's OS `prefers-color-scheme` instead of the `.dark` class set by the in-page theme toggle. On a system in OS-dark mode, toggling the site to "light" left the cream body background visible (CSS rule scoped to `.dark body`) but `dark:*` Tailwind utilities stayed on, producing washed-out / inverted text.

Test plan

  • In OS-dark mode, toggle the site to light — verify body background and text both flip to light styling.
  • In OS-light mode, toggle to dark — verify both flip to dark.
  • Spot-check that any `dark:`-prefixed utilities respond only to the toggle.

🤖 Generated with Claude Code

Tailwind defaults darkMode to 'media', which makes every dark: variant
react to the user's OS preference rather than the in-page theme
toggle. Combined with the .dark class set by the toggle, this caused
inverted state: light-cream body background but dark-mode utilities
still active.

Pin darkMode to 'class' so dark: variants only activate when the
toggle sets .dark on <html>, matching the rest of the design-token
system.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gallery.hovanhoa.net Ready Ready Preview, Comment Jun 9, 2026 4:56pm

@hovanhoa
hovanhoa merged commit 7203bd3 into main Jun 9, 2026
2 of 3 checks passed
@hovanhoa
hovanhoa deleted the fix/darkmode-class branch June 9, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant