Repository navigation
feat: support scoping the dark: variant to a root selector in tailwindCompiler - #1608
Merged
chrisschnaars merged 1 commit intoSep 3, 2026
Merged
Conversation
β¦dCompiler Mirrors when-color-mode-dark($root) (added in #1596) for Tailwind-styled MDX content: the dark: custom-variant currently matches [darkModeDataAttribute=dark] on any ancestor, which bleeds when a page has two independent data-color-mode scopes (e.g. readme's SuperHub admin shell vs. the hub content it's previewing). darkModeRootSelector, when supplied, scopes dark: to that root's own attribute instead. Omitted, behavior is unchanged. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
| Filename | Overview |
|---|---|
| utils/tailwind-compiler.ts | Adds the optional root selector to dark-variant generation while retaining the previous unscoped selector when omitted. |
| components/TailwindStyle/index.tsx | Exposes and forwards the new selector option and recompiles when it changes. |
| tests/utils/tailwind-compiler.test.ts | Verifies scoped, fallback, and disabled custom-variant strings. |
| tests/components/TailwindStyle.test.tsx | Verifies that TailwindStyle forwards both dark-mode options to the compiler. |
Reviews (1): Last reviewed commit: "feat: support scoping the dark: variant ..." | Re-trigger Greptile
chrisschnaars
deleted the
chrisschnaars/tailwind-dark-mode-root-selector
branch
September 3, 2026 15:22
rafegoldberg
pushed a commit
that referenced
this pull request
Sep 3, 2026
Collaborator
This PR was released!π Changes included in v15.4.0 |
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
tailwindCompiler/TailwindStyleaccept a newdarkModeRootSelectoroption. When supplied, the generateddark:custom-variant is scoped to that root's own[darkModeDataAttribute], self or descendant, instead of matching the attribute on any ancestor.when-color-mode-dark($root)(styles/mixins/when-color-mode-dark.scss, added in feat: update dark mode mixinΒ #1596) β same rationale: a page can have two independentdata-color-modescopes (e.g. readme's SuperHub admin shell vs. the hub content it's previewing), and the current ancestor-matching selector can't tell them apart. No default root selector is provided, for the same reasonwhen-color-mode-darkdoesn't have one β see that mixin's doc comment, and the new doc comment ontailwindCompiler'sdarkModeRootSelectorparam, for the full reasoning.Test plan
__tests__/utils/tailwind-compiler.test.ts(new) β unit-tests the generated@custom-variant dark (...)string directly (spies ontailwindcss.compilesince the real compile pipeline needs this package's production string-import loaders, which aren't wired into vitest β same reason the existingTailwindStyle.test.tsxmockstailwindCompilerrather than exercising real output)__tests__/components/TailwindStyle.test.tsxβ new case confirmingdarkModeRootSelectorthreads through totailwindCompilernpx vitest runon both files β 9/9 passingnpx eslintβ cleannpx tsc --noEmitβ no new errorsπ€ Generated with Claude Code