@tenphi/tasty 0.0.0-snapshot.a8b0eee → 0.0.0-snapshot.a8da86e

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 (125) hide show
  1. package/README.md +181 -136
  2. package/dist/babel-types-C_7kRP38.d.ts +18 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-Betc6IB6.js +60 -0
  6. package/dist/chunks/build-config-Betc6IB6.js.map +1 -0
  7. package/dist/{collector-Crs9kGJW.js → chunks/collector-DqqisglQ.js} +68 -101
  8. package/dist/chunks/collector-DqqisglQ.js.map +1 -0
  9. package/dist/chunks/config-engine-BPeROwq2.js +272 -0
  10. package/dist/chunks/config-engine-BPeROwq2.js.map +1 -0
  11. package/dist/chunks/css-definitions-IeuyJTGk.js +899 -0
  12. package/dist/chunks/css-definitions-IeuyJTGk.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-P1E2jkj7.js +502 -0
  16. package/dist/chunks/debug-P1E2jkj7.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-XMBbGRes.js +582 -0
  22. package/dist/chunks/react-runtime-XMBbGRes.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CsIMtulO.js +2415 -0
  24. package/dist/chunks/runtime-engine-CsIMtulO.js.map +1 -0
  25. package/dist/chunks/runtime-state-CyKzDioI.js +141 -0
  26. package/dist/chunks/runtime-state-CyKzDioI.js.map +1 -0
  27. package/dist/{merge-styles-BzQutdAK.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-RbokDN6A.js +5427 -0
  30. package/dist/chunks/style-engine-RbokDN6A.js.map +1 -0
  31. package/dist/{css-writer-CPy_cbFJ.js → chunks/zero-engine-DbtjMsfo.js} +81 -137
  32. package/dist/chunks/zero-engine-DbtjMsfo.js.map +1 -0
  33. package/dist/{collector-osfWTeRd.d.ts → collector-w4mBj5gd.d.ts} +64 -8
  34. package/dist/{config-BoZDUHW5.d.ts → config-CrZOfNJ5.d.ts} +489 -85
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-B_k47mc_.d.ts → index-CYJtAI9a.d.ts} +664 -399
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -732
  40. package/dist/{merge-styles-BMWcH6MF.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
  41. package/dist/ssr/astro-client.d.ts +1 -1
  42. package/dist/ssr/astro-client.js +1 -14
  43. package/dist/ssr/astro-client.js.map +1 -1
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +11 -8
  54. package/dist/ssr/astro-middleware.js +2 -14
  55. package/dist/ssr/astro-middleware.js.map +1 -1
  56. package/dist/ssr/astro.d.ts +40 -10
  57. package/dist/ssr/astro.js +163 -91
  58. package/dist/ssr/astro.js.map +1 -1
  59. package/dist/ssr/index.d.ts +10 -18
  60. package/dist/ssr/index.js +5 -5
  61. package/dist/ssr/index.js.map +1 -1
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +134 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +9 -9
  66. package/dist/ssr/next.js +29 -44
  67. package/dist/ssr/next.js.map +1 -1
  68. package/dist/static/index.d.ts +8 -9
  69. package/dist/static/index.js +4 -22
  70. package/dist/static/index.js.map +1 -1
  71. package/dist/static/inject.d.ts +1 -2
  72. package/dist/static/inject.js.map +1 -1
  73. package/dist/{index-tcHuMPFt.d.ts → types-JEY8PVYP.d.ts} +874 -593
  74. package/dist/zero/babel.d.ts +5 -19
  75. package/dist/zero/babel.js +74 -144
  76. package/dist/zero/babel.js.map +1 -1
  77. package/dist/zero/index.d.ts +57 -7
  78. package/dist/zero/index.js +24 -2
  79. package/dist/zero/index.js.map +1 -0
  80. package/dist/zero/next.d.ts +4 -5
  81. package/dist/zero/next.js +0 -31
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +17 -9
  84. package/docs/adoption.md +56 -31
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +69 -40
  87. package/docs/configuration.md +487 -86
  88. package/docs/debug.md +26 -14
  89. package/docs/design-system.md +43 -24
  90. package/docs/dsl.md +558 -181
  91. package/docs/getting-started.md +64 -41
  92. package/docs/injector.md +120 -30
  93. package/docs/methodology.md +46 -40
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +87 -21
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +151 -42
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +252 -86
  100. package/docs/styles.md +142 -25
  101. package/docs/tasty-static.md +174 -106
  102. package/package.json +127 -35
  103. package/tasty.config.ts +5 -0
  104. package/dist/async-storage-B7_o6FKt.js +0 -44
  105. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  106. package/dist/collector-Crs9kGJW.js.map +0 -1
  107. package/dist/config-BaxtQMS3.js +0 -10464
  108. package/dist/config-BaxtQMS3.js.map +0 -1
  109. package/dist/context-CkSg-kDT.js +0 -24
  110. package/dist/context-CkSg-kDT.js.map +0 -1
  111. package/dist/core-CmxaoZ-N.js +0 -1598
  112. package/dist/core-CmxaoZ-N.js.map +0 -1
  113. package/dist/css-writer-CPy_cbFJ.js.map +0 -1
  114. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  115. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  116. package/dist/format-rules-CPirO_Mj.js +0 -143
  117. package/dist/format-rules-CPirO_Mj.js.map +0 -1
  118. package/dist/hydrate-CVn-A_3y.js +0 -45
  119. package/dist/hydrate-CVn-A_3y.js.map +0 -1
  120. package/dist/index.js.map +0 -1
  121. package/dist/keyframes-vpzoVdUR.js +0 -588
  122. package/dist/keyframes-vpzoVdUR.js.map +0 -1
  123. package/dist/merge-styles-BzQutdAK.js.map +0 -1
  124. package/dist/resolve-recipes-DgH8A3Nn.js +0 -144
  125. package/dist/resolve-recipes-DgH8A3Nn.js.map +0 -1
package/docs/dsl.md CHANGED
@@ -1,8 +1,10 @@
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).
6
8
 
7
9
  ---
8
10
 
@@ -18,17 +20,28 @@ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
18
20
 
19
21
  #### State Key Types
20
22
 
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]` |
23
+ | Syntax | Example | Generated CSS |
24
+ | ------------------ | ------------------------ | ------------------------------------------------------------------------ |
25
+ | Boolean modifier | `hovered` | `[data-hovered]` |
26
+ | Value modifier | `theme=danger` | `[data-theme="danger"]` |
27
+ | Pseudo-class | `:hover` | `:hover` |
28
+ | Class selector | `.active` | `.active` |
29
+ | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
30
+ | Combined (AND) | `hovered & .active` | `[data-hovered].active` |
31
+ | Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
32
+ | Negated (NOT) | `!disabled` | `:not([data-disabled])` |
33
+ | Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
34
+
35
+ #### Automatic Native States
36
+
37
+ `disabled` and `checked` are built-in automatic states. On a Tasty component, they track the corresponding native prop or attribute, so these pairs express the same component state:
38
+
39
+ | Concise Tasty state | Explicit attribute selector |
40
+ | ------------------- | --------------------------- |
41
+ | `disabled` | `[disabled]` |
42
+ | `checked` | `[checked]` |
43
+
44
+ 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
45
 
33
46
  Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
34
47
 
@@ -41,12 +54,32 @@ fill: {
41
54
  }
42
55
  ```
43
56
 
57
+ 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.
58
+
59
+ #### Default State Ordering
60
+
61
+ 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.
62
+
63
+ ```jsx
64
+ // Correct — default first
65
+ color: { '': '#text', hovered: '#accent' }
66
+
67
+ // Auto-corrected with a warning — '' moved to the front
68
+ color: { hovered: '#accent', '': '#text' }
69
+ ```
70
+
71
+ 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.
72
+
44
73
  ### Sub-element
45
74
 
46
75
  Element styled using a capitalized key. Identified by `data-element` attribute:
47
76
 
48
77
  ```jsx
49
- styles: { Title: { preset: 'h3' } }
78
+ styles: {
79
+ Title: {
80
+ preset: 'h3';
81
+ }
82
+ }
50
83
  // Targets: <div data-element="Title">
51
84
  ```
52
85
 
@@ -56,19 +89,19 @@ Control how a sub-element selector attaches to the root selector using the `$` p
56
89
 
57
90
  Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
58
91
 
59
- | Pattern | Result | Description |
60
- |---------|--------|-------------|
61
- | *(none)* | `[data-element="Cell"]` | Descendant (default) |
62
- | `>` | `> [data-element="Cell"]` | Direct child |
63
- | `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
64
- | `> 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 |
65
- | `h1` | `h1` | Tag selector (no key injection) |
66
- | `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
67
- | `h1 *` | `h1 *` | Any descendant of tag |
68
- | `*` | `*` | All descendants |
69
- | `&::before` | `::before` | Root pseudo (no key); `&` is required |
70
- | `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
71
- | `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
92
+ | Pattern | Result | Description |
93
+ | ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
94
+ | _(none)_ | `[data-element="Cell"]` | Descendant (default) |
95
+ | `>` | `> [data-element="Cell"]` | Direct child |
96
+ | `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
97
+ | `> 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 |
98
+ | `h1` | `h1` | Tag selector (no key injection) |
99
+ | `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
100
+ | `h1 *` | `h1 *` | Any descendant of tag |
101
+ | `*` | `*` | All descendants |
102
+ | `&::before` | `::before` | Root pseudo (no key); `&` is required |
103
+ | `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
104
+ | `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
72
105
 
73
106
  Rules for key injection (`[data-element="..."]`):
74
107
 
@@ -97,7 +130,7 @@ const List = tasty({
97
130
  Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
98
131
 
99
132
  ```jsx
100
- fill: '#purple.5' // → var(--purple-color) with 50% opacity
133
+ fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
101
134
  ```
102
135
 
103
136
  ### Modifier
@@ -109,7 +142,7 @@ mods={{ hovered: true, theme: 'danger' }}
109
142
  // → data-hovered="" data-theme="danger"
110
143
  ```
111
144
 
112
- Modifiers can also be exposed as top-level component props via `modProps` — see [Runtime — Mod Props](react-api.md#mod-props).
145
+ Modifiers can also be exposed as top-level component props via `modProps` — see [React API — Mod Props](react-api.md#mod-props).
113
146
 
114
147
  ---
115
148
 
@@ -119,23 +152,155 @@ Modifiers can also be exposed as top-level component props via `modProps` — se
119
152
  color: '#purple', // Full opacity
120
153
  color: '#purple.5', // 50% opacity
121
154
  color: '#purple.05', // 5% opacity
155
+ color: '#purple.$fade', // Opacity from a custom property
122
156
  fill: '#current', // → currentcolor
123
- fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
124
157
  color: '(#primary, #secondary)', // Fallback syntax
125
158
  ```
126
159
 
160
+ The suffix sets the alpha on the token's color with CSS relative color syntax:
161
+
162
+ ```jsx
163
+ fill: '#purple.5';
164
+ // → oklch(from var(--purple-color) l c h / .5)
165
+ ```
166
+
167
+ The channels are copied over and the alpha slot is written, which asks nothing of
168
+ the color beyond _being_ a color. That means the suffix works on every one of
169
+ these:
170
+
171
+ - a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
172
+ Tasty cannot convert — none of which have channels to decompose
173
+ - `#current`, which resolves to the color the element inherits
174
+ - a `--name-color` variable declared in your own CSS, with no Tasty token
175
+ definition behind it
176
+
177
+ Two properties follow from writing the alpha slot rather than compositing:
178
+
179
+ - **Alpha is replaced, not multiplied.** A token holding `rgb(255 0 0 / .8)`
180
+ faded to `.5` is alpha `.5`, not `.4`.
181
+ - **The alpha may be a number or a percentage.** `#purple.$fade` emits
182
+ `/ var(--fade)` unchanged, so it works whether `$fade` holds `.5` or `50%` —
183
+ which is what `--*-opacity` properties are registered to accept.
184
+
185
+ ### `#current` is the keyword
186
+
187
+ `#current` emits the `currentcolor` keyword, so it resolves against the element
188
+ that reads it. That is what lets it follow a color an ancestor faded — a ramp
189
+ that expresses its disabled state once, in `color`, fades everything painted from
190
+ `#current` below it with no further declarations.
191
+
192
+ The `color` style also publishes `--current-color` beside every color it sets,
193
+ for anything that needs the inherited color _as a color_ rather than as the
194
+ keyword — hand-authored CSS, or a place the keyword will not do. Read it as
195
+ `$current-color`. It is registered with `initial-value: currentcolor`, so where
196
+ nothing published it, it still resolves against each element's own color:
197
+
198
+ ```jsx
199
+ fill: '$current-color'; // → var(--current-color)
200
+ ```
201
+
202
+ A color that already reads the color it inherits — `#current`, a `#current` fade
203
+ — is not published into it: resolving such a value a second time at a descendant
204
+ would fade it twice.
205
+
206
+ One case needs the wider floor to be considered. A token _defined_ as `#current`
207
+ and then faded gives relative color syntax a `currentcolor` origin, which Safari
208
+ supports only from 18:
209
+
210
+ ```jsx
211
+ { '#ink': '#current', fill: '#ink.5' }
212
+ // --ink-color: currentcolor
213
+ // fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
214
+ ```
215
+
216
+ Put the fade in the token instead — `{ '#ink': '#current.5' }` — and it goes
217
+ through `color-mix()`, which works from Safari 16.2 and composes like every other
218
+ `#current` fade.
219
+
220
+ ### `#current` composes instead
221
+
222
+ `#current` is the one exception, and the difference is deliberate. A token _names_
223
+ a color, so fading it sets its alpha. `currentcolor` is the color an element
224
+ **inherits**, which an ancestor may already have faded — `#current.4` means "40%
225
+ of what reaches me":
226
+
227
+ ```jsx
228
+ fill: '#current.4';
229
+ // → color-mix(in oklab, currentcolor 40%, transparent)
230
+ ```
231
+
232
+ So a `#current` fade nested inside another one composes: a label at `#current.4`
233
+ with a fill of `#current.18` under it lands at `.072`. Color ramps built on
234
+ `#current` depend on that — replacing would double the opacity of every nested
235
+ step. Because a `color-mix()` percentage cannot be a `<number>`, an opacity
236
+ custom property used as `#current.$fade` must hold a unitless number; a token
237
+ accepts either form.
238
+
239
+ The space is always `oklch`: it is unbounded, so a wide-gamut color survives a
240
+ round trip that a gamut-limited space would clamp. Nothing configures this —
241
+ see [Color space](configuration.md#color-space).
242
+
243
+ ---
244
+
245
+ ## CSS Color Functions
246
+
247
+ Every CSS color function is recognized as a color, so it lands in the color slot
248
+ of whichever style property you use it in — and tokens inside it are expanded:
249
+
250
+ ```jsx
251
+ fill: 'color-mix(in oklab, #primary 50%, #surface)',
252
+ color: 'light-dark(#dark, #light)',
253
+ color: 'contrast-color(#primary)',
254
+ fill: 'color(display-p3 1 .5 0)',
255
+ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
256
+ shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
257
+ ```
258
+
259
+ `light-dark()` is the one exception to "always a color": CSS lets it pick between
260
+ values of any type, so it is treated as a color only when its arguments are
261
+ colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
262
+
263
+ A color token defined as one of these functions takes the
264
+ [opacity suffix](#color-tokens--opacity) like any other:
265
+
266
+ ```jsx
267
+ const Card = tasty({
268
+ styles: {
269
+ '#brand': 'color-mix(in oklab, #primary 50%, #surface)',
270
+ fill: '#brand.5',
271
+ },
272
+ });
273
+ ```
274
+
275
+ A [replace token](configuration.md#replace-tokens-parse-time-substitution) is
276
+ substituted while parsing, so its color is right there to fade in place. A
277
+ channel function takes the alpha after a slash; a derived function has no alpha
278
+ channel, so it gets wrapped:
279
+
280
+ ```jsx
281
+ configure({
282
+ replaceTokens: {
283
+ '#solid': 'hsl(220 90% 50%)',
284
+ '#adaptive': 'light-dark(#dark, #light)',
285
+ },
286
+ });
287
+
288
+ fill: '#solid.5'; // → hsl(220 90% 50% / .5)
289
+ fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
290
+ ```
291
+
127
292
  ---
128
293
 
129
294
  ## Built-in Units
130
295
 
131
- | Unit | Description | Example | CSS Output |
132
- |------|-------------|---------|------------|
133
- | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
134
- | `r` | Border radius | `1r` | `var(--radius)` |
135
- | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
136
- | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
137
- | `ow` | Outline width | `1ow` | `var(--outline-width)` |
138
- | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
296
+ | Unit | Description | Example | CSS Output |
297
+ | ---- | ------------------ | ------- | ------------------------------- |
298
+ | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
299
+ | `r` | Border radius | `1r` | `var(--radius)` |
300
+ | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
301
+ | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
302
+ | `ow` | Outline width | `1ow` | `var(--outline-width)` |
303
+ | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
139
304
 
140
305
  You can register additional custom units via [`configure()`](configuration.md#options).
141
306
 
@@ -178,9 +343,29 @@ const ElevatedCard = tasty({
178
343
  });
179
344
  ```
180
345
 
346
+ **Where recipes resolve:**
347
+
348
+ The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
349
+
350
+ ```jsx
351
+ const CardWithPanel = tasty({
352
+ styles: {
353
+ recipe: 'card',
354
+ Panel: {
355
+ recipe: 'card elevated',
356
+ padding: '2x', // Overrides the panel's base recipe padding
357
+ },
358
+ },
359
+ });
360
+ ```
361
+
362
+ At each level, base recipes are collected in name order (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).
363
+
364
+ 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.
365
+
181
366
  **Post-merge recipes (`/` separator):**
182
367
 
183
- Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
368
+ Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
184
369
 
185
370
  ```jsx
186
371
  const Input = tasty({
@@ -218,8 +403,8 @@ When a style property uses a state map, the merge behavior depends on whether th
218
403
  const MyButton = tasty(Button, {
219
404
  styles: {
220
405
  fill: {
221
- 'loading': '#yellow', // append new state
222
- 'disabled': '#gray.20', // override existing state in place
406
+ loading: '#yellow', // append new state
407
+ disabled: '#gray.20', // override existing state in place
223
408
  },
224
409
  },
225
410
  });
@@ -229,7 +414,7 @@ const MyButton = tasty(Button, {
229
414
  styles: {
230
415
  fill: {
231
416
  '': '#red',
232
- 'hovered': '#blue',
417
+ hovered: '#blue',
233
418
  },
234
419
  },
235
420
  });
@@ -254,8 +439,12 @@ fill: {
254
439
  Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
255
440
 
256
441
  ```jsx
257
- fill: { pressed: null } // removes pressed from the result
258
- fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe too
442
+ fill: {
443
+ pressed: null;
444
+ } // removes pressed from the result
445
+ fill: {
446
+ disabled: false;
447
+ } // tombstone — no CSS for disabled, blocks recipe too
259
448
  ```
260
449
 
261
450
  ### Resetting Properties with `null` and `false`
@@ -263,44 +452,54 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
263
452
  ```jsx
264
453
  const SimpleButton = tasty(Button, {
265
454
  styles: {
266
- fill: null, // discard parent's fill, let recipe fill in
455
+ fill: null, // discard parent's fill, let recipe fill in
267
456
  border: false, // no border at all (tombstone — blocks recipe too)
268
457
  },
269
458
  });
270
459
  ```
271
460
 
272
- | Value | Meaning | Recipe fills in? |
273
- |-------|---------|-----------------|
274
- | `undefined` | Not provided — parent preserved | N/A |
275
- | `null` | Intentional unset — parent discarded | Yes |
276
- | `false` | Tombstone — blocks everything | No |
461
+ | Value | Meaning | Recipe fills in? |
462
+ | ----------- | ------------------------------------ | ---------------- |
463
+ | `undefined` | Not provided — parent preserved | N/A |
464
+ | `null` | Intentional unset — parent discarded | Yes |
465
+ | `false` | Tombstone — blocks everything | No |
277
466
 
278
467
  ---
279
468
 
280
469
  ## Advanced States (`@` prefix)
281
470
 
282
- | Prefix | Purpose | Example |
283
- |--------|---------|---------|
284
- | `@media` | Media queries | `@media(w < 768px)` |
285
- | `@(...)` | Container queries | `@(panel, w >= 300px)` |
286
- | `@supports` | Feature/selector support | `@supports(display: grid)` |
287
- | `@root` | Root element states | `@root(schema=dark)` |
288
- | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
289
- | `@own` | Sub-element's own state | `@own(hovered)` |
290
- | `@starting` | Entry animation | `@starting` |
291
- | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
292
- | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
293
- | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
294
- | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
471
+ | Prefix | Purpose | Example |
472
+ | ----------- | ----------------------------------------- | -------------------------- |
473
+ | `@media` | Media queries | `@media(w < 768px)` |
474
+ | `@(...)` | Container queries | `@(panel, w >= 300px)` |
475
+ | `@supports` | Feature/selector support | `@supports(display: grid)` |
476
+ | `@root` | Root element states | `@root(schema=dark)` |
477
+ | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
478
+ | `@own` | Sub-element's own state | `@own(hovered)` |
479
+ | `@starting` | Entry animation | `@starting` |
480
+ | `_` | Fallback floor (always-on, never negated) | `_` |
481
+ | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
482
+ | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
483
+ | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
484
+ | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
485
+
486
+ > **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
487
+ > `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
488
+ > `:where(...)` so they carry **zero specificity**. The only specificity anchors
489
+ > are the doubled component class (`.t0.t0`) and sub-element `[data-element]`
490
+ > attributes. This means overlapping rules (e.g. a `_` fallback floor and the
491
+ > states layered over it) resolve purely by **source order** — Tasty emits
492
+ > lower-priority states first and higher-priority states last so the cascade
493
+ > produces the intended winner.
295
494
 
296
495
  ### `@media(...)` — Media Queries
297
496
 
298
497
  Media queries support dimension shorthands and custom unit expansion:
299
498
 
300
499
  | Shorthand | Expands to |
301
- |-----------|------------|
302
- | `w` | `width` |
303
- | `h` | `height` |
500
+ | --------- | ---------- |
501
+ | `w` | `width` |
502
+ | `h` | `height` |
304
503
 
305
504
  ```jsx
306
505
  fill: {
@@ -311,14 +510,14 @@ fill: {
311
510
  }
312
511
  ```
313
512
 
314
- | Tasty syntax | CSS output |
315
- |--------------|------------|
316
- | `@media(w < 768px)` | `@media (width < 768px)` |
317
- | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
318
- | `@media:print` | `@media print` |
319
- | `@media:screen` | `@media screen` |
513
+ | Tasty syntax | CSS output |
514
+ | ------------------------------------ | ------------------------------------- |
515
+ | `@media(w < 768px)` | `@media (width < 768px)` |
516
+ | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
517
+ | `@media:print` | `@media print` |
518
+ | `@media:screen` | `@media screen` |
320
519
  | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
321
- | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
520
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
322
521
 
323
522
  Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
324
523
 
@@ -328,12 +527,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
328
527
 
329
528
  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`.
330
529
 
331
- | Shorthand | Expands to |
332
- |-----------|------------|
333
- | `w` | `width` |
334
- | `h` | `height` |
335
- | `is` | `inline-size` |
336
- | `bs` | `block-size` |
530
+ | Shorthand | Expands to |
531
+ | --------- | ------------- |
532
+ | `w` | `width` |
533
+ | `h` | `height` |
534
+ | `is` | `inline-size` |
535
+ | `bs` | `block-size` |
337
536
 
338
537
  ```jsx
339
538
  const Panel = tasty({
@@ -346,26 +545,29 @@ const Panel = tasty({
346
545
  });
347
546
  ```
348
547
 
349
- | Tasty syntax | CSS output |
350
- |--------------|------------|
351
- | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
352
- | `@(w < 600px)` | `@container (width < 600px)` |
353
- | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
354
- | `@(layout, $compact)` | `@container layout style(--compact)` |
355
- | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
356
- | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
548
+ | Tasty syntax | CSS output |
549
+ | ---------------------------------- | ---------------------------------------------- |
550
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
551
+ | `@(w < 600px)` | `@container (width < 600px)` |
552
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
553
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
554
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
555
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
357
556
 
358
557
  Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
359
558
 
360
559
  ### `@supports(...)` — Feature Queries
361
560
 
362
- Feature queries test CSS property support. Use `$` as the first argument to test selector support:
561
+ Feature queries test CSS property support and accept CSS support functions such
562
+ as `at-rule()`. Use `$` as the first argument to test selector support:
363
563
 
364
- | Tasty syntax | CSS output |
365
- |--------------|------------|
366
- | `@supports(display: grid)` | `@supports (display: grid)` |
367
- | `@supports($, :has(*))` | `@supports selector(:has(*))` |
368
- | `!@supports(display: grid)` | `@supports (not (display: grid))` |
564
+ | Tasty syntax | CSS output |
565
+ | ---------------------------- | ---------------------------------- |
566
+ | `@supports(display: grid)` | `@supports (display: grid)` |
567
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
568
+ | `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
569
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
570
+ | `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
369
571
 
370
572
  ```jsx
371
573
  display: {
@@ -374,6 +576,114 @@ display: {
374
576
  }
375
577
  ```
376
578
 
579
+ `at-rule()` tests whether the browser supports the named at-rule. Its surrounding
580
+ parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
581
+ other states use the same syntax as property queries:
582
+
583
+ ```jsx
584
+ color: {
585
+ _: 'red',
586
+ '@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
587
+ }
588
+ ```
589
+
590
+ Use `_` to keep a base value when a browser cannot evaluate a query. A support
591
+ query only detects a browser feature; it does not add an API for authoring the
592
+ queried at-rule in a Tasty style object. For conditional stylesheet imports such
593
+ as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
594
+ stylesheet or document-level `useRawCSS()`. Put imports before other rules in
595
+ that stylesheet. Imports cannot be used in constructable stylesheets, including
596
+ Tasty's adopted-sheet mode for Shadow DOM.
597
+
598
+ ### `_` — Fallback Floor
599
+
600
+ By default Tasty makes states **mutually exclusive**: a higher-priority state
601
+ turns the lower-priority ones off via negation, so exactly one branch applies.
602
+ This relies on `A | !A` always being true. CSS feature/container queries break
603
+ that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
604
+ just true/false), and `not(unknown)` is also unknown — so a negated default
605
+ branch silently never applies. The classic case is `scroll-state`: a browser can
606
+ support `container-type: scroll-state` while a specific `scroll-state(...)` query
607
+ is unknown, leaving _no_ branch active.
608
+
609
+ The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
610
+ **always applies** as a guaranteed floor: it never receives negation, and
611
+ higher-priority states simply layer over it via the cascade.
612
+
613
+ ```jsx
614
+ inset: {
615
+ _: '0 top',
616
+ '@supports(container-type: scroll-state) & @(scroll-state(scrolled: block-end))':
617
+ '-80x top',
618
+ }
619
+ ```
620
+
621
+ ```css
622
+ .t0.t0 {
623
+ inset: 0...;
624
+ }
625
+ @container scroll-state(scrolled: block-end) {
626
+ @supports (container-type: scroll-state) {
627
+ .t0.t0 {
628
+ inset: -80px...;
629
+ }
630
+ }
631
+ }
632
+ ```
633
+
634
+ The floor is emitted as a bare rule (no negated `@supports` / container branches),
635
+ so it always applies. When the override matches it wins because it is emitted
636
+ later and all state selectors share the same specificity (see the note on
637
+ `:where()` below).
638
+
639
+ Notes:
640
+
641
+ - `_` is a **standalone key only** — it defines a single map-wide floor and
642
+ cannot be combined with state logic. Keys like `_ & hovered` or `_ | focused`
643
+ are ignored with an `INVALID_FALLBACK_KEY` dev warning.
644
+ - `_` can coexist with the bare `''` default when other states exist: `''` is the
645
+ negated default, `_` is the always-on floor. With only `_` and `''` (no other
646
+ states) the `''` default is redundant — Tasty keeps the `_` value and drops
647
+ `''` with a `REDUNDANT_DEFAULT_STATE` warning.
648
+ - `_` is position-independent: it is always placed at the lowest priority
649
+ regardless of where it appears in the map.
650
+
651
+ #### `_` vs the `''` default
652
+
653
+ In simple maps where every other state is a plain modifier (always cleanly
654
+ on/off), `_` and `''` produce the **same visible result** — the base value shows
655
+ whenever no other state wins. They diverge in three situations, and the root
656
+ cause is always the same: **`''` is mutually exclusive (turned off by negation),
657
+ while `_` is always on (layered underneath).**
658
+
659
+ - **Unknown / invalid branches.** If a higher-priority branch sits behind a query
660
+ that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
661
+ selector the browser drops, the negated `''` default disappears along with it
662
+ (`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
663
+ survives because it is an unconditional bare rule. This is the case `_` exists
664
+ for.
665
+
666
+ - **Empty / "unset" states.** A state can intentionally produce _no_ output (an
667
+ empty value) to leave a property unset while that state is active. With `''`
668
+ this works — the default is negated away and nothing replaces it, so the
669
+ property unsets. With `_` the floor can never be turned off, so its value keeps
670
+ applying and the "unset on this state" intent is lost.
671
+
672
+ ```jsx
673
+ // '' : color unsets while loading. '_' : color stays #text while loading.
674
+ color: { '': '#text', loading: '' }
675
+ ```
676
+
677
+ - **States with different output shapes.** Because `_` layers additively, when
678
+ different states emit _different sets_ of declarations, the floor's
679
+ declarations bleed through wherever the winning state does not override the
680
+ same property — which can produce inconsistent combinations. A `''` default is
681
+ swapped out cleanly by its mutually-exclusive condition.
682
+
683
+ Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
684
+ supports unsetting), and reach for `_` only when a value must survive an
685
+ _unknown_ higher-priority branch.
686
+
377
687
  ### `@root(...)` — Root Element States
378
688
 
379
689
  Root states generate selectors on the `:root` element. They are useful for theme modes, feature flags, and other page-level conditions:
@@ -388,13 +698,13 @@ color: {
388
698
  }
389
699
  ```
390
700
 
391
- | Tasty syntax | CSS selector |
392
- |--------------|-------------|
393
- | `@root(schema=dark)` | `:root[data-schema="dark"]` |
394
- | `@root(hovered)` | `:root[data-hovered]` |
395
- | `@root(.premium-user)` | `:root.premium-user` |
396
- | `@root([lang="en"])` | `:root[lang="en"]` |
397
- | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
701
+ | Tasty syntax | CSS selector |
702
+ | ---------------------- | --------------------------------- |
703
+ | `@root(schema=dark)` | `:root[data-schema="dark"]` |
704
+ | `@root(hovered)` | `:root[data-hovered]` |
705
+ | `@root(.premium-user)` | `:root.premium-user` |
706
+ | `@root([lang="en"])` | `:root[lang="en"]` |
707
+ | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
398
708
 
399
709
  Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
400
710
 
@@ -410,7 +720,7 @@ const Nav = tasty({
410
720
  '': '#text',
411
721
  '@own(:hover)': '#primary',
412
722
  '@own(:focus-visible)': '#primary',
413
- 'selected': '#primary', // root-level modifier
723
+ selected: '#primary', // root-level modifier
414
724
  },
415
725
  },
416
726
  },
@@ -418,11 +728,11 @@ const Nav = tasty({
418
728
  });
419
729
  ```
420
730
 
421
- | Tasty syntax (inside sub-element) | CSS output |
422
- |-----------------------------------|------------|
423
- | `@own(:hover)` | `:hover` on the sub-element selector |
424
- | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
425
- | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
731
+ | Tasty syntax (inside sub-element) | CSS output |
732
+ | --------------------------------- | ------------------------------------------------- |
733
+ | `@own(:hover)` | `:hover` on the sub-element selector |
734
+ | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
735
+ | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
426
736
 
427
737
  `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
428
738
 
@@ -435,14 +745,14 @@ const FadeIn = tasty({
435
745
  styles: {
436
746
  opacity: { '': '1', '@starting': '0' },
437
747
  transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
438
- transition: 'opacity 0.3s, translate 0.3s',
748
+ transition: 'opacity, translate',
439
749
  },
440
750
  });
441
751
  ```
442
752
 
443
- | Tasty syntax | CSS output |
444
- |--------------|------------|
445
- | `@starting` | `@starting-style { .t0.t0 { ... } }` |
753
+ | Tasty syntax | CSS output |
754
+ | ------------ | ------------------------------------ |
755
+ | `@starting` | `@starting-style { .t0.t0 { ... } }` |
446
756
 
447
757
  ### `@parent(...)` — Parent Element States
448
758
 
@@ -453,22 +763,22 @@ const Highlight = tasty({
453
763
  styles: {
454
764
  fill: {
455
765
  '': '#white',
456
- '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
457
- '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
766
+ '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
767
+ '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
458
768
  },
459
769
  },
460
770
  });
461
771
  ```
462
772
 
463
- | Syntax | CSS Output |
464
- |--------|------------|
465
- | `@parent(hovered)` | `:is([data-hovered] *)` |
466
- | `!@parent(hovered)` | `:not([data-hovered] *)` |
467
- | `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
468
- | `@parent(.active)` | `:is(.active *)` |
469
- | `@parent(hovered & focused)` | `:is([data-hovered][data-focused] *)` (same ancestor) |
773
+ | Syntax | CSS Output |
774
+ | ------------------------------------- | -------------------------------------------------------------------- |
775
+ | `@parent(hovered)` | `:is([data-hovered] *)` |
776
+ | `!@parent(hovered)` | `:not([data-hovered] *)` |
777
+ | `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
778
+ | `@parent(.active)` | `:is(.active *)` |
779
+ | `@parent(hovered & focused)` | `:is([data-hovered][data-focused] *)` (same ancestor) |
470
780
  | `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
471
- | `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
781
+ | `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
472
782
 
473
783
  For sub-elements, the parent check applies to the root element's ancestors:
474
784
 
@@ -499,38 +809,38 @@ const Card = tasty({
499
809
  styles: {
500
810
  display: {
501
811
  '': 'block',
502
- ':has(> Icon)': 'grid', // has Icon as direct child
503
- ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
504
- ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
505
- ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
506
- ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
507
- ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
508
- '!:has(> Icon)': 'flex', // negation: no Icon child
812
+ ':has(> Icon)': 'grid', // has Icon as direct child
813
+ ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
814
+ ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
815
+ ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
816
+ ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
817
+ ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
818
+ '!:has(> Icon)': 'flex', // negation: no Icon child
509
819
  },
510
820
  },
511
821
  });
512
822
  ```
513
823
 
514
- | Syntax | CSS Output | Meaning |
515
- |--------|------------|---------|
516
- | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
517
- | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
518
- | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
519
- | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
520
- | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
521
- | `:has(>)` | `:has(> *)` | Has any direct child |
522
- | `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
523
- | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
524
- | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
525
- | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
824
+ | Syntax | CSS Output | Meaning |
825
+ | ---------------------- | --------------------------------------- | --------------------------------------- |
826
+ | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
827
+ | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
828
+ | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
829
+ | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
830
+ | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
831
+ | `:has(>)` | `:has(> *)` | Has any direct child |
832
+ | `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
833
+ | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
834
+ | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
835
+ | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
526
836
 
527
837
  Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
528
838
 
529
839
  ```jsx
530
- ':has(> Icon) & hovered' // AND: structural + data attribute
531
- '@parent(hovered) & :has(> Icon)' // AND: parent check + structural
532
- ':has(> Icon) | :has(> Button)' // OR: either sub-element present
533
- ':has(> Icon) ^ :has(> Button)' // XOR: exactly one present
840
+ ':has(> Icon) & hovered'; // AND: structural + data attribute
841
+ '@parent(hovered) & :has(> Icon)'; // AND: parent check + structural
842
+ ':has(> Icon) | :has(> Button)'; // OR: either sub-element present
843
+ ':has(> Icon) ^ :has(> Button)'; // XOR: exactly one present
534
844
  ```
535
845
 
536
846
  > **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.
@@ -555,6 +865,8 @@ const Pulse = tasty({
555
865
  });
556
866
  ```
557
867
 
868
+ 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.
869
+
558
870
  ---
559
871
 
560
872
  ## Properties (`@property`)
@@ -565,39 +877,39 @@ CSS cannot transition or animate custom properties unless the browser knows thei
565
877
  const AnimatedGradient = tasty({
566
878
  styles: {
567
879
  '$gradient-angle': '0deg',
568
- '#theme': 'okhsl(280 80% 50%)',
569
- background: 'linear-gradient($gradient-angle, #theme, transparent)',
570
- transition: '$$gradient-angle 0.3s, ##theme 0.3s',
880
+ '#theme': 'okhst(280 80% 50%)',
881
+ image: 'linear-gradient($gradient-angle, #theme, #clear)',
882
+ transition: '$$gradient-angle, ##theme',
571
883
  },
572
884
  });
573
885
  ```
574
886
 
575
887
  Here `$gradient-angle: '0deg'` is detected as `<angle>` and `#theme` as `<color>` (via the `#name` naming convention), so both transitions work without any manual `@property` declarations. Numeric types (`<number>`, `<length>`, `<percentage>`, `<angle>`, `<time>`) are inferred from values; `<color>` is inferred from `#name` tokens.
576
888
 
577
- Use explicit `@properties` when you need non-default settings like `inherits: false`:
889
+ Use explicit `@property` when you need non-default settings like `inherits: false`:
578
890
 
579
891
  ```jsx
580
- '@properties': {
892
+ '@property': {
581
893
  '$gradient-angle': { syntax: '<angle>', inherits: false, initialValue: '0deg' },
582
894
  },
583
895
  ```
584
896
 
585
897
  ---
586
898
 
587
- ## Font Face (`@fontFace`)
899
+ ## Font Face (`@font-face`)
588
900
 
589
901
  Register custom fonts directly inside a `styles` object. Keys are font-family names, values are descriptor objects (or arrays of them for multiple weights/styles).
590
902
 
591
903
  ```ts
592
904
  const Heading = tasty({
593
905
  styles: {
594
- '@fontFace': {
906
+ '@font-face': {
595
907
  'Brand Sans': {
596
908
  src: 'url("/fonts/brand-sans.woff2") format("woff2")',
597
909
  fontDisplay: 'swap',
598
910
  },
599
911
  },
600
- fontFamily: '"Brand Sans", sans-serif',
912
+ font: '"Brand Sans", sans-serif',
601
913
  },
602
914
  });
603
915
  ```
@@ -607,7 +919,7 @@ const Heading = tasty({
607
919
  Supply an array to register several variants of the same family:
608
920
 
609
921
  ```ts
610
- '@fontFace': {
922
+ '@font-face': {
611
923
  'Brand Sans': [
612
924
  { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
613
925
  { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
@@ -617,26 +929,26 @@ Supply an array to register several variants of the same family:
617
929
 
618
930
  ### Supported descriptors
619
931
 
620
- | Descriptor | CSS property | Type |
621
- |---|---|---|
622
- | `src` (required) | `src` | `string` |
623
- | `fontWeight` | `font-weight` | `string \| number` |
624
- | `fontStyle` | `font-style` | `string` |
625
- | `fontStretch` | `font-stretch` | `string` |
626
- | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
627
- | `unicodeRange` | `unicode-range` | `string` |
628
- | `ascentOverride` | `ascent-override` | `string` |
629
- | `descentOverride` | `descent-override` | `string` |
630
- | `lineGapOverride` | `line-gap-override` | `string` |
631
- | `sizeAdjust` | `size-adjust` | `string` |
632
- | `fontFeatureSettings` | `font-feature-settings` | `string` |
633
- | `fontVariationSettings` | `font-variation-settings` | `string` |
932
+ | Descriptor | CSS property | Type |
933
+ | ----------------------- | ------------------------- | --------------------------------------------------------- |
934
+ | `src` (required) | `src` | `string` |
935
+ | `fontWeight` | `font-weight` | `string \| number` |
936
+ | `fontStyle` | `font-style` | `string` |
937
+ | `fontStretch` | `font-stretch` | `string` |
938
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
939
+ | `unicodeRange` | `unicode-range` | `string` |
940
+ | `ascentOverride` | `ascent-override` | `string` |
941
+ | `descentOverride` | `descent-override` | `string` |
942
+ | `lineGapOverride` | `line-gap-override` | `string` |
943
+ | `sizeAdjust` | `size-adjust` | `string` |
944
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
945
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
634
946
 
635
947
  > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
636
948
 
637
949
  ---
638
950
 
639
- ## Counter Style (`@counterStyle`)
951
+ ## Counter Style (`@counter-style`)
640
952
 
641
953
  Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
642
954
 
@@ -644,7 +956,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
644
956
  const EmojiList = tasty({
645
957
  tag: 'ol',
646
958
  styles: {
647
- '@counterStyle': {
959
+ '@counter-style': {
648
960
  thumbs: {
649
961
  system: 'cyclic',
650
962
  symbols: '"👍"',
@@ -658,23 +970,88 @@ const EmojiList = tasty({
658
970
 
659
971
  ### Supported descriptors
660
972
 
661
- | Descriptor | CSS property | Type |
662
- |---|---|---|
663
- | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
664
- | `symbols` | `symbols` | `string` |
665
- | `additiveSymbols` | `additive-symbols` | `string` |
666
- | `prefix` | `prefix` | `string` |
667
- | `suffix` | `suffix` | `string` |
668
- | `negative` | `negative` | `string` |
669
- | `range` | `range` | `string` |
670
- | `pad` | `pad` | `string` |
671
- | `fallback` | `fallback` | `string` |
672
- | `speakAs` | `speak-as` | `string` |
973
+ | Descriptor | CSS property | Type |
974
+ | ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
975
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
976
+ | `symbols` | `symbols` | `string` |
977
+ | `additiveSymbols` | `additive-symbols` | `string` |
978
+ | `prefix` | `prefix` | `string` |
979
+ | `suffix` | `suffix` | `string` |
980
+ | `negative` | `negative` | `string` |
981
+ | `range` | `range` | `string` |
982
+ | `pad` | `pad` | `string` |
983
+ | `fallback` | `fallback` | `string` |
984
+ | `speakAs` | `speak-as` | `string` |
673
985
 
674
986
  > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
675
987
 
676
988
  ---
677
989
 
990
+ ## Functions (`@function`)
991
+
992
+ Define reusable, parameterized CSS [custom functions](https://developer.mozilla.org/en-US/docs/Web/CSS/@function) via the CSS `@function` at-rule. A custom function takes parameters and returns a single value — like a dynamic custom property.
993
+
994
+ The token convention follows Tasty's `$` vs `$$` distinction:
995
+
996
+ - **`$$name`** — the literal callable name (`--name`). Used for the **definition key** and for **invocation** `$$name(...)`, mirroring the existing `$$gradient-angle` → `--gradient-angle` sugar. The definition key matches the call site.
997
+ - **`$name`** — a custom-property declaration/reference (`var(--name)`). Used for **parameters** and **local variables**, exactly like declaring custom props in a styles object.
998
+ - **Local variables** are declared directly as `$name` keys on the descriptor — the body reads like a mini styles object.
999
+ - `result`, local-variable values, and parameter `default` values flow through the full Tasty DSL, so units (`2x`), color tokens (`#theme`), auto-calc (`(-1 * $value)` → `calc(-1 * var(--value))`), and fallbacks (`($shadow-color, black)` → `var(--shadow-color, black)`) all work.
1000
+
1001
+ ```ts
1002
+ const Box = tasty({
1003
+ styles: {
1004
+ '@function': {
1005
+ // simplest: one bare param + result (auto-calc, no explicit calc())
1006
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
1007
+
1008
+ // typed param + default + return type + local variable
1009
+ $$shadow: {
1010
+ args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
1011
+ returns: '<color>',
1012
+ $offset: '2px', // local variable
1013
+ result: '$offset $offset ($shadow-color, black)',
1014
+ },
1015
+ },
1016
+ margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
1017
+ shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
1018
+ },
1019
+ });
1020
+ ```
1021
+
1022
+ Generated CSS:
1023
+
1024
+ ```css
1025
+ @function --negative(--value) {
1026
+ result: calc(-1 * var(--value));
1027
+ }
1028
+ @function --shadow(--shadow-color <color>: inherit) returns <color> {
1029
+ --offset: 2px;
1030
+ result: var(--offset) var(--offset) var(--shadow-color, black);
1031
+ }
1032
+ .t0 {
1033
+ margin: --negative(10px) 0 0 0;
1034
+ box-shadow: --shadow(var(--accent-color));
1035
+ }
1036
+ ```
1037
+
1038
+ ### Descriptor shape
1039
+
1040
+ | Field | Type | Notes |
1041
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
1042
+ | `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
1043
+ | `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
1044
+ | `returns` | `string` | Optional return type, e.g. `'<color>'`. |
1045
+ | `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
1046
+
1047
+ A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
1048
+
1049
+ 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).
1050
+
1051
+ > `@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.
1052
+
1053
+ ---
1054
+
678
1055
  ## Style Properties
679
1056
 
680
1057
  For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
@@ -687,4 +1064,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
687
1064
  - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
688
1065
  - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
689
1066
  - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
690
- - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin
1067
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin