@codenhub/styles 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +7 -7
  2. package/dist/aesthetics/chunky-tile.css +1 -1
  3. package/dist/aesthetics/cyber.css +1 -1
  4. package/dist/aesthetics/glass.css +1 -1
  5. package/dist/aesthetics/index.css +1 -1
  6. package/dist/aesthetics/neobrutalism.css +1 -1
  7. package/dist/aesthetics/pixel.css +1 -1
  8. package/dist/aesthetics/sketch.css +1 -1
  9. package/dist/components.css +1 -1
  10. package/dist/index.css +1 -1
  11. package/dist/native.css +1 -1
  12. package/dist/palette.css +1 -1
  13. package/dist/theme.css +1 -1
  14. package/dist/tw/aesthetics/chunky-tile.css +39 -39
  15. package/dist/tw/aesthetics/cyber.css +16 -11
  16. package/dist/tw/aesthetics/glass.css +235 -10
  17. package/dist/tw/aesthetics/index.css +2 -1
  18. package/dist/tw/aesthetics/neobrutalism.css +23 -11
  19. package/dist/tw/aesthetics/pixel.css +18 -8
  20. package/dist/tw/aesthetics/sketch.css +14 -7
  21. package/dist/tw/box.css +49 -27
  22. package/dist/tw/components/button.css +35 -14
  23. package/dist/tw/components/feedback.css +59 -56
  24. package/dist/tw/components/form.css +200 -126
  25. package/dist/tw/components/index.css +3 -7
  26. package/dist/tw/components/loader.css +4 -5
  27. package/dist/tw/components/surface.css +71 -68
  28. package/dist/tw/components/tooltip.css +75 -41
  29. package/dist/tw/elevation.css +14 -22
  30. package/dist/tw/index.css +15 -19
  31. package/dist/tw/intent.css +31 -24
  32. package/dist/tw/native.css +15 -5
  33. package/dist/tw/palette.css +8 -5
  34. package/dist/tw/presentation.css +16 -30
  35. package/dist/tw/reset.css +21 -28
  36. package/dist/tw/surface.css +11 -12
  37. package/dist/tw/theme.css +58 -86
  38. package/dist/tw/utilities/content.css +268 -199
  39. package/dist/tw/utilities/layout.css +15 -25
  40. package/docs/accessibility.md +50 -33
  41. package/docs/changelog/0.6.0.md +52 -0
  42. package/docs/changelog/index.md +1 -0
  43. package/docs/concepts.md +6 -6
  44. package/docs/index.md +9 -0
  45. package/docs/integrating/nextjs.md +1 -1
  46. package/docs/integrating/tailwind.md +14 -6
  47. package/docs/setup.md +6 -6
  48. package/docs/usage/aesthetics.md +35 -8
  49. package/docs/usage/buttons.md +1 -1
  50. package/docs/usage/composing.md +1 -1
  51. package/docs/usage/content-and-layout.md +12 -11
  52. package/docs/usage/customizing.md +8 -9
  53. package/docs/usage/feedback.md +5 -3
  54. package/docs/usage/forms.md +51 -35
  55. package/docs/usage/theming.md +39 -40
  56. package/docs/usage/tooltips.md +37 -17
  57. package/llms-full.txt +331 -183
  58. package/llms.txt +6 -0
  59. package/package.json +5 -5
@@ -7,21 +7,11 @@
7
7
  line at its boundary. Exactly one value from each set applies, so the six
8
8
  combinations are the whole vocabulary.
9
9
 
10
- A fill class never decides an edge and an edge class never decides a fill.
11
- `.solid` briefly broke that rule, writing `--ui-border: 0%` alongside its fill
12
- so that a filled box could not be ringed in another colour. It bought a real
13
- fix -- the edge blend runs the line toward the fill, which lands *on* the fill
14
- when the fill is opaque and on a second coat of the same tint when it is not,
15
- so every capped intent that drew a line drew a visible ring over its own plate
16
- -- at the cost of the one property that makes the six combinations readable:
17
- that each half means only what it says. Two axes that are independent in two
18
- cases out of three are not axes.
19
-
20
- The ring was a fault in the blend rather than in the class, and it was fixed
21
- there: the line fades toward `transparent` as the fill fills in, so a
22
- translucent plate shows through its own border as one coat (`box.css`;
23
- docs/internal/model.md#presentation). `.solid.edged` and `.solid.edgeless`
24
- render one box.
10
+ A fill class never decides an edge and an edge class never decides a fill, so
11
+ each half means only what it says. The line fades toward `transparent` as the
12
+ fill fills in (`box.css`; docs/internal/model.md#presentation), so
13
+ `.solid.edged` and `.solid.edgeless` render one box without either class
14
+ deciding the other's question.
25
15
 
26
16
  Presentation declares only unitless numbers and percentages. A custom
27
17
  property's value is resolved on the element that declares it, so anything
@@ -33,8 +23,8 @@
33
23
  container set the look for its subtree while any element still opts out.
34
24
 
35
25
  Hover is derived from these values rather than declared beside them:
36
- `min(100%, resting fill + --hover-step)`, always in `--intent-hover`. There is
37
- no hover token and no per-presentation branch. */
26
+ `min(100%, resting fill + --hover-step)`, always in `--intent-hover`. There
27
+ is no hover token and no per-presentation branch. */
38
28
 
39
29
  /* Filled with the intent color. Text is the contrast tone. */
40
30
  .solid {
@@ -48,11 +38,9 @@
48
38
  --ui-fg-on-fill: 0%;
49
39
  }
50
40
 
51
- /* No fill at rest; the derived hover gives it one. Text is the intent color.
52
-
53
- Named `.ghost` rather than `.bare` because `.bare` and `.edgeless` both read
54
- as "less of something", so an author wanting no border reached for `.bare`
55
- first and got no background instead. `.ghost` says fill and only fill.
41
+ /* No fill at rest; the derived hover gives it one. Text is the intent color. It
42
+ names a fill and only a fill: `.bare` and `.edgeless` both read as "less of
43
+ something", so an author wanting no border would reach for the wrong one.
56
44
 
57
45
  A component that rests on a ground rather than on nothing keeps that ground
58
46
  here: `.ghost` is zero fill, not zero paint. `.data-table` is the exception
@@ -62,16 +50,14 @@
62
50
  --ui-fg-on-fill: 0%;
63
51
  }
64
52
 
65
- /* A line in the intent color, at the aesthetic's material width. The width comes
66
- from the aesthetic and nothing else: there is no presentation scale on it, so
67
- small components need no ceilings to survive a thick one.
53
+ /* A line in the intent color, at the aesthetic's material width. The width
54
+ comes from the aesthetic and nothing else: there is no presentation scale on
55
+ it, so small components need no ceilings to survive a thick one.
68
56
 
69
57
  The edge is the silhouette and nothing else. Rules *inside* a component that
70
- has an inside are a separate decision with its own class -- `.data-table.ruled`
71
- -- because tying them here made them arrive by implication: a table drew rules
72
- only because its published edge default happened to be `edged`, so whether a
73
- consumer got them depended on a default they had not read and could not name.
74
- Two questions, two switches. */
58
+ has an inside are a separate decision with their own class --
59
+ `.data-table.ruled` -- so a consumer's own markup says whether they asked for
60
+ them. */
75
61
  .edged {
76
62
  --ui-border: 100%;
77
63
  }
package/dist/tw/reset.css CHANGED
@@ -3,13 +3,12 @@
3
3
  @import "./typography.css";
4
4
 
5
5
  @layer base {
6
- /* The package's own components no longer lean on this: `@utility box` sets
6
+ /* The package's own components do not lean on this: `@utility box` sets
7
7
  `box-sizing: border-box` on itself, so a sized control is right in every
8
8
  entrypoint including the reset-less `/components` and granular `/tw/*`
9
- ones. What is left for the universal rule is the consumer's own markup --
10
- a plain `<div>` laid out beside our components under the full reset -- so
11
- it stays part of the opinionated baseline the reset already is, rather
12
- than a correctness prop the components need. */
9
+ ones. The universal rule covers the consumer's own markup -- a plain
10
+ `<div>` laid out beside our components -- as part of the opinionated
11
+ baseline. */
13
12
  *,
14
13
  *::before,
15
14
  *::after {
@@ -52,12 +51,16 @@
52
51
  margin: 0;
53
52
  }
54
53
 
54
+ /* The whole font, not only the family: the user agent gives a button and a
55
+ field their own smaller size, so a `<button>`, a `.btn` link, and the
56
+ same `.btn` on another entrypoint each printed a different label size.
57
+ Tailwind's Preflight does the same on the entries that carry it. */
55
58
  button,
56
59
  input,
57
60
  optgroup,
58
61
  select,
59
62
  textarea {
60
- font-family: inherit;
63
+ font: inherit;
61
64
  }
62
65
 
63
66
  button,
@@ -72,9 +75,20 @@
72
75
  color: var(--color-primary-contrast);
73
76
  }
74
77
 
78
+ /* Negative, so the ring is drawn over the edge rather than beside it: at a
79
+ positive offset the outline floats a gap away and reads as a second,
80
+ detached frame around the control. Pulled in by exactly the line width the
81
+ aesthetic draws, the ring lands on top of the line and a focused control
82
+ reads as its own edge thickening -- which is what a focus indicator is
83
+ meant to look like. Computed here, on the focused element, because that is
84
+ where an aesthetic's `--ui-border-width` resolves; `--focus-ring-offset`,
85
+ when a consumer sets it, still wins.
86
+
87
+ A component drawing no line at rest loses nothing: the outline moves inward
88
+ over its own fill by a hairline, which is not a visible change. */
75
89
  :focus-visible {
76
90
  outline: var(--focus-ring-width) solid var(--focus-ring);
77
- outline-offset: var(--focus-ring-offset);
91
+ outline-offset: var(--focus-ring-offset, calc(-1 * var(--ui-border-width, var(--border-width))));
78
92
  }
79
93
 
80
94
  @media (forced-colors: active) {
@@ -127,24 +141,3 @@
127
141
  border-color: CanvasText;
128
142
  }
129
143
  }
130
-
131
- /* The user agent already promises both of these for a native `<dialog>` --
132
- `dialog:not([open]) { display: none }` and a centered `margin: auto` on the
133
- open box -- but both are user-agent origin, which loses to any author rule
134
- at all. `.card`'s own `display: block` (`surface`'s `@apply box block`)
135
- beats the first outright, so a `<dialog class="card">` renders open with no
136
- `open` attribute and no `.showModal()` call -- the registry has no
137
- dialog/modal component of its own, and `.card` is the closest primitive a
138
- consumer reaches for. A margin reset on every element -- Tailwind's own
139
- Preflight on the entries that carry it -- beats the second, so an opened
140
- dialog pins to the top-left instead of centering. Restated here, unlayered like
141
- the block above, for the same reason: a behavior override has to win over
142
- any layered rule whatever the specificity, and `.card` is layered in the
143
- utilities layer regardless of how it composes `box`. */
144
- dialog:not([open]) {
145
- display: none;
146
- }
147
-
148
- dialog[open] {
149
- margin: auto;
150
- }
@@ -22,14 +22,13 @@
22
22
  --_d-border: 100%;
23
23
 
24
24
  /* The public token first, so an aesthetic (glass's translucent ground) or a
25
- consumer names the ground outright; then the component's own quiet
26
- default, which `.card.soft`, a neutral `.panel`, and a neutral `.alert`
27
- write as a private rather than as the public token. Written as the public
28
- token, their own declaration beat glass's inherited one in a glass region,
29
- and once the aesthetics are layered below the components it beats glass
30
- on the same element too -- `.card.soft.glass` went opaque. Restated
31
- `initial` here so a quiet ground cannot inherit into a surface nested
32
- inside one, the way `box` restates `--_d-ground`. See
25
+ consumer names the ground outright; then the component's own quiet default,
26
+ which `.card.soft`, a neutral `.panel`, and a neutral `.alert` write as a
27
+ private rather than as the public token. Written as the public token, their
28
+ own declaration would beat glass's inherited one in a glass region, and
29
+ beat glass on the same element too (`.card.soft.glass` would go opaque).
30
+ Restated `initial` here so a quiet ground cannot inherit into a surface
31
+ nested inside one, the way `box` restates `--_d-ground`. See
33
32
  docs/internal/model.md#cascade-layers. */
34
33
  --_d-surface-ground: initial;
35
34
  --_d-ground: var(--ui-surface-ground, var(--_d-surface-ground, var(--color-background)));
@@ -47,16 +46,16 @@
47
46
  calc(var(--_corner-surface) * var(--ui-corner-tl, 1)) calc(var(--_corner-surface) * var(--ui-corner-tr, 1))
48
47
  calc(var(--_corner-surface) * var(--ui-corner-br, 1)) calc(var(--_corner-surface) * var(--ui-corner-bl, 1))
49
48
  );
50
- /* Prefixed property first, deliberately: written second the minifier folds the
51
- pair into the prefixed one alone, and the standard property never reaches
52
- `dist/` -- which drops the blur in Firefox (the one engine with
53
- `backdrop-filter` and not the `-webkit-` alias). Measured on the built CSS. */
54
49
  /* The painted layer: a pattern, a texture, or a gradient an aesthetic lays
55
50
  over the plate. Surfaces only, like the backdrop, so a control's label and
56
51
  `.select`'s chevron never sit on one. The aesthetic that sets it owns the
57
52
  contrast of the text over it, and a consumer's own `background-image` still
58
53
  beats this declaration. */
59
54
  background-image: var(--ui-surface-image, none);
55
+ /* Prefixed property first, deliberately: written second the minifier folds the
56
+ pair into the prefixed one alone, and the standard property never reaches
57
+ `dist/` -- which drops the blur in Firefox (the one engine with
58
+ `backdrop-filter` and not the `-webkit-` alias). Measured on the built CSS. */
60
59
  -webkit-backdrop-filter: var(--ui-backdrop, none);
61
60
  backdrop-filter: var(--ui-backdrop, none);
62
61
  }
package/dist/tw/theme.css CHANGED
@@ -35,30 +35,22 @@
35
35
  --color-accent-hover: light-dark(var(--color-neutral-700), var(--color-neutral-300));
36
36
  --color-accent-subtle: light-dark(var(--color-neutral-100), var(--color-neutral-800));
37
37
  --color-accent-strong: light-dark(var(--color-neutral-800), var(--color-neutral-200));
38
- /* Light was neutral-300 (1.42:1 against the page, already under 3:1 by the
39
- text-control comment below) until a `.card.soft.edged` measured its own
40
- border against its own fill rather than against the page: 12% of
41
- `--intent-color` mixed into the ground and a line resolving to nearly the
42
- same tone landed the two 4 RGB units apart, which reads as no boundary at
43
- all. Dark's neutral-700 pairing already separated -- 27 units, still under
44
- 3:1 but at least legible -- so only light moved. Neutral-400 is not a new
45
- number: `.chunky-tile` already measured it at 2.48:1 against the light
46
- page and picked it for the same reason, "the heaviest grey that still
47
- leaves a field legible." Dark is unchanged. */
38
+ /* Neutral-400 in light: the heaviest grey that still leaves a field legible
39
+ (2.48:1 against the page). A lighter line lands within a few RGB units of a
40
+ `.card.soft.edged`'s own fill and reads as no boundary. Dark's neutral-700
41
+ already separates (27 units). */
48
42
  --color-border: light-dark(var(--color-neutral-400), var(--color-neutral-700));
49
43
 
50
44
  /* A text control's line is the only thing identifying it: the box is
51
45
  transparent at rest, so nothing else marks where typing goes.
52
- `--color-border` is neutral-300/700 and measures 1.42:1 on the light page,
53
- which is a line you can barely see.
46
+ `--color-border` is the quiet surface line, too light for that.
54
47
 
55
- One value rather than a `light-dark()` pair, and that is the point: the page
56
- is neutral-50 in light and neutral-950 in dark, so a tone halfway between
57
- them reads on both grounds at once. A text control draws it at
58
- `--_line-rest` rather than whole, which is what keeps the field quiet while
59
- leaving the pointer somewhere to go -- so the line as painted lands under
60
- the 3:1 WCAG 1.4.11 asks of a control boundary. Recorded in
61
- docs/accessibility.md. */
48
+ One value rather than a `light-dark()` pair: the page is neutral-50 in
49
+ light and neutral-950 in dark, so a tone halfway between them reads on both
50
+ grounds at once. A text control draws it at `--_line-rest` rather than
51
+ whole, which keeps the field quiet while leaving the pointer somewhere to
52
+ go, so the line as painted lands under the 3:1 WCAG 1.4.11 asks of a
53
+ control boundary. Recorded in docs/accessibility.md. */
62
54
  --color-control-border: var(--color-neutral-500);
63
55
  --color-background: light-dark(var(--color-neutral-50), var(--color-neutral-950));
64
56
  --color-foreground: light-dark(var(--color-neutral-100), var(--color-neutral-900));
@@ -68,40 +60,30 @@
68
60
  --color-text-contrast: light-dark(var(--color-neutral-50), var(--color-neutral-950));
69
61
  --color-text-hover: light-dark(var(--color-neutral-700), var(--color-neutral-200));
70
62
  /* No `--color-text-subtle`: the neutral intent points `--intent-subtle` at
71
- `--color-surface`, not at a text-family tint, so the slot the other families
72
- fill had no reader here. */
63
+ `--color-surface`, not at a text-family tint. */
73
64
  --color-text-strong: light-dark(var(--color-neutral-900), var(--color-neutral-100));
74
65
 
75
- /* The tooltip bubble is the one component whose plate is chosen rather than
76
- derived. Everything else composes its ground from the intent, and for the
77
- bubble that produced the same 20% of the page's ink in both themes -- which
78
- steps *lighter* than the surface on a dark page and *darker* on a light one.
79
- Dark got the conventional reading, a floating thing lifted off its page;
80
- light got a mid-grey slab two steps darker than every card on the screen,
81
- carrying dark ink. Measured, the light bubble was neutral-400 at 2.01:1
82
- against the page while the dark one was 2.27:1 the other way.
66
+ /* The tooltip bubble's plate is chosen per theme rather than derived: 20% of
67
+ the page's ink over the surface tone steps lighter than the surface on a
68
+ dark page and darker on a light one, and one derivation cannot serve both
69
+ directions. Both ends read as lifted: near-white over a light page, a mid
70
+ grey over a dark one.
83
71
 
84
- One derivation cannot serve both directions, so the pair is stated. Both
85
- ends read as lifted: near-white over a light page, a mid grey over a dark
86
- one. Near-white is only 1.04:1 against the page, so the bubble draws a
87
- hairline as well -- see `components/tooltip.css`. */
72
+ Near-white is only 1.04:1 against the page, so the bubble draws a hairline
73
+ as well -- see `components/tooltip.css`. */
88
74
  --color-tooltip: light-dark(var(--color-white), var(--color-neutral-700));
89
75
  --color-tooltip-contrast: light-dark(var(--color-neutral-900), var(--color-neutral-100));
90
76
 
91
- /* Emerald-700 rather than 600. A filled button's label is normal-size text, so
92
- WCAG 1.4.3 asks 4.5:1, and white on emerald-600 measures 3.50:1 -- it passed
93
- only as large text, which `.btn` is not. One step darker carries the white
94
- label and leaves the hue where it was. */
77
+ /* Emerald-700 rather than 600: a filled button's label is normal-size text
78
+ (WCAG 1.4.3 asks 4.5:1), and white on emerald-600 measures 3.50:1. */
95
79
  --color-success: var(--color-emerald-700);
96
80
  --color-success-contrast: var(--color-neutral-50);
97
- /* Baked rather than mixed live. `box-hover` nests this token two `color-mix()`
98
- levels deeper to compose the fill and the edge, and three levels of
99
- `color-mix()` over a `light-dark()` crashes the WebKit renderer outright on
100
- hover. Confirmed on all four semantic intents, not only this one. Each
101
- pinned pair below is
102
- `color-mix(in srgb, <base> 82%, <strong>)`, resolved once per theme and
103
- screenshotted back so the blend stays exact; re-bake it if the base or
104
- strong tone it was mixed from changes. */
81
+ /* Baked rather than mixed live: `box-hover` nests this token two
82
+ `color-mix()` levels deeper to compose the fill and the edge, and three
83
+ levels of `color-mix()` over a `light-dark()` crash the WebKit renderer on
84
+ hover. Each pinned pair below is `color-mix(in srgb, <base> 82%,
85
+ <strong>)`, resolved once per theme; re-bake it if the base or strong tone
86
+ it was mixed from changes. */
105
87
  --color-success-hover: light-dark(#007552, #008e66);
106
88
  /* The dark ground is `-900` to make room for the `-300` ink above it. `-subtle`
107
89
  is what `kbd`, `code`, `pre` and the tooltip bubble rest on, and those are the
@@ -110,21 +92,16 @@
110
92
  WCAG 1.4.3 asks of normal text -- and the other three sat at 4.9 to 5.0 with
111
93
  no headroom. One step darker puts all four past 9:1. */
112
94
  --color-success-subtle: light-dark(var(--color-emerald-100), var(--color-emerald-900));
113
- /* The dark tone is `-300`, not `-100`. `-strong` is what a partial fill prints
114
- -- the label of a soft badge, the dot of a soft radio -- and on a dark page
115
- the `-100` shade of every hue is a pale tint that reads white at small
116
- sizes. The intent's colour survived only in the fill and the border, so a
117
- soft success badge and a soft destructive one had the same white label and a
118
- radio's dot stopped matching its own ring. `-300` keeps the hue and stays
119
- far above the contrast a mark or a label needs. Light keeps `-800`, which
120
- was never the problem: it is saturated and dark against a light page. */
95
+ /* The dark tone is `-300`, not `-100`: `-strong` is what a partial fill
96
+ prints -- the label of a soft badge, the dot of a soft radio -- and on a
97
+ dark page the `-100` shade of every hue is a pale tint that reads white at
98
+ small sizes. `-300` keeps the hue. Light keeps `-800`, which is saturated
99
+ and dark against a light page. */
121
100
  --color-success-strong: light-dark(var(--color-emerald-800), var(--color-emerald-300));
122
- /* Amber is the one family that cannot solve this by darkening. White on
123
- amber-600 measures 3.07:1, and the amber dark enough to carry white has
124
- stopped being amber -- it reads brown, which is not the colour a warning is
125
- supposed to be. So the ink moves instead of the hue: dark ink on amber is
126
- what a warning looks like nearly everywhere, and it is the only intent whose
127
- contrast tone is not the page colour. */
101
+ /* Amber cannot solve contrast by darkening: white on amber-600 measures
102
+ 3.07:1, and amber dark enough to carry white reads brown. So the ink moves
103
+ instead of the hue: dark ink on amber is what a warning looks like, and
104
+ warning is the only intent whose contrast tone is not the page colour. */
128
105
  --color-warning: var(--color-amber-600);
129
106
  --color-warning-contrast: var(--color-neutral-950);
130
107
  /* Same crash, same fix as `--color-success-hover` above. */
@@ -145,7 +122,6 @@
145
122
  --color-info-strong: light-dark(var(--color-indigo-800), var(--color-indigo-300));
146
123
 
147
124
  --breakpoint-xs: 30rem;
148
- --breakpoint-2xl: 90rem;
149
125
  }
150
126
 
151
127
  /* Tailwind only keeps a `@theme` variable in the compiled output when it
@@ -202,15 +178,11 @@
202
178
  --elevation-lg: 0 20px 25px -5px var(--elevation-color), 0 8px 10px -6px var(--elevation-color);
203
179
 
204
180
  --focus-ring: color-mix(in srgb, var(--color-primary) 64%, transparent);
205
- /* Negative, so the ring is drawn over the edge rather than beside it: at a
206
- positive offset the outline floats a gap away and reads as a second, detached
207
- frame around the control. Pulled in by exactly the material line width, the
208
- ring lands on top of the line and a focused control reads as its own edge
209
- thickening -- which is what a focus indicator is meant to look like.
210
-
211
- A component drawing no line at rest loses nothing: the outline moves one
212
- pixel inward over its own fill, which at a hairline is not a visible change. */
213
- --focus-ring-offset: calc(-1 * var(--border-width));
181
+ /* `--focus-ring-offset` is not declared: its default is the negative of the
182
+ line width of whatever is focused, which only the focused element knows,
183
+ so the outline computes it there -- see `reset.css`. Declared here it
184
+ resolved against the base 1px once and inherited, and under a 2px
185
+ aesthetic the ring covered half the edge and left a stripe of it inside. */
214
186
  --focus-ring-width: 3px;
215
187
 
216
188
  --motion-duration-fast: 120ms;
@@ -254,24 +226,24 @@
254
226
  }
255
227
 
256
228
  /* The first arm mirrors the `color-scheme: dark` block above, all three
257
- spellings included -- a consumer writing `.theme-dark` for the token theme
258
- was otherwise left without the matching `dark:` variant.
229
+ spellings included.
230
+
231
+ The second arm follows the OS preference. `--color-*` tokens resolve through
232
+ `light-dark()` against the computed `color-scheme`, so with no explicit
233
+ selector `:root`'s `color-scheme: light dark` already follows it -- see
234
+ `concepts.md#theme-selection`. A selector list cannot query computed style,
235
+ but it can match "OS prefers dark, and not under a forced-light subtree" with
236
+ a plain descendant exclusion: `:not(:where(.light, .light *, ...))` matches
237
+ only when no ancestor (or the element itself) carries one of the three light
238
+ spellings. The exclusion cannot see a subtree forced light by other means,
239
+ where `light-dark()` would still honor it; that is out of contract, since
240
+ those three spellings are the only supported way to force a theme.
259
241
 
260
- The second arm closes the gap that left open: `--color-*` tokens resolve
261
- through `light-dark()` against the computed `color-scheme`, so with no
262
- explicit selector at all `:root`'s `color-scheme: light dark` already
263
- follows the OS preference -- see `concepts.md#theme-selection`. A selector
264
- list cannot query computed style the way `light-dark()` does, but it can
265
- still match "OS prefers dark, and not under a forced-light subtree" with a
266
- plain descendant exclusion: `:not(:where(.light, .light *, ...))` matches
267
- only when no ancestor (or the element itself) carries one of the three
268
- light spellings. That is the one case the exclusion cannot see -- a
269
- subtree forced light through some means other than these three selectors,
270
- where `light-dark()` would still honor it but this variant could not
271
- detect it. Out of contract: those three spellings are the only supported
272
- way to force a theme, so nothing else is expected to set `color-scheme`
273
- directly. Each arm is independent, so an explicit selector still wins at
274
- any depth even inside a subtree the other arm would otherwise match. */
242
+ Each arm is independent, so an explicit selector wins over the OS preference
243
+ at any depth. It does not win over an explicit selector of the opposite
244
+ theme further up: `.dark *` matches every descendant of a `.dark` element,
245
+ including one inside a nested `.light`, so a `dark:` utility still fires
246
+ there although its tokens are light. `setup.md#dark-variant` documents it. */
275
247
  @custom-variant dark {
276
248
  &:where(.dark, .dark *, .theme-dark, .theme-dark *, [data-theme="dark"], [data-theme="dark"] *) {
277
249
  @slot;