@tenphi/tasty 0.0.0-snapshot.dfef2a5 → 0.0.0-snapshot.e01a0ee

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 (129) hide show
  1. package/README.md +436 -395
  2. package/dist/babel-types-BKDTT4--.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-DlxpZKk_.js +60 -0
  6. package/dist/chunks/build-config-DlxpZKk_.js.map +1 -0
  7. package/dist/{collector-DTahQUiV.js → chunks/collector-B4-yqFEs.js} +25 -119
  8. package/dist/chunks/collector-B4-yqFEs.js.map +1 -0
  9. package/dist/chunks/config-engine-DJsb5WYu.js +272 -0
  10. package/dist/chunks/config-engine-DJsb5WYu.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-DW1TGGiy.js +910 -0
  14. package/dist/chunks/css-definitions-DW1TGGiy.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-DMMwe1rY.js +502 -0
  18. package/dist/chunks/debug-DMMwe1rY.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DhPtFlZs.js +689 -0
  24. package/dist/chunks/react-runtime-DhPtFlZs.js.map +1 -0
  25. package/dist/chunks/runtime-engine-BlrVXv8l.js +2432 -0
  26. package/dist/chunks/runtime-engine-BlrVXv8l.js.map +1 -0
  27. package/dist/chunks/runtime-state-BLyMRYFF.js +152 -0
  28. package/dist/chunks/runtime-state-BLyMRYFF.js.map +1 -0
  29. package/dist/{merge-styles-oklji0KB.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-of5Xbc27.js +5571 -0
  32. package/dist/chunks/style-engine-of5Xbc27.js.map +1 -0
  33. package/dist/{css-writer-BrQjOLNY.js → chunks/zero-engine-D2jPSpWA.js} +65 -145
  34. package/dist/chunks/zero-engine-D2jPSpWA.js.map +1 -0
  35. package/dist/{collector-DUaHCcTS.d.ts → collector-CTU-nl0g.d.ts} +23 -4
  36. package/dist/{config-YsxGv4tq.d.ts → config-CcxqSZI2.d.ts} +175 -70
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-DhhUI0yi.d.ts → index--GdqCPlp.d.ts} +311 -253
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -921
  43. package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +3 -2
  54. package/dist/ssr/astro-middleware-static.js +0 -11
  55. package/dist/ssr/astro-middleware-static.js.map +1 -1
  56. package/dist/ssr/astro-middleware.d.ts +3 -2
  57. package/dist/ssr/astro-middleware.js +0 -12
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -6
  60. package/dist/ssr/astro.js +157 -93
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -25
  65. package/dist/ssr/index.js +5 -5
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +9 -8
  71. package/dist/ssr/next.js +29 -43
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/{index-Cd45t5NM.d.ts → types-DJEM_BOJ.d.ts} +864 -818
  78. package/dist/zero/babel.d.ts +67 -2
  79. package/dist/zero/babel.js +77 -140
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +62 -8
  82. package/dist/zero/index.js +24 -2
  83. package/dist/zero/index.js.map +1 -0
  84. package/dist/zero/next.d.ts +4 -5
  85. package/dist/zero/next.js +3 -38
  86. package/dist/zero/next.js.map +1 -1
  87. package/docs/README.md +16 -8
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +120 -86
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +251 -109
  92. package/docs/debug.md +21 -8
  93. package/docs/design-system.md +152 -31
  94. package/docs/dsl.md +373 -219
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +106 -68
  97. package/docs/methodology.md +80 -49
  98. package/docs/migration-v3.md +52 -52
  99. package/docs/pipeline.md +54 -27
  100. package/docs/plugins.md +59 -75
  101. package/docs/react-api.md +138 -52
  102. package/docs/runtime-benchmarks.md +388 -0
  103. package/docs/ssr.md +285 -101
  104. package/docs/styles.md +118 -32
  105. package/docs/tasty-static.md +272 -135
  106. package/package.json +118 -34
  107. package/dist/async-storage-DKK-wTD4.js +0 -44
  108. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  109. package/dist/babel-BUQGeOXA.d.ts +0 -83
  110. package/dist/collector-DTahQUiV.js.map +0 -1
  111. package/dist/config-B5kHzuNz.js +0 -12269
  112. package/dist/config-B5kHzuNz.js.map +0 -1
  113. package/dist/context-CA8YKeMn.js +0 -24
  114. package/dist/context-CA8YKeMn.js.map +0 -1
  115. package/dist/core-CTP5hhqP.js +0 -1565
  116. package/dist/core-CTP5hhqP.js.map +0 -1
  117. package/dist/css-writer-BrQjOLNY.js.map +0 -1
  118. package/dist/format-global-rules-DklyaXv-.js +0 -22
  119. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  120. package/dist/format-rules-DKOA-6qu.js +0 -130
  121. package/dist/format-rules-DKOA-6qu.js.map +0 -1
  122. package/dist/hydrate-OeMX99We.js +0 -37
  123. package/dist/hydrate-OeMX99We.js.map +0 -1
  124. package/dist/index.js.map +0 -1
  125. package/dist/keyframes-CoBy6OgI.js +0 -424
  126. package/dist/keyframes-CoBy6OgI.js.map +0 -1
  127. package/dist/merge-styles-oklji0KB.js.map +0 -1
  128. package/dist/resolve-recipes-DTG81rzl.js +0 -144
  129. package/dist/resolve-recipes-DTG81rzl.js.map +0 -1
package/docs/dsl.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Style DSL Reference
2
2
 
3
- This is the Tasty style language reference — the value syntax, state mappings, tokens, units, extending semantics, and special declarations that apply to both runtime `tasty()` and build-time `tastyStatic()`.
3
+ This is the language behind Tasty’s predictable state resolution. Every property can use a state map; later branches declare higher priority, and Tasty compiles them so only one generated selector can match.
4
4
 
5
- For the runtime React API (`tasty()`, hooks, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
5
+ The same value syntax, state maps, tokens, units, extension semantics, and special declarations apply to React `tasty()`—whether rendered on the client or server—and build-time `tastyStatic()`.
6
+
7
+ For the React API (`tasty()`, style functions, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
8
+
9
+ To autocomplete your own token and preset names, see [TypeScript autocomplete](getting-started.md#typescript-autocomplete); to check state keys, tokens, units, and values at lint time, see [ESLint plugin](getting-started.md#eslint-plugin).
6
10
 
7
11
  ---
8
12
 
@@ -16,22 +20,45 @@ Object where keys represent states and values are the styles to apply:
16
20
  fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
17
21
  ```
18
22
 
23
+ Define an alias for one component by adding an `'@name': '<state expression>'` key to its styles. It works like a global alias from [`configure({ states })`](configuration.md#options), scoped to that component:
24
+
25
+ ```jsx
26
+ styles: {
27
+ '@narrow': '@media(w < 600px)',
28
+ fill: { '': '#surface', '@narrow': '#surface-mobile' },
29
+ }
30
+ ```
31
+
19
32
  #### State Key Types
20
33
 
21
- | Syntax | Example | Generated CSS |
22
- |--------|---------|---------------|
23
- | Boolean modifier | `hovered` | `[data-hovered]` |
24
- | Value modifier | `theme=danger` | `[data-theme="danger"]` |
25
- | Pseudo-class | `:hover` | `:hover` |
26
- | Class selector | `.active` | `.active` |
27
- | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
28
- | Combined (AND) | `hovered & .active` | `[data-hovered].active` |
29
- | Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
30
- | Negated (NOT) | `!disabled` | `:not([data-disabled])` |
31
- | Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
34
+ | Syntax | Example | Generated CSS |
35
+ | ------------------ | ------------------------ | ------------------------------------------------------------------------ |
36
+ | Boolean modifier | `hovered` | `[data-hovered]` |
37
+ | Value modifier | `theme=danger` | `[data-theme="danger"]` |
38
+ | Pseudo-class | `:hover` | `:hover` |
39
+ | Class selector | `.active` | `.active` |
40
+ | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
41
+ | Combined (AND) | `hovered & .active` | `[data-hovered].active` |
42
+ | Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
43
+ | Negated (NOT) | `!disabled` | `:not([data-disabled])` |
44
+ | Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
45
+
46
+ #### Automatic Native States
47
+
48
+ `disabled`, `checked`, and `hidden` are built-in automatic states. A Tasty component sets `data-disabled`, `data-checked`, and `data-hidden` from the native `disabled`, `checked`, and `hidden` props (or `isDisabled`, `isChecked`, `isHidden`), so each pair below expresses the same component state:
49
+
50
+ | Concise Tasty state | Compiles to | Explicit attribute selector |
51
+ | ------------------- | ----------------- | --------------------------- |
52
+ | `disabled` | `[data-disabled]` | `[disabled]` |
53
+ | `checked` | `[data-checked]` | `[checked]` |
54
+ | `hidden` | `[data-hidden]` | `[hidden]` |
55
+
56
+ Prefer the concise form when authoring Tasty component styles. Explicit attribute selectors remain valid and can be useful when targeting arbitrary attributes or when CSS-shaped syntax makes an introductory example easier to recognize.
32
57
 
33
58
  Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
34
59
 
60
+ A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
61
+
35
62
  `^` (XOR) means "exactly one of" — `A ^ B` expands to `(A & !B) | (!A & B)`. This is useful for mutually exclusive states where exactly one should be active:
36
63
 
37
64
  ```jsx
@@ -41,6 +68,8 @@ fill: {
41
68
  }
42
69
  ```
43
70
 
71
+ Modifier and class names start with a letter and may be a single letter (`x` → `[data-x]`, `.x`). Tasty emits an `INVALID_STATE_KEY` warning for a key it cannot fully read and skips the unreadable parts. That covers characters outside the notation (`1st`, or `@media (w < 600px)` with a space before the parenthesis), an operator missing a state (`hovered &`), and two states with no operator between them (`hovered focused`). A partly read key can apply in states you did not mean, so fix the key rather than rely on what it produces.
72
+
44
73
  #### Default State Ordering
45
74
 
46
75
  Key order sets priority — later keys win and turn off earlier ones via negation. The bare default (`''`) is the lowest-priority state, so it **must be the first key**. If it appears after other states, Tasty moves it to the front and emits a dev warning (`MISPLACED_DEFAULT_STATE`); otherwise it would override every state above it.
@@ -53,14 +82,16 @@ color: { '': '#text', hovered: '#accent' }
53
82
  color: { hovered: '#accent', '': '#text' }
54
83
  ```
55
84
 
56
- The bare `''` default still **receives negation** (it is turned off when a higher-priority state matches). For a value that must always apply as a guaranteed floor — even where a query is *unknown* — use the [`_` fallback floor](#_--fallback-floor) instead. The two can coexist: `''` is the negated default, `_` is the always-on floor. If a map contains only `_` and `''` (no other states), the `''` default is redundant — Tasty keeps the `_` value and drops `''` with a `REDUNDANT_DEFAULT_STATE` warning.
85
+ The bare `''` default still **receives negation** (it is turned off when a higher-priority state matches). For a value that must always apply as a guaranteed floor — even where a query is _unknown_ — use the [`_` fallback floor](#_--fallback-floor) instead. The two can coexist: `''` is the negated default, `_` is the always-on floor. If a map contains only `_` and `''` (no other states), the `''` default is redundant — Tasty keeps the `_` value and drops `''` with a `REDUNDANT_DEFAULT_STATE` warning.
57
86
 
58
87
  ### Sub-element
59
88
 
60
89
  Element styled using a capitalized key. Identified by `data-element` attribute:
61
90
 
62
91
  ```jsx
63
- styles: { Title: { preset: 'h3' } }
92
+ styles: {
93
+ Title: { preset: 'h3' },
94
+ }
64
95
  // Targets: <div data-element="Title">
65
96
  ```
66
97
 
@@ -70,19 +101,19 @@ Control how a sub-element selector attaches to the root selector using the `$` p
70
101
 
71
102
  Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
72
103
 
73
- | Pattern | Result | Description |
74
- |---------|--------|-------------|
75
- | *(none)* | `[data-element="Cell"]` | Descendant (default) |
76
- | `>` | `> [data-element="Cell"]` | Direct child |
77
- | `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
78
- | `> Cell` | `> [data-element="Cell"]` | Self-name shorthand — when the trailing element name matches the sub-element's own key, it acts as the placeholder (same as `@`); no duplication |
79
- | `h1` | `h1` | Tag selector (no key injection) |
80
- | `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
81
- | `h1 *` | `h1 *` | Any descendant of tag |
82
- | `*` | `*` | All descendants |
83
- | `&::before` | `::before` | Root pseudo (no key); `&` is required |
84
- | `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
85
- | `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
104
+ | Pattern | Result | Description |
105
+ | ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
106
+ | _(none)_ | `[data-element="Cell"]` | Descendant (default) |
107
+ | `>` | `> [data-element="Cell"]` | Direct child |
108
+ | `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
109
+ | `> Cell` | `> [data-element="Cell"]` | Self-name shorthand — when the trailing element name matches the sub-element's own key, it acts as the placeholder (same as `@`); no duplication |
110
+ | `h1` | `h1` | Tag selector (no key injection) |
111
+ | `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
112
+ | `h1 *` | `h1 *` | Any descendant of tag |
113
+ | `*` | `*` | All descendants |
114
+ | `&::before` | `::before` | Root pseudo (no key); `&` is required |
115
+ | `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
116
+ | `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
86
117
 
87
118
  Rules for key injection (`[data-element="..."]`):
88
119
 
@@ -98,20 +129,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
98
129
  const List = tasty({
99
130
  styles: {
100
131
  Item: {
101
- $: '>@:last-child',
102
- border: 'none',
132
+ $: '>@::after',
133
+ content: '""',
103
134
  },
104
135
  },
105
136
  });
106
- // → .t0 > [data-element="Item"]:last-child { border: none }
137
+ // → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
107
138
  ```
108
139
 
140
+ Keep conditions such as `:last-child` out of `$` and write them as `@own(:last-child)` in a state map; `tasty/no-state-in-selector` warns otherwise. When `$` ends in a pseudo-element, `@own()` describes the pseudo-element instead (see [`@own(...)`](#own--sub-elements-own-state)), so a condition on the element it belongs to stays in `$`, before the pseudo-element: `$: 'a[rel="next"]::before'`.
141
+
109
142
  ### Color Token
110
143
 
111
144
  Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
112
145
 
113
146
  ```jsx
114
- fill: '#purple.5' // → oklch(from var(--purple-color) l c h / .5)
147
+ fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
115
148
  ```
116
149
 
117
150
  ### Modifier
@@ -138,6 +171,10 @@ fill: '#current', // → currentcolor
138
171
  color: '(#primary, #secondary)', // Fallback syntax
139
172
  ```
140
173
 
174
+ `#white`, `#black`, `#border`, and `#outline` are registered by default (see [Default properties](#default-properties)), and `#clear` is a built-in alias for `transparent` (see [below](#clear-is-transparent)), so they work before you define any tokens.
175
+
176
+ A name that is also a hex color is read as a token with the literal as its fallback, in every color style: `color: '#ddd'` emits `var(--ddd-color, #ddd)`, and `#ddd.5` emits `oklch(from var(--ddd-color, #ddd) l c h / .5)`. A `#ddd` token, if you define one, wins over the literal.
177
+
141
178
  The suffix sets the alpha on the token's color with CSS relative color syntax:
142
179
 
143
180
  ```jsx
@@ -146,7 +183,7 @@ fill: '#purple.5';
146
183
  ```
147
184
 
148
185
  The channels are copied over and the alpha slot is written, which asks nothing of
149
- the color beyond *being* a color. That means the suffix works on every one of
186
+ the color beyond _being_ a color. That means the suffix works on every one of
150
187
  these:
151
188
 
152
189
  - a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
@@ -163,6 +200,17 @@ Two properties follow from writing the alpha slot rather than compositing:
163
200
  `/ var(--fade)` unchanged, so it works whether `$fade` holds `.5` or `50%` —
164
201
  which is what `--*-opacity` properties are registered to accept.
165
202
 
203
+ ### `#clear` is transparent
204
+
205
+ `#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
206
+ Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
207
+ `transparent`. The same rule applies to user-defined replace tokens resolving
208
+ to `transparent`, including aliases of `#clear`.
209
+
210
+ It does not read `--clear-color` or require an `@property` registration.
211
+ An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
212
+ default alias and uses the replacement's usual opacity behavior.
213
+
166
214
  ### `#current` is the keyword
167
215
 
168
216
  `#current` emits the `currentcolor` keyword, so it resolves against the element
@@ -171,7 +219,7 @@ that expresses its disabled state once, in `color`, fades everything painted fro
171
219
  `#current` below it with no further declarations.
172
220
 
173
221
  The `color` style also publishes `--current-color` beside every color it sets,
174
- for anything that needs the inherited color *as a color* rather than as the
222
+ for anything that needs the inherited color _as a color_ rather than as the
175
223
  keyword — hand-authored CSS, or a place the keyword will not do. Read it as
176
224
  `$current-color`. It is registered with `initial-value: currentcolor`, so where
177
225
  nothing published it, it still resolves against each element's own color:
@@ -184,7 +232,7 @@ A color that already reads the color it inherits — `#current`, a `#current` fa
184
232
  — is not published into it: resolving such a value a second time at a descendant
185
233
  would fade it twice.
186
234
 
187
- One case needs the wider floor to be considered. A token *defined* as `#current`
235
+ One case needs the wider floor to be considered. A token _defined_ as `#current`
188
236
  and then faded gives relative color syntax a `currentcolor` origin, which Safari
189
237
  supports only from 18:
190
238
 
@@ -200,7 +248,7 @@ through `color-mix()`, which works from Safari 16.2 and composes like every othe
200
248
 
201
249
  ### `#current` composes instead
202
250
 
203
- `#current` is the one exception, and the difference is deliberate. A token *names*
251
+ `#current` composes alpha, and the difference is deliberate. A token _names_
204
252
  a color, so fading it sets its alpha. `currentcolor` is the color an element
205
253
  **inherits**, which an ancestor may already have faded — `#current.4` means "40%
206
254
  of what reaches me":
@@ -217,9 +265,10 @@ step. Because a `color-mix()` percentage cannot be a `<number>`, an opacity
217
265
  custom property used as `#current.$fade` must hold a unitless number; a token
218
266
  accepts either form.
219
267
 
220
- The space is always `oklch`: it is unbounded, so a wide-gamut color survives a
221
- round trip that a gamut-limited space would clamp. Nothing configures this —
222
- see [Color space](configuration.md#color-space).
268
+ Token fades always use `oklch(from …)`: it is unbounded, so a wide-gamut color
269
+ survives a round trip that a gamut-limited space would clamp. `#current` fades
270
+ mix `in oklab`. Nothing configures either — see
271
+ [Color space](configuration.md#color-space).
223
272
 
224
273
  ---
225
274
 
@@ -237,6 +286,9 @@ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
237
286
  shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
238
287
  ```
239
288
 
289
+ Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
290
+ time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
291
+
240
292
  `light-dark()` is the one exception to "always a color": CSS lets it pick between
241
293
  values of any type, so it is treated as a color only when its arguments are
242
294
  colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
@@ -266,24 +318,24 @@ configure({
266
318
  },
267
319
  });
268
320
 
269
- fill: '#solid.5'; // → hsl(220 90% 50% / .5)
270
- fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
321
+ fill: '#solid.5'; // → hsl(220 90% 50% / .5)
322
+ fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
271
323
  ```
272
324
 
273
325
  ---
274
326
 
275
327
  ## Built-in Units
276
328
 
277
- | Unit | Description | Example | CSS Output |
278
- |------|-------------|---------|------------|
279
- | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
280
- | `r` | Border radius | `1r` | `var(--radius)` |
281
- | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
282
- | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
283
- | `ow` | Outline width | `1ow` | `var(--outline-width)` |
284
- | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
329
+ | Unit | Description | Default | Example | CSS output |
330
+ | ---- | ------------------ | ---------------- | ------- | ---------------- |
331
+ | `x` | Spacing step | `8px` | `2x` | `16px` |
332
+ | `r` | Border radius | `6px` | `1r` | `6px` |
333
+ | `cr` | Card border radius | `10px` | `1cr` | `10px` |
334
+ | `bw` | Border width | `1px` | `2bw` | `2px` |
335
+ | `ow` | Outline width | `3px` | `1ow` | `3px` |
336
+ | `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
285
337
 
286
- You can register additional custom units via [`configure()`](configuration.md#options).
338
+ Units compile to plain values. Change the scale with `configure({ units: { x: '4px' } })`, or point a unit at a custom property when it must change at runtime: with `units: { x: 'var(--gap)' }`, `2x` compiles to `calc(2 * var(--gap))`. Setting a `$gap` or `$radius` token does not change the units. Register additional units the same way via [`configure()`](configuration.md#options).
287
339
 
288
340
  ---
289
341
 
@@ -324,9 +376,29 @@ const ElevatedCard = tasty({
324
376
  });
325
377
  ```
326
378
 
379
+ **Where recipes resolve:**
380
+
381
+ The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
382
+
383
+ ```jsx
384
+ const CardWithPanel = tasty({
385
+ styles: {
386
+ recipe: 'card',
387
+ Panel: {
388
+ recipe: 'card elevated',
389
+ padding: '2x', // Overrides the panel's base recipe padding
390
+ },
391
+ },
392
+ });
393
+ ```
394
+
395
+ At each level, base recipes are collected in the order listed (later recipes replace earlier values for the same property), then local styles are merged, then post recipes are merged. The merges with local styles and post recipes follow the [state-map extension and replacement rules](#extending-vs-replacing-state-maps).
396
+
397
+ Recipe definitions themselves cannot contain a `recipe` reference to another recipe: there is no recursive expansion or recipe inheritance. Compose names in the root or sub-element `recipe` property instead. See [Configuration — Recipes](configuration.md#recipes) for an unsupported nesting example.
398
+
327
399
  **Post-merge recipes (`/` separator):**
328
400
 
329
- Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
401
+ Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
330
402
 
331
403
  ```jsx
332
404
  const Input = tasty({
@@ -364,8 +436,8 @@ When a style property uses a state map, the merge behavior depends on whether th
364
436
  const MyButton = tasty(Button, {
365
437
  styles: {
366
438
  fill: {
367
- 'loading': '#yellow', // append new state
368
- 'disabled': '#gray.20', // override existing state in place
439
+ loading: '#yellow', // append new state
440
+ disabled: '#gray.20', // override existing state in place
369
441
  },
370
442
  },
371
443
  });
@@ -375,7 +447,7 @@ const MyButton = tasty(Button, {
375
447
  styles: {
376
448
  fill: {
377
449
  '': '#red',
378
- 'hovered': '#blue',
450
+ hovered: '#blue',
379
451
  },
380
452
  },
381
453
  });
@@ -400,8 +472,14 @@ fill: {
400
472
  Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
401
473
 
402
474
  ```jsx
403
- fill: { pressed: null } // removes pressed from the result
404
- fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe too
475
+ const MyButton = tasty(Button, {
476
+ styles: {
477
+ fill: {
478
+ hovered: null, // removes the parent's hovered state
479
+ disabled: false, // tombstone — no CSS for disabled, blocks recipe too
480
+ },
481
+ },
482
+ });
405
483
  ```
406
484
 
407
485
  ### Resetting Properties with `null` and `false`
@@ -409,36 +487,36 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
409
487
  ```jsx
410
488
  const SimpleButton = tasty(Button, {
411
489
  styles: {
412
- fill: null, // discard parent's fill, let recipe fill in
490
+ fill: null, // discard parent's fill, let recipe fill in
413
491
  border: false, // no border at all (tombstone — blocks recipe too)
414
492
  },
415
493
  });
416
494
  ```
417
495
 
418
- | Value | Meaning | Recipe fills in? |
419
- |-------|---------|-----------------|
420
- | `undefined` | Not provided — parent preserved | N/A |
421
- | `null` | Intentional unset — parent discarded | Yes |
422
- | `false` | Tombstone — blocks everything | No |
496
+ | Value | Meaning | Recipe fills in? |
497
+ | ----------- | ------------------------------------ | ---------------- |
498
+ | `undefined` | Not provided — parent preserved | N/A |
499
+ | `null` | Intentional unset — parent discarded | Yes |
500
+ | `false` | Tombstone — blocks everything | No |
423
501
 
424
502
  ---
425
503
 
426
504
  ## Advanced States (`@` prefix)
427
505
 
428
- | Prefix | Purpose | Example |
429
- |--------|---------|---------|
430
- | `@media` | Media queries | `@media(w < 768px)` |
431
- | `@(...)` | Container queries | `@(panel, w >= 300px)` |
432
- | `@supports` | Feature/selector support | `@supports(display: grid)` |
433
- | `@root` | Root element states | `@root(schema=dark)` |
434
- | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
435
- | `@own` | Sub-element's own state | `@own(hovered)` |
436
- | `@starting` | Entry animation | `@starting` |
437
- | `_` | Fallback floor (always-on, never negated) | `_` |
438
- | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
439
- | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
440
- | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
441
- | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
506
+ | Prefix | Purpose | Example |
507
+ | ----------- | ----------------------------------------- | -------------------------- |
508
+ | `@media` | Media queries | `@media(w < 768px)` |
509
+ | `@(...)` | Container queries | `@(panel, w >= 300px)` |
510
+ | `@supports` | Feature/selector support | `@supports(display: grid)` |
511
+ | `@root` | Root element states | `@root(schema=dark)` |
512
+ | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
513
+ | `@own` | Sub-element's own state | `@own(hovered)` |
514
+ | `@starting` | Entry animation | `@starting` |
515
+ | `_` | Fallback floor (always-on, never negated) | `_` |
516
+ | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
517
+ | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
518
+ | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
519
+ | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
442
520
 
443
521
  > **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
444
522
  > `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
@@ -451,12 +529,12 @@ const SimpleButton = tasty(Button, {
451
529
 
452
530
  ### `@media(...)` — Media Queries
453
531
 
454
- Media queries support dimension shorthands and custom unit expansion:
532
+ Media queries support dimension shorthands:
455
533
 
456
534
  | Shorthand | Expands to |
457
- |-----------|------------|
458
- | `w` | `width` |
459
- | `h` | `height` |
535
+ | --------- | ---------- |
536
+ | `w` | `width` |
537
+ | `h` | `height` |
460
538
 
461
539
  ```jsx
462
540
  fill: {
@@ -467,16 +545,23 @@ fill: {
467
545
  }
468
546
  ```
469
547
 
470
- | Tasty syntax | CSS output |
471
- |--------------|------------|
472
- | `@media(w < 768px)` | `@media (width < 768px)` |
473
- | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
474
- | `@media:print` | `@media print` |
475
- | `@media:screen` | `@media screen` |
548
+ | Tasty syntax | CSS output |
549
+ | ------------------------------------ | ------------------------------------- |
550
+ | `@media(w < 768px)` | `@media (width < 768px)` |
551
+ | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
552
+ | `@media:print` | `@media print` |
553
+ | `@media:screen` | `@media screen` |
554
+ | `@media:all` | `@media all` |
555
+ | `@media:speech` | `@media speech` |
476
556
  | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
477
- | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
557
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
558
+ | `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
559
+
560
+ Tasty units resolve to their literal length inside query conditions, built-in and configured units alike: `@media(w < 40x)` emits `@media (width < 320px)`. A query condition cannot read a custom property, so a unit configured as one (`units: { x: 'var(--gap)' }`) cannot be used there; write that length in `px`, `em`, or `rem`.
478
561
 
479
- Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
562
+ Units are only converted in features that take a length: `width`, `height`, `inline-size`, and `block-size`, with or without `min-`/`max-` (`@media(min-width: 40x)` converts too). Every other feature keeps its value as written, so `@media(min-resolution: 2x)` and `@media(resolution >= 2x)` reach the browser unchanged: there `x` is CSS's own resolution unit, an alias of `dppx`.
563
+
564
+ When it combines or orders conditions, Tasty compares bounds only within one unit. `@media(w >= 600px) & @media(w < 40em)` keeps both bounds, because a query `em` follows the user's font size, so `600px` and `40em` cannot be ordered at build time.
480
565
 
481
566
  In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
482
567
 
@@ -484,12 +569,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
484
569
 
485
570
  Container queries use the syntax `@(name, condition)` for named containers or `@(condition)` for the nearest ancestor container. Dimension shorthands (`w`, `h`, `is`, `bs`) are expanded the same way as `@media`.
486
571
 
487
- | Shorthand | Expands to |
488
- |-----------|------------|
489
- | `w` | `width` |
490
- | `h` | `height` |
491
- | `is` | `inline-size` |
492
- | `bs` | `block-size` |
572
+ | Shorthand | Expands to |
573
+ | --------- | ------------- |
574
+ | `w` | `width` |
575
+ | `h` | `height` |
576
+ | `is` | `inline-size` |
577
+ | `bs` | `block-size` |
493
578
 
494
579
  ```jsx
495
580
  const Panel = tasty({
@@ -502,26 +587,31 @@ const Panel = tasty({
502
587
  });
503
588
  ```
504
589
 
505
- | Tasty syntax | CSS output |
506
- |--------------|------------|
507
- | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
508
- | `@(w < 600px)` | `@container (width < 600px)` |
509
- | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
510
- | `@(layout, $compact)` | `@container layout style(--compact)` |
511
- | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
512
- | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
590
+ | Tasty syntax | CSS output |
591
+ | ---------------------------------- | -------------------------------------------- |
592
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
593
+ | `@(w < 600px)` | `@container (width < 600px)` |
594
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
595
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
596
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
597
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
513
598
 
514
- Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
599
+ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: value)`. The value is emitted unquoted, so it matches a custom property set to the identifier `danger`, not the string `"danger"`.
600
+
601
+ Other size features pass through as written: `@(aspect-ratio > 1)` → `@container (aspect-ratio > 1)`, `@(orientation: portrait)` → `@container (orientation: portrait)`. They need a container with `containerType: 'size'`, since an `inline-size` container has no block size to compare against.
515
602
 
516
603
  ### `@supports(...)` — Feature Queries
517
604
 
518
- Feature queries test CSS property support. Use `$` as the first argument to test selector support:
605
+ Feature queries test CSS property support and accept CSS support functions such
606
+ as `at-rule()`. Use `$` as the first argument to test selector support:
519
607
 
520
- | Tasty syntax | CSS output |
521
- |--------------|------------|
522
- | `@supports(display: grid)` | `@supports (display: grid)` |
523
- | `@supports($, :has(*))` | `@supports selector(:has(*))` |
524
- | `!@supports(display: grid)` | `@supports (not (display: grid))` |
608
+ | Tasty syntax | CSS output |
609
+ | ----------------------------- | ----------------------------------- |
610
+ | `@supports(display: grid)` | `@supports (display: grid)` |
611
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
612
+ | `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
613
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
614
+ | `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
525
615
 
526
616
  ```jsx
527
617
  display: {
@@ -530,6 +620,25 @@ display: {
530
620
  }
531
621
  ```
532
622
 
623
+ `at-rule()` tests whether the browser supports the named at-rule. Its surrounding
624
+ parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
625
+ other states use the same syntax as property queries:
626
+
627
+ ```jsx
628
+ color: {
629
+ _: 'red',
630
+ '@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
631
+ }
632
+ ```
633
+
634
+ Use `_` to keep a base value when a browser cannot evaluate a query. A support
635
+ query only detects a browser feature; it does not add an API for authoring the
636
+ queried at-rule in a Tasty style object. For conditional stylesheet imports such
637
+ as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
638
+ stylesheet or document-level `useRawCSS()`. Put imports before other rules in
639
+ that stylesheet. Imports cannot be used in constructable stylesheets, including
640
+ Tasty's adopted-sheet mode for Shadow DOM.
641
+
533
642
  ### `_` — Fallback Floor
534
643
 
535
644
  By default Tasty makes states **mutually exclusive**: a higher-priority state
@@ -539,7 +648,7 @@ that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
539
648
  just true/false), and `not(unknown)` is also unknown — so a negated default
540
649
  branch silently never applies. The classic case is `scroll-state`: a browser can
541
650
  support `container-type: scroll-state` while a specific `scroll-state(...)` query
542
- is unknown, leaving *no* branch active.
651
+ is unknown, leaving _no_ branch active.
543
652
 
544
653
  The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
545
654
  **always applies** as a guaranteed floor: it never receives negation, and
@@ -554,10 +663,14 @@ inset: {
554
663
  ```
555
664
 
556
665
  ```css
557
- .t0.t0 { inset: 0 ...; }
558
- @container scroll-state(scrolled: block-end) {
559
- @supports (container-type: scroll-state) {
560
- .t0.t0 { inset: -80px ...; }
666
+ .t0.t0 {
667
+ inset: 0 auto auto auto;
668
+ }
669
+ @supports (container-type: scroll-state) {
670
+ @container scroll-state(scrolled: block-end) {
671
+ .t0.t0 {
672
+ inset: -640px auto auto auto;
673
+ }
561
674
  }
562
675
  }
563
676
  ```
@@ -565,7 +678,7 @@ inset: {
565
678
  The floor is emitted as a bare rule (no negated `@supports` / container branches),
566
679
  so it always applies. When the override matches it wins because it is emitted
567
680
  later and all state selectors share the same specificity (see the note on
568
- `:where()` below).
681
+ `:where()` above).
569
682
 
570
683
  Notes:
571
684
 
@@ -588,13 +701,13 @@ cause is always the same: **`''` is mutually exclusive (turned off by negation),
588
701
  while `_` is always on (layered underneath).**
589
702
 
590
703
  - **Unknown / invalid branches.** If a higher-priority branch sits behind a query
591
- that can be *unknown* (`@supports`, container, `scroll-state`) or uses a
704
+ that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
592
705
  selector the browser drops, the negated `''` default disappears along with it
593
706
  (`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
594
707
  survives because it is an unconditional bare rule. This is the case `_` exists
595
708
  for.
596
709
 
597
- - **Empty / "unset" states.** A state can intentionally produce *no* output (an
710
+ - **Empty / "unset" states.** A state can intentionally produce _no_ output (an
598
711
  empty value) to leave a property unset while that state is active. With `''`
599
712
  this works — the default is negated away and nothing replaces it, so the
600
713
  property unsets. With `_` the floor can never be turned off, so its value keeps
@@ -606,14 +719,14 @@ while `_` is always on (layered underneath).**
606
719
  ```
607
720
 
608
721
  - **States with different output shapes.** Because `_` layers additively, when
609
- different states emit *different sets* of declarations, the floor's
722
+ different states emit _different sets_ of declarations, the floor's
610
723
  declarations bleed through wherever the winning state does not override the
611
724
  same property — which can produce inconsistent combinations. A `''` default is
612
725
  swapped out cleanly by its mutually-exclusive condition.
613
726
 
614
727
  Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
615
728
  supports unsetting), and reach for `_` only when a value must survive an
616
- *unknown* higher-priority branch.
729
+ _unknown_ higher-priority branch.
617
730
 
618
731
  ### `@root(...)` — Root Element States
619
732
 
@@ -629,15 +742,15 @@ color: {
629
742
  }
630
743
  ```
631
744
 
632
- | Tasty syntax | CSS selector |
633
- |--------------|-------------|
634
- | `@root(schema=dark)` | `:root[data-schema="dark"]` |
635
- | `@root(hovered)` | `:root[data-hovered]` |
636
- | `@root(.premium-user)` | `:root.premium-user` |
637
- | `@root([lang="en"])` | `:root[lang="en"]` |
638
- | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
745
+ | Tasty syntax | CSS selector |
746
+ | ---------------------- | --------------------------------- |
747
+ | `@root(schema=dark)` | `:root[data-schema="dark"]` |
748
+ | `@root(hovered)` | `:root[data-hovered]` |
749
+ | `@root(.premium-user)` | `:root.premium-user` |
750
+ | `@root([lang="en"])` | `:root[lang="en"]` |
751
+ | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
639
752
 
640
- Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
753
+ Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
641
754
 
642
755
  ### `@own(...)` — Sub-element's Own State
643
756
 
@@ -651,7 +764,7 @@ const Nav = tasty({
651
764
  '': '#text',
652
765
  '@own(:hover)': '#primary',
653
766
  '@own(:focus-visible)': '#primary',
654
- 'selected': '#primary', // root-level modifier
767
+ selected: '#primary', // root-level modifier
655
768
  },
656
769
  },
657
770
  },
@@ -659,14 +772,28 @@ const Nav = tasty({
659
772
  });
660
773
  ```
661
774
 
662
- | Tasty syntax (inside sub-element) | CSS output |
663
- |-----------------------------------|------------|
664
- | `@own(:hover)` | `:hover` on the sub-element selector |
665
- | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
666
- | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
775
+ | Tasty syntax (inside sub-element) | CSS output |
776
+ | --------------------------------- | ------------------------------------------------- |
777
+ | `@own(:hover)` | `:hover` on the sub-element selector |
778
+ | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
779
+ | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
667
780
 
668
781
  `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
669
782
 
783
+ When `$` ends in a pseudo-element, `@own()` is the pseudo-element's own state and goes after it:
784
+
785
+ ```jsx
786
+ Label: {
787
+ $: '@::part(label)',
788
+ color: { '': '#text', '@own(:focus)': '#primary' },
789
+ },
790
+ // → .t0.t0 [data-element="Label"]::part(label):where(:focus) { … }
791
+ ```
792
+
793
+ A pseudo-element has no attributes, classes, or place in the DOM tree. So a state that tests a modifier (`@own(hovered)`), an attribute (`@own([open])`), a class, or a tree position (`@own(:first-child)`, `@own(:has(…))`) can never match it. Tasty ignores such a state and warns. To condition on the element the pseudo-element belongs to, write it in `$` before the pseudo-element (`$: 'a[rel="next"]::before'`), or use `@parent()` for its ancestors.
794
+
795
+ This covers every pseudo-element form: `::before`, `::marker`, `::backdrop`, vendor-prefixed ones such as `::-webkit-details-marker`, functional ones such as `::part(label)`, and the legacy `:before`, `:after`, `:first-line`, `:first-letter`. Each item of a `$` list is judged on its own. Tasty emits pseudo-class states regardless of browser support. Only some pseudo-elements, such as `::part()` and `::-webkit-scrollbar-thumb`, match states like `:hover` or `:focus` today.
796
+
670
797
  ### `@starting` — Entry Animation
671
798
 
672
799
  Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
@@ -676,40 +803,40 @@ const FadeIn = tasty({
676
803
  styles: {
677
804
  opacity: { '': '1', '@starting': '0' },
678
805
  transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
679
- transition: 'opacity 0.3s, translate 0.3s',
806
+ transition: 'opacity, translate',
680
807
  },
681
808
  });
682
809
  ```
683
810
 
684
- | Tasty syntax | CSS output |
685
- |--------------|------------|
686
- | `@starting` | `@starting-style { .t0.t0 { ... } }` |
811
+ | Tasty syntax | CSS output |
812
+ | ------------ | ------------------------------------ |
813
+ | `@starting` | `.t0.t0 { @starting-style { ... } }` |
687
814
 
688
815
  ### `@parent(...)` — Parent Element States
689
816
 
690
- Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
817
+ Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
691
818
 
692
819
  ```jsx
693
820
  const Highlight = tasty({
694
821
  styles: {
695
822
  fill: {
696
823
  '': '#white',
697
- '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
698
- '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
824
+ '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
825
+ '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
699
826
  },
700
827
  },
701
828
  });
702
829
  ```
703
830
 
704
- | Syntax | CSS Output |
705
- |--------|------------|
706
- | `@parent(hovered)` | `:is([data-hovered] *)` |
707
- | `!@parent(hovered)` | `:not([data-hovered] *)` |
708
- | `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
709
- | `@parent(.active)` | `:is(.active *)` |
710
- | `@parent(hovered & focused)` | `:is([data-hovered][data-focused] *)` (same ancestor) |
711
- | `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
712
- | `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
831
+ | Syntax | CSS Output |
832
+ | ------------------------------------- | -------------------------------------------------------------------------- |
833
+ | `@parent(hovered)` | `:where([data-hovered] *)` |
834
+ | `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
835
+ | `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
836
+ | `@parent(.active)` | `:where(.active *)` |
837
+ | `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
838
+ | `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
839
+ | `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
713
840
 
714
841
  For sub-elements, the parent check applies to the root element's ancestors:
715
842
 
@@ -724,12 +851,12 @@ const Card = tasty({
724
851
  },
725
852
  },
726
853
  });
727
- // → .t0.t0:is([data-hovered] *) [data-element="Label"]
854
+ // → .t0.t0:where([data-hovered] *) [data-element="Label"]
728
855
  ```
729
856
 
730
857
  ### `:is()`, `:has()` — CSS Structural Pseudo-classes
731
858
 
732
- Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`.
859
+ Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`. Leading combinators (`> Icon`, `+ Icon`) are relative selectors and are valid only inside `:has()`.
733
860
 
734
861
  `:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
735
862
 
@@ -740,38 +867,38 @@ const Card = tasty({
740
867
  styles: {
741
868
  display: {
742
869
  '': 'block',
743
- ':has(> Icon)': 'grid', // has Icon as direct child
744
- ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
745
- ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
746
- ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
747
- ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
748
- ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
749
- '!:has(> Icon)': 'flex', // negation: no Icon child
870
+ ':has(> Icon)': 'grid', // has Icon as direct child
871
+ ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
872
+ ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
873
+ ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
874
+ ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
875
+ ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
876
+ '!:has(> Icon)': 'flex', // negation: no Icon child
750
877
  },
751
878
  },
752
879
  });
753
880
  ```
754
881
 
755
- | Syntax | CSS Output | Meaning |
756
- |--------|------------|---------|
757
- | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
758
- | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
759
- | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
760
- | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
761
- | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
762
- | `:has(>)` | `:has(> *)` | Has any direct child |
763
- | `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
764
- | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
765
- | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
766
- | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
882
+ | Syntax | CSS Output | Meaning |
883
+ | -------------------- | ------------------------------------- | --------------------------------------- |
884
+ | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
885
+ | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
886
+ | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
887
+ | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
888
+ | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
889
+ | `:has(>)` | `:has(> *)` | Has any direct child |
890
+ | `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
891
+ | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
892
+ | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
893
+ | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
767
894
 
768
895
  Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
769
896
 
770
897
  ```jsx
771
- ':has(> Icon) & hovered' // AND: structural + data attribute
772
- '@parent(hovered) & :has(> Icon)' // AND: parent check + structural
773
- ':has(> Icon) | :has(> Button)' // OR: either sub-element present
774
- ':has(> Icon) ^ :has(> Button)' // XOR: exactly one present
898
+ ':has(> Icon) & hovered'; // AND: structural + data attribute
899
+ '@parent(hovered) & :has(> Icon)'; // AND: parent check + structural
900
+ ':has(> Icon) | :has(> Button)'; // OR: either sub-element present
901
+ ':has(> Icon) ^ :has(> Button)'; // XOR: exactly one present
775
902
  ```
776
903
 
777
904
  > **Nesting limit:** The state key parser supports up to 2 levels of nested parentheses inside `:is()`, `:has()`, `:not()`, and `:where()` — e.g. `:has(Input:not(:disabled))` works, but 3+ levels like `:has(:is(:not(:hover)))` will not be tokenized correctly. This covers virtually all practical use cases.
@@ -796,6 +923,8 @@ const Pulse = tasty({
796
923
  });
797
924
  ```
798
925
 
926
+ Keyframes names are case-sensitive and keep their authored case in `animation` and `animationName` (`fadeIn`, not `fadein`), so they match `@keyframes` defined here, in `configure({ keyframes })`, or in plain CSS. Everything else in the value — durations, timing functions, keywords — is parsed as usual.
927
+
799
928
  ---
800
929
 
801
930
  ## Properties (`@property`)
@@ -807,8 +936,8 @@ const AnimatedGradient = tasty({
807
936
  styles: {
808
937
  '$gradient-angle': '0deg',
809
938
  '#theme': 'okhst(280 80% 50%)',
810
- background: 'linear-gradient($gradient-angle, #theme, transparent)',
811
- transition: '$$gradient-angle 0.3s, ##theme 0.3s',
939
+ image: 'linear-gradient($gradient-angle, #theme, #clear)',
940
+ transition: '$$gradient-angle, ##theme',
812
941
  },
813
942
  });
814
943
  ```
@@ -823,6 +952,26 @@ Use explicit `@property` when you need non-default settings like `inherits: fals
823
952
  },
824
953
  ```
825
954
 
955
+ ### Default properties
956
+
957
+ Tasty registers these properties itself. Style handlers read their defaults from them rather than repeating the values inline, so styles work before you define any tokens, and defining a token replaces the initial value.
958
+
959
+ | Token | Initial value | Read by |
960
+ | ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
961
+ | `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
962
+ | `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
963
+ | `#border` | `currentcolor` | `border` with no color |
964
+ | `#outline` | `currentcolor` | `outline` with no color |
965
+ | `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
966
+ | `$transition` | `80ms` | `transition` with no duration |
967
+ | `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
968
+ | `$bold-font-weight` | `700` | `preset: 'name / strong'` |
969
+ | `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
970
+
971
+ Every rendering path emits them: the client injector, the SSR collector (`TastyRegistry`, `tastyIntegration()`, `runWithCollector()`), the `withTastyNext()` shared stylesheet, and the Babel plugin. CSS written with the programmatic API needs [`extractConfigProperties()`](tasty-static.md#programmatic-api), once per stylesheet. Server rendering without a collector, such as Astro without `tastyIntegration()`, emits none of them.
972
+
973
+ The initial values need `@property` support: Chrome and Edge 85+, Firefox 128+, Safari 16.4+. In older engines a handler that reads one of these tokens resolves to nothing unless your tokens define it: a `border` with no color draws no border, and a `transition` with no duration does not animate. To support those engines, define the tokens your styles rely on in `configure({ tokens })`.
974
+
826
975
  ---
827
976
 
828
977
  ## Font Face (`@font-face`)
@@ -838,7 +987,7 @@ const Heading = tasty({
838
987
  fontDisplay: 'swap',
839
988
  },
840
989
  },
841
- fontFamily: '"Brand Sans", sans-serif',
990
+ font: '"Brand Sans", sans-serif',
842
991
  },
843
992
  });
844
993
  ```
@@ -858,20 +1007,20 @@ Supply an array to register several variants of the same family:
858
1007
 
859
1008
  ### Supported descriptors
860
1009
 
861
- | Descriptor | CSS property | Type |
862
- |---|---|---|
863
- | `src` (required) | `src` | `string` |
864
- | `fontWeight` | `font-weight` | `string \| number` |
865
- | `fontStyle` | `font-style` | `string` |
866
- | `fontStretch` | `font-stretch` | `string` |
867
- | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
868
- | `unicodeRange` | `unicode-range` | `string` |
869
- | `ascentOverride` | `ascent-override` | `string` |
870
- | `descentOverride` | `descent-override` | `string` |
871
- | `lineGapOverride` | `line-gap-override` | `string` |
872
- | `sizeAdjust` | `size-adjust` | `string` |
873
- | `fontFeatureSettings` | `font-feature-settings` | `string` |
874
- | `fontVariationSettings` | `font-variation-settings` | `string` |
1010
+ | Descriptor | CSS property | Type |
1011
+ | ----------------------- | ------------------------- | --------------------------------------------------------- |
1012
+ | `src` (required) | `src` | `string` |
1013
+ | `fontWeight` | `font-weight` | `string \| number` |
1014
+ | `fontStyle` | `font-style` | `string` |
1015
+ | `fontStretch` | `font-stretch` | `string` |
1016
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
1017
+ | `unicodeRange` | `unicode-range` | `string` |
1018
+ | `ascentOverride` | `ascent-override` | `string` |
1019
+ | `descentOverride` | `descent-override` | `string` |
1020
+ | `lineGapOverride` | `line-gap-override` | `string` |
1021
+ | `sizeAdjust` | `size-adjust` | `string` |
1022
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
1023
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
875
1024
 
876
1025
  > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
877
1026
 
@@ -883,7 +1032,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
883
1032
 
884
1033
  ```ts
885
1034
  const EmojiList = tasty({
886
- tag: 'ol',
1035
+ as: 'ol',
887
1036
  styles: {
888
1037
  '@counter-style': {
889
1038
  thumbs: {
@@ -899,18 +1048,18 @@ const EmojiList = tasty({
899
1048
 
900
1049
  ### Supported descriptors
901
1050
 
902
- | Descriptor | CSS property | Type |
903
- |---|---|---|
904
- | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
905
- | `symbols` | `symbols` | `string` |
906
- | `additiveSymbols` | `additive-symbols` | `string` |
907
- | `prefix` | `prefix` | `string` |
908
- | `suffix` | `suffix` | `string` |
909
- | `negative` | `negative` | `string` |
910
- | `range` | `range` | `string` |
911
- | `pad` | `pad` | `string` |
912
- | `fallback` | `fallback` | `string` |
913
- | `speakAs` | `speak-as` | `string` |
1051
+ | Descriptor | CSS property | Type |
1052
+ | ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
1053
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
1054
+ | `symbols` | `symbols` | `string` |
1055
+ | `additiveSymbols` | `additive-symbols` | `string` |
1056
+ | `prefix` | `prefix` | `string` |
1057
+ | `suffix` | `suffix` | `string` |
1058
+ | `negative` | `negative` | `string` |
1059
+ | `range` | `range` | `string` |
1060
+ | `pad` | `pad` | `string` |
1061
+ | `fallback` | `fallback` | `string` |
1062
+ | `speakAs` | `speak-as` | `string` |
914
1063
 
915
1064
  > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
916
1065
 
@@ -932,18 +1081,18 @@ const Box = tasty({
932
1081
  styles: {
933
1082
  '@function': {
934
1083
  // simplest: one bare param + result (auto-calc, no explicit calc())
935
- '$$negative': { args: ['$value'], result: '(-1 * $value)' },
1084
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
936
1085
 
937
1086
  // typed param + default + return type + local variable
938
- '$$shadow': {
1087
+ $$shadow: {
939
1088
  args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
940
1089
  returns: '<color>',
941
- '$offset': '2px', // local variable
1090
+ $offset: '2px', // local variable
942
1091
  result: '$offset $offset ($shadow-color, black)',
943
1092
  },
944
1093
  },
945
- marginTop: '$$negative(10px)', // → margin-top: --negative(10px)
946
- boxShadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
1094
+ margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
1095
+ shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
947
1096
  },
948
1097
  });
949
1098
  ```
@@ -951,26 +1100,31 @@ const Box = tasty({
951
1100
  Generated CSS:
952
1101
 
953
1102
  ```css
954
- @function --negative(--value) { result: calc(-1 * var(--value)); }
1103
+ @function --negative(--value) {
1104
+ result: calc(-1 * var(--value));
1105
+ }
955
1106
  @function --shadow(--shadow-color <color>: inherit) returns <color> {
956
1107
  --offset: 2px;
957
1108
  result: var(--offset) var(--offset) var(--shadow-color, black);
958
1109
  }
959
- .t0 { margin-top: --negative(10px); box-shadow: --shadow(var(--accent-color)); }
1110
+ .t0 {
1111
+ margin: --negative(10px) 0 0 0;
1112
+ box-shadow: --shadow(var(--accent-color));
1113
+ }
960
1114
  ```
961
1115
 
962
1116
  ### Descriptor shape
963
1117
 
964
- | Field | Type | Notes |
965
- |---|---|---|
966
- | `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
967
- | `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
968
- | `returns` | `string` | Optional return type, e.g. `'<color>'`. |
969
- | `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
1118
+ | Field | Type | Notes |
1119
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
1120
+ | `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
1121
+ | `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
1122
+ | `returns` | `string` | Optional return type, e.g. `'<color>'`. |
1123
+ | `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
970
1124
 
971
1125
  A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
972
1126
 
973
- Functions can also be registered with the [`useFunction`](react-api.md#usefunction) hook or globally via [`configure({ functions })`](configuration.md#functions) (the same map also accepts bare-key parse functions).
1127
+ Functions can also be registered with the [`useFunction`](react-api.md#usefunction) style function or globally via [`configure({ functions })`](configuration.md#functions) (the same map also accepts bare-key parse functions).
974
1128
 
975
1129
  > `@function` is permanent — injected once and never cleaned up, like `@counter-style`. It is an experimental CSS feature ([Chrome 139+](https://developer.mozilla.org/en-US/docs/Web/CSS/@function)); unsupported browsers safely ignore the native rule, so use it as progressive enhancement — or enable the [`configure({ polyfills: { functions: true } })`](configuration.md#polyfills) inline polyfill to expand `$$name(...)` calls into plain CSS for full cross-browser support.
976
1130
 
@@ -988,4 +1142,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
988
1142
  - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
989
1143
  - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
990
1144
  - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
991
- - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin
1145
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin