Skip to content

Commit e9c0ea5

Browse files
unLiebclaude
andcommitted
Fix bg-back/bg-front staying dark outside dark theme
--color-front/--color-back are declared once in the @theme block, which Tailwind evaluates at :root. data-theme is only ever set on <body>, so :root never matches a [data-theme] rule and the two colors permanently resolve to their @theme fallback (the dark theme's values) regardless of the active theme. Invisible in dark mode since the fallback happens to match it; every other theme silently kept a dark bg-back/bg-front (most visible on the checklist detail page, where bg-back is applied at full opacity to the whole article). Redeclare --color-front/--color-back inside each [data-theme] block so they're recomputed at the element the attribute selector actually matches. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 3e29850 commit e9c0ea5

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

src/styles/tailwind.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,72 +16,111 @@
1616
@source inline("{checked:,hover:}checkbox-{info,success,neutral,warning,error}");
1717
@source inline("hover:bg-{info,success,neutral,warning,error}");
1818
19+
/*
20+
* --color-front/--color-back are registered in the @theme block above, which
21+
* Tailwind v4 evaluates at :root (<html>). data-theme, however, is only ever
22+
* set on <body> (see root.tsx / theme-store.ts), so :root never sees a
23+
* matching [data-theme="..."] rule and --color-front/--color-back permanently
24+
* resolve to their @theme fallback (the dark values) no matter which theme is
25+
* active. That's invisible in dark mode, since the fallback happens to match
26+
* it, but every other theme silently keeps a dark bg-back/text-front. Each
27+
* block below redeclares --color-front/--color-back at the same element the
28+
* attribute selector actually matches, so they pick up that theme's colors.
29+
*/
1930
[data-theme="light"] {
2031
--front: 237 9% 86% / 0.75;
2132
--back: 237 9% 86% / 1;
33+
--color-front: hsl(var(--front));
34+
--color-back: hsl(var(--back));
2235
}
2336

2437
[data-theme="dark"] {
2538
--front: 217 14% 17%;
2639
--back: 212 14% 10%;
40+
--color-front: hsl(var(--front));
41+
--color-back: hsl(var(--back));
2742
}
2843

2944
[data-theme="night"] {
3045
--front: 220 45% 9%;
3146
--back: 219 38% 13%;
47+
--color-front: hsl(var(--front));
48+
--color-back: hsl(var(--back));
3249
}
3350

3451
[data-theme="cupcake"] {
3552
--front: 297 77% 90%;
3653
--back: 303 60% 94%;
54+
--color-front: hsl(var(--front));
55+
--color-back: hsl(var(--back));
3756
}
3857

3958
[data-theme="bumblebee"] {
4059
--front: 76 40% 87%;
4160
--back: 60 23% 92%;
61+
--color-front: hsl(var(--front));
62+
--color-back: hsl(var(--back));
4263
}
4364

4465
[data-theme="corporate"] {
4566
--front: 212 44% 84%;
4667
--back: 212 26% 90%;
68+
--color-front: hsl(var(--front));
69+
--color-back: hsl(var(--back));
4770
}
4871

4972
[data-theme="synthwave"] {
5073
--front: 253 58% 12%;
5174
--back: 254 48% 17%;
75+
--color-front: hsl(var(--front));
76+
--color-back: hsl(var(--back));
5277
}
5378

5479
[data-theme="retro"] {
5580
--front: 42 37% 72%;
5681
--back: 43 36% 87%;
82+
--color-front: hsl(var(--front));
83+
--color-back: hsl(var(--back));
5784
}
5885

5986
[data-theme="valentine"] {
6087
--front: 320 71% 85%;
6188
--back: 322 61% 94%;
89+
--color-front: hsl(var(--front));
90+
--color-back: hsl(var(--back));
6291
}
6392

6493
[data-theme="halloween"] {
6594
--front: 0 0% 9%;
6695
--back: 0 0% 17%;
96+
--color-front: hsl(var(--front));
97+
--color-back: hsl(var(--back));
6798
}
6899

69100
[data-theme="aqua"] {
70101
--front: 231 41% 27%;
71102
--back: 231 34% 23%;
103+
--color-front: hsl(var(--front));
104+
--color-back: hsl(var(--back));
72105
}
73106

74107
[data-theme="lofi"] {
75108
--front: 228 12% 92%;
76109
--back: 228 12% 92% / 0.75;
110+
--color-front: hsl(var(--front));
111+
--color-back: hsl(var(--back));
77112
}
78113

79114
[data-theme="fantasy"] {
80115
--front: 231 34% 23%;
81116
--back: 210 2% 83%;
117+
--color-front: hsl(var(--front));
118+
--color-back: hsl(var(--back));
82119
}
83120

84121
[data-theme="dracula"] {
85122
--front: 210 2% 83% / 0.03;
86123
--back: 228 20% 15%;
124+
--color-front: hsl(var(--front));
125+
--color-back: hsl(var(--back));
87126
}

0 commit comments

Comments
 (0)