@tenphi/tasty 0.0.0-snapshot.2cbc2f8 → 0.0.0-snapshot.2e07213

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 (124) hide show
  1. package/README.md +181 -136
  2. package/dist/babel-rZcEwPLM.d.ts +82 -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-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/{collector-OvXG7KWf.js → chunks/collector-D2ARGT2L.js} +64 -99
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.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-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.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-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{merge-styles-CmWiXajN.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-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{css-writer-C8h3QlRt.js → chunks/zero-engine-gJrKBRiw.js} +37 -113
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/{collector-CpU85p2G.d.ts → collector-w4mBj5gd.d.ts} +64 -8
  34. package/dist/{config-3h7BtX4l.d.ts → config-CZWCzBr6.d.ts} +483 -79
  35. package/dist/core/index.d.ts +5 -5
  36. package/dist/core/index.js +9 -6
  37. package/dist/{index-C_SRmAWj.d.ts → index-G9JuwM9p.d.ts} +532 -390
  38. package/dist/index.d.ts +5 -5
  39. package/dist/index.js +11 -732
  40. package/dist/{merge-styles-BzOwGOGC.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 +128 -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-BsJz5xBF.d.ts → types-JEY8PVYP.d.ts} +874 -593
  74. package/dist/zero/babel.d.ts +2 -81
  75. package/dist/zero/babel.js +58 -120
  76. package/dist/zero/babel.js.map +1 -1
  77. package/dist/zero/index.d.ts +19 -6
  78. package/dist/zero/index.js +2 -2
  79. package/dist/zero/next.d.ts +3 -5
  80. package/dist/zero/next.js +0 -31
  81. package/dist/zero/next.js.map +1 -1
  82. package/docs/README.md +17 -9
  83. package/docs/adoption.md +56 -31
  84. package/docs/ai-agents.md +250 -0
  85. package/docs/comparison.md +69 -40
  86. package/docs/configuration.md +486 -85
  87. package/docs/debug.md +26 -14
  88. package/docs/design-system.md +43 -24
  89. package/docs/dsl.md +455 -189
  90. package/docs/getting-started.md +64 -41
  91. package/docs/injector.md +120 -30
  92. package/docs/methodology.md +46 -40
  93. package/docs/migration-v3.md +285 -0
  94. package/docs/pipeline.md +36 -15
  95. package/docs/plugins.md +353 -0
  96. package/docs/react-api.md +144 -42
  97. package/docs/runtime-benchmarks.md +388 -0
  98. package/docs/ssr.md +252 -86
  99. package/docs/styles.md +142 -25
  100. package/docs/tasty-static.md +141 -106
  101. package/package.json +122 -39
  102. package/tasty.config.ts +4 -0
  103. package/dist/async-storage-B7_o6FKt.js +0 -44
  104. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  105. package/dist/collector-OvXG7KWf.js.map +0 -1
  106. package/dist/config-BfqoUnBb.js +0 -10950
  107. package/dist/config-BfqoUnBb.js.map +0 -1
  108. package/dist/context-CkSg-kDT.js +0 -24
  109. package/dist/context-CkSg-kDT.js.map +0 -1
  110. package/dist/core-DlcI4RnL.js +0 -1598
  111. package/dist/core-DlcI4RnL.js.map +0 -1
  112. package/dist/css-writer-C8h3QlRt.js.map +0 -1
  113. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  114. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  115. package/dist/format-rules-D9CBkvVE.js +0 -143
  116. package/dist/format-rules-D9CBkvVE.js.map +0 -1
  117. package/dist/hydrate-sIvCdUlE.js +0 -45
  118. package/dist/hydrate-sIvCdUlE.js.map +0 -1
  119. package/dist/index.js.map +0 -1
  120. package/dist/keyframes-bg4yPrZL.js +0 -595
  121. package/dist/keyframes-bg4yPrZL.js.map +0 -1
  122. package/dist/merge-styles-CmWiXajN.js.map +0 -1
  123. package/dist/resolve-recipes-OwLUM8jV.js +0 -144
  124. package/dist/resolve-recipes-OwLUM8jV.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,6 +54,8 @@ 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
+
44
59
  #### Default State Ordering
45
60
 
46
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.
@@ -53,14 +68,18 @@ color: { '': '#text', hovered: '#accent' }
53
68
  color: { hovered: '#accent', '': '#text' }
54
69
  ```
55
70
 
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.
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.
57
72
 
58
73
  ### Sub-element
59
74
 
60
75
  Element styled using a capitalized key. Identified by `data-element` attribute:
61
76
 
62
77
  ```jsx
63
- styles: { Title: { preset: 'h3' } }
78
+ styles: {
79
+ Title: {
80
+ preset: 'h3';
81
+ }
82
+ }
64
83
  // Targets: <div data-element="Title">
65
84
  ```
66
85
 
@@ -70,19 +89,19 @@ Control how a sub-element selector attaches to the root selector using the `$` p
70
89
 
71
90
  Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
72
91
 
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 |
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 |
86
105
 
87
106
  Rules for key injection (`[data-element="..."]`):
88
107
 
@@ -111,7 +130,7 @@ const List = tasty({
111
130
  Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
112
131
 
113
132
  ```jsx
114
- fill: '#purple.5' // → var(--purple-color) with 50% opacity
133
+ fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
115
134
  ```
116
135
 
117
136
  ### Modifier
@@ -123,7 +142,7 @@ mods={{ hovered: true, theme: 'danger' }}
123
142
  // → data-hovered="" data-theme="danger"
124
143
  ```
125
144
 
126
- 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).
127
146
 
128
147
  ---
129
148
 
@@ -133,23 +152,155 @@ Modifiers can also be exposed as top-level component props via `modProps` — se
133
152
  color: '#purple', // Full opacity
134
153
  color: '#purple.5', // 50% opacity
135
154
  color: '#purple.05', // 5% opacity
155
+ color: '#purple.$fade', // Opacity from a custom property
136
156
  fill: '#current', // → currentcolor
137
- fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
138
157
  color: '(#primary, #secondary)', // Fallback syntax
139
158
  ```
140
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
+
141
292
  ---
142
293
 
143
294
  ## Built-in Units
144
295
 
145
- | Unit | Description | Example | CSS Output |
146
- |------|-------------|---------|------------|
147
- | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
148
- | `r` | Border radius | `1r` | `var(--radius)` |
149
- | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
150
- | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
151
- | `ow` | Outline width | `1ow` | `var(--outline-width)` |
152
- | `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)` |
153
304
 
154
305
  You can register additional custom units via [`configure()`](configuration.md#options).
155
306
 
@@ -192,9 +343,29 @@ const ElevatedCard = tasty({
192
343
  });
193
344
  ```
194
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
+
195
366
  **Post-merge recipes (`/` separator):**
196
367
 
197
- Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
368
+ Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
198
369
 
199
370
  ```jsx
200
371
  const Input = tasty({
@@ -232,8 +403,8 @@ When a style property uses a state map, the merge behavior depends on whether th
232
403
  const MyButton = tasty(Button, {
233
404
  styles: {
234
405
  fill: {
235
- 'loading': '#yellow', // append new state
236
- 'disabled': '#gray.20', // override existing state in place
406
+ loading: '#yellow', // append new state
407
+ disabled: '#gray.20', // override existing state in place
237
408
  },
238
409
  },
239
410
  });
@@ -243,7 +414,7 @@ const MyButton = tasty(Button, {
243
414
  styles: {
244
415
  fill: {
245
416
  '': '#red',
246
- 'hovered': '#blue',
417
+ hovered: '#blue',
247
418
  },
248
419
  },
249
420
  });
@@ -268,8 +439,12 @@ fill: {
268
439
  Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
269
440
 
270
441
  ```jsx
271
- fill: { pressed: null } // removes pressed from the result
272
- 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
273
448
  ```
274
449
 
275
450
  ### Resetting Properties with `null` and `false`
@@ -277,36 +452,36 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
277
452
  ```jsx
278
453
  const SimpleButton = tasty(Button, {
279
454
  styles: {
280
- fill: null, // discard parent's fill, let recipe fill in
455
+ fill: null, // discard parent's fill, let recipe fill in
281
456
  border: false, // no border at all (tombstone — blocks recipe too)
282
457
  },
283
458
  });
284
459
  ```
285
460
 
286
- | Value | Meaning | Recipe fills in? |
287
- |-------|---------|-----------------|
288
- | `undefined` | Not provided — parent preserved | N/A |
289
- | `null` | Intentional unset — parent discarded | Yes |
290
- | `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 |
291
466
 
292
467
  ---
293
468
 
294
469
  ## Advanced States (`@` prefix)
295
470
 
296
- | Prefix | Purpose | Example |
297
- |--------|---------|---------|
298
- | `@media` | Media queries | `@media(w < 768px)` |
299
- | `@(...)` | Container queries | `@(panel, w >= 300px)` |
300
- | `@supports` | Feature/selector support | `@supports(display: grid)` |
301
- | `@root` | Root element states | `@root(schema=dark)` |
302
- | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
303
- | `@own` | Sub-element's own state | `@own(hovered)` |
304
- | `@starting` | Entry animation | `@starting` |
305
- | `_` | Fallback floor (always-on, never negated) | `_` |
306
- | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
307
- | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
308
- | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
309
- | `: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)` |
310
485
 
311
486
  > **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
312
487
  > `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
@@ -322,9 +497,9 @@ const SimpleButton = tasty(Button, {
322
497
  Media queries support dimension shorthands and custom unit expansion:
323
498
 
324
499
  | Shorthand | Expands to |
325
- |-----------|------------|
326
- | `w` | `width` |
327
- | `h` | `height` |
500
+ | --------- | ---------- |
501
+ | `w` | `width` |
502
+ | `h` | `height` |
328
503
 
329
504
  ```jsx
330
505
  fill: {
@@ -335,14 +510,14 @@ fill: {
335
510
  }
336
511
  ```
337
512
 
338
- | Tasty syntax | CSS output |
339
- |--------------|------------|
340
- | `@media(w < 768px)` | `@media (width < 768px)` |
341
- | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
342
- | `@media:print` | `@media print` |
343
- | `@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` |
344
519
  | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
345
- | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
520
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
346
521
 
347
522
  Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
348
523
 
@@ -352,12 +527,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
352
527
 
353
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`.
354
529
 
355
- | Shorthand | Expands to |
356
- |-----------|------------|
357
- | `w` | `width` |
358
- | `h` | `height` |
359
- | `is` | `inline-size` |
360
- | `bs` | `block-size` |
530
+ | Shorthand | Expands to |
531
+ | --------- | ------------- |
532
+ | `w` | `width` |
533
+ | `h` | `height` |
534
+ | `is` | `inline-size` |
535
+ | `bs` | `block-size` |
361
536
 
362
537
  ```jsx
363
538
  const Panel = tasty({
@@ -370,26 +545,29 @@ const Panel = tasty({
370
545
  });
371
546
  ```
372
547
 
373
- | Tasty syntax | CSS output |
374
- |--------------|------------|
375
- | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
376
- | `@(w < 600px)` | `@container (width < 600px)` |
377
- | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
378
- | `@(layout, $compact)` | `@container layout style(--compact)` |
379
- | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
380
- | `@(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)` |
381
556
 
382
557
  Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
383
558
 
384
559
  ### `@supports(...)` — Feature Queries
385
560
 
386
- 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:
387
563
 
388
- | Tasty syntax | CSS output |
389
- |--------------|------------|
390
- | `@supports(display: grid)` | `@supports (display: grid)` |
391
- | `@supports($, :has(*))` | `@supports selector(:has(*))` |
392
- | `!@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)))` |
393
571
 
394
572
  ```jsx
395
573
  display: {
@@ -398,6 +576,25 @@ display: {
398
576
  }
399
577
  ```
400
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
+
401
598
  ### `_` — Fallback Floor
402
599
 
403
600
  By default Tasty makes states **mutually exclusive**: a higher-priority state
@@ -407,7 +604,7 @@ that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
407
604
  just true/false), and `not(unknown)` is also unknown — so a negated default
408
605
  branch silently never applies. The classic case is `scroll-state`: a browser can
409
606
  support `container-type: scroll-state` while a specific `scroll-state(...)` query
410
- is unknown, leaving *no* branch active.
607
+ is unknown, leaving _no_ branch active.
411
608
 
412
609
  The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
413
610
  **always applies** as a guaranteed floor: it never receives negation, and
@@ -422,10 +619,14 @@ inset: {
422
619
  ```
423
620
 
424
621
  ```css
425
- .t0.t0 { inset: 0 ...; }
622
+ .t0.t0 {
623
+ inset: 0...;
624
+ }
426
625
  @container scroll-state(scrolled: block-end) {
427
626
  @supports (container-type: scroll-state) {
428
- .t0.t0 { inset: -80px ...; }
627
+ .t0.t0 {
628
+ inset: -80px...;
629
+ }
429
630
  }
430
631
  }
431
632
  ```
@@ -456,13 +657,13 @@ cause is always the same: **`''` is mutually exclusive (turned off by negation),
456
657
  while `_` is always on (layered underneath).**
457
658
 
458
659
  - **Unknown / invalid branches.** If a higher-priority branch sits behind a query
459
- that can be *unknown* (`@supports`, container, `scroll-state`) or uses a
660
+ that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
460
661
  selector the browser drops, the negated `''` default disappears along with it
461
662
  (`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
462
663
  survives because it is an unconditional bare rule. This is the case `_` exists
463
664
  for.
464
665
 
465
- - **Empty / "unset" states.** A state can intentionally produce *no* output (an
666
+ - **Empty / "unset" states.** A state can intentionally produce _no_ output (an
466
667
  empty value) to leave a property unset while that state is active. With `''`
467
668
  this works — the default is negated away and nothing replaces it, so the
468
669
  property unsets. With `_` the floor can never be turned off, so its value keeps
@@ -474,14 +675,14 @@ while `_` is always on (layered underneath).**
474
675
  ```
475
676
 
476
677
  - **States with different output shapes.** Because `_` layers additively, when
477
- different states emit *different sets* of declarations, the floor's
678
+ different states emit _different sets_ of declarations, the floor's
478
679
  declarations bleed through wherever the winning state does not override the
479
680
  same property — which can produce inconsistent combinations. A `''` default is
480
681
  swapped out cleanly by its mutually-exclusive condition.
481
682
 
482
683
  Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
483
684
  supports unsetting), and reach for `_` only when a value must survive an
484
- *unknown* higher-priority branch.
685
+ _unknown_ higher-priority branch.
485
686
 
486
687
  ### `@root(...)` — Root Element States
487
688
 
@@ -497,13 +698,13 @@ color: {
497
698
  }
498
699
  ```
499
700
 
500
- | Tasty syntax | CSS selector |
501
- |--------------|-------------|
502
- | `@root(schema=dark)` | `:root[data-schema="dark"]` |
503
- | `@root(hovered)` | `:root[data-hovered]` |
504
- | `@root(.premium-user)` | `:root.premium-user` |
505
- | `@root([lang="en"])` | `:root[lang="en"]` |
506
- | `!@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"])` |
507
708
 
508
709
  Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
509
710
 
@@ -519,7 +720,7 @@ const Nav = tasty({
519
720
  '': '#text',
520
721
  '@own(:hover)': '#primary',
521
722
  '@own(:focus-visible)': '#primary',
522
- 'selected': '#primary', // root-level modifier
723
+ selected: '#primary', // root-level modifier
523
724
  },
524
725
  },
525
726
  },
@@ -527,11 +728,11 @@ const Nav = tasty({
527
728
  });
528
729
  ```
529
730
 
530
- | Tasty syntax (inside sub-element) | CSS output |
531
- |-----------------------------------|------------|
532
- | `@own(:hover)` | `:hover` on the sub-element selector |
533
- | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
534
- | `@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 |
535
736
 
536
737
  `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
537
738
 
@@ -544,14 +745,14 @@ const FadeIn = tasty({
544
745
  styles: {
545
746
  opacity: { '': '1', '@starting': '0' },
546
747
  transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
547
- transition: 'opacity 0.3s, translate 0.3s',
748
+ transition: 'opacity, translate',
548
749
  },
549
750
  });
550
751
  ```
551
752
 
552
- | Tasty syntax | CSS output |
553
- |--------------|------------|
554
- | `@starting` | `@starting-style { .t0.t0 { ... } }` |
753
+ | Tasty syntax | CSS output |
754
+ | ------------ | ------------------------------------ |
755
+ | `@starting` | `@starting-style { .t0.t0 { ... } }` |
555
756
 
556
757
  ### `@parent(...)` — Parent Element States
557
758
 
@@ -562,22 +763,22 @@ const Highlight = tasty({
562
763
  styles: {
563
764
  fill: {
564
765
  '': '#white',
565
- '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
566
- '@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"]
567
768
  },
568
769
  },
569
770
  });
570
771
  ```
571
772
 
572
- | Syntax | CSS Output |
573
- |--------|------------|
574
- | `@parent(hovered)` | `:is([data-hovered] *)` |
575
- | `!@parent(hovered)` | `:not([data-hovered] *)` |
576
- | `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
577
- | `@parent(.active)` | `:is(.active *)` |
578
- | `@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) |
579
780
  | `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
580
- | `@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) |
581
782
 
582
783
  For sub-elements, the parent check applies to the root element's ancestors:
583
784
 
@@ -608,38 +809,38 @@ const Card = tasty({
608
809
  styles: {
609
810
  display: {
610
811
  '': 'block',
611
- ':has(> Icon)': 'grid', // has Icon as direct child
612
- ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
613
- ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
614
- ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
615
- ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
616
- ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
617
- '!: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
618
819
  },
619
820
  },
620
821
  });
621
822
  ```
622
823
 
623
- | Syntax | CSS Output | Meaning |
624
- |--------|------------|---------|
625
- | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
626
- | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
627
- | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
628
- | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
629
- | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
630
- | `:has(>)` | `:has(> *)` | Has any direct child |
631
- | `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
632
- | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
633
- | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
634
- | `!: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`) |
635
836
 
636
837
  Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
637
838
 
638
839
  ```jsx
639
- ':has(> Icon) & hovered' // AND: structural + data attribute
640
- '@parent(hovered) & :has(> Icon)' // AND: parent check + structural
641
- ':has(> Icon) | :has(> Button)' // OR: either sub-element present
642
- ':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
643
844
  ```
644
845
 
645
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.
@@ -675,38 +876,38 @@ const AnimatedGradient = tasty({
675
876
  styles: {
676
877
  '$gradient-angle': '0deg',
677
878
  '#theme': 'okhst(280 80% 50%)',
678
- background: 'linear-gradient($gradient-angle, #theme, transparent)',
679
- transition: '$$gradient-angle 0.3s, ##theme 0.3s',
879
+ image: 'linear-gradient($gradient-angle, #theme, #clear)',
880
+ transition: '$$gradient-angle, ##theme',
680
881
  },
681
882
  });
682
883
  ```
683
884
 
684
885
  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.
685
886
 
686
- Use explicit `@properties` when you need non-default settings like `inherits: false`:
887
+ Use explicit `@property` when you need non-default settings like `inherits: false`:
687
888
 
688
889
  ```jsx
689
- '@properties': {
890
+ '@property': {
690
891
  '$gradient-angle': { syntax: '<angle>', inherits: false, initialValue: '0deg' },
691
892
  },
692
893
  ```
693
894
 
694
895
  ---
695
896
 
696
- ## Font Face (`@fontFace`)
897
+ ## Font Face (`@font-face`)
697
898
 
698
899
  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).
699
900
 
700
901
  ```ts
701
902
  const Heading = tasty({
702
903
  styles: {
703
- '@fontFace': {
904
+ '@font-face': {
704
905
  'Brand Sans': {
705
906
  src: 'url("/fonts/brand-sans.woff2") format("woff2")',
706
907
  fontDisplay: 'swap',
707
908
  },
708
909
  },
709
- fontFamily: '"Brand Sans", sans-serif',
910
+ font: '"Brand Sans", sans-serif',
710
911
  },
711
912
  });
712
913
  ```
@@ -716,7 +917,7 @@ const Heading = tasty({
716
917
  Supply an array to register several variants of the same family:
717
918
 
718
919
  ```ts
719
- '@fontFace': {
920
+ '@font-face': {
720
921
  'Brand Sans': [
721
922
  { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
722
923
  { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
@@ -726,26 +927,26 @@ Supply an array to register several variants of the same family:
726
927
 
727
928
  ### Supported descriptors
728
929
 
729
- | Descriptor | CSS property | Type |
730
- |---|---|---|
731
- | `src` (required) | `src` | `string` |
732
- | `fontWeight` | `font-weight` | `string \| number` |
733
- | `fontStyle` | `font-style` | `string` |
734
- | `fontStretch` | `font-stretch` | `string` |
735
- | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
736
- | `unicodeRange` | `unicode-range` | `string` |
737
- | `ascentOverride` | `ascent-override` | `string` |
738
- | `descentOverride` | `descent-override` | `string` |
739
- | `lineGapOverride` | `line-gap-override` | `string` |
740
- | `sizeAdjust` | `size-adjust` | `string` |
741
- | `fontFeatureSettings` | `font-feature-settings` | `string` |
742
- | `fontVariationSettings` | `font-variation-settings` | `string` |
930
+ | Descriptor | CSS property | Type |
931
+ | ----------------------- | ------------------------- | --------------------------------------------------------- |
932
+ | `src` (required) | `src` | `string` |
933
+ | `fontWeight` | `font-weight` | `string \| number` |
934
+ | `fontStyle` | `font-style` | `string` |
935
+ | `fontStretch` | `font-stretch` | `string` |
936
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
937
+ | `unicodeRange` | `unicode-range` | `string` |
938
+ | `ascentOverride` | `ascent-override` | `string` |
939
+ | `descentOverride` | `descent-override` | `string` |
940
+ | `lineGapOverride` | `line-gap-override` | `string` |
941
+ | `sizeAdjust` | `size-adjust` | `string` |
942
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
943
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
743
944
 
744
945
  > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
745
946
 
746
947
  ---
747
948
 
748
- ## Counter Style (`@counterStyle`)
949
+ ## Counter Style (`@counter-style`)
749
950
 
750
951
  Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
751
952
 
@@ -753,7 +954,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
753
954
  const EmojiList = tasty({
754
955
  tag: 'ol',
755
956
  styles: {
756
- '@counterStyle': {
957
+ '@counter-style': {
757
958
  thumbs: {
758
959
  system: 'cyclic',
759
960
  symbols: '"👍"',
@@ -767,23 +968,88 @@ const EmojiList = tasty({
767
968
 
768
969
  ### Supported descriptors
769
970
 
770
- | Descriptor | CSS property | Type |
771
- |---|---|---|
772
- | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
773
- | `symbols` | `symbols` | `string` |
774
- | `additiveSymbols` | `additive-symbols` | `string` |
775
- | `prefix` | `prefix` | `string` |
776
- | `suffix` | `suffix` | `string` |
777
- | `negative` | `negative` | `string` |
778
- | `range` | `range` | `string` |
779
- | `pad` | `pad` | `string` |
780
- | `fallback` | `fallback` | `string` |
781
- | `speakAs` | `speak-as` | `string` |
971
+ | Descriptor | CSS property | Type |
972
+ | ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
973
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
974
+ | `symbols` | `symbols` | `string` |
975
+ | `additiveSymbols` | `additive-symbols` | `string` |
976
+ | `prefix` | `prefix` | `string` |
977
+ | `suffix` | `suffix` | `string` |
978
+ | `negative` | `negative` | `string` |
979
+ | `range` | `range` | `string` |
980
+ | `pad` | `pad` | `string` |
981
+ | `fallback` | `fallback` | `string` |
982
+ | `speakAs` | `speak-as` | `string` |
782
983
 
783
984
  > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
784
985
 
785
986
  ---
786
987
 
988
+ ## Functions (`@function`)
989
+
990
+ 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.
991
+
992
+ The token convention follows Tasty's `$` vs `$$` distinction:
993
+
994
+ - **`$$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.
995
+ - **`$name`** — a custom-property declaration/reference (`var(--name)`). Used for **parameters** and **local variables**, exactly like declaring custom props in a styles object.
996
+ - **Local variables** are declared directly as `$name` keys on the descriptor — the body reads like a mini styles object.
997
+ - `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.
998
+
999
+ ```ts
1000
+ const Box = tasty({
1001
+ styles: {
1002
+ '@function': {
1003
+ // simplest: one bare param + result (auto-calc, no explicit calc())
1004
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
1005
+
1006
+ // typed param + default + return type + local variable
1007
+ $$shadow: {
1008
+ args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
1009
+ returns: '<color>',
1010
+ $offset: '2px', // local variable
1011
+ result: '$offset $offset ($shadow-color, black)',
1012
+ },
1013
+ },
1014
+ margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
1015
+ shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
1016
+ },
1017
+ });
1018
+ ```
1019
+
1020
+ Generated CSS:
1021
+
1022
+ ```css
1023
+ @function --negative(--value) {
1024
+ result: calc(-1 * var(--value));
1025
+ }
1026
+ @function --shadow(--shadow-color <color>: inherit) returns <color> {
1027
+ --offset: 2px;
1028
+ result: var(--offset) var(--offset) var(--shadow-color, black);
1029
+ }
1030
+ .t0 {
1031
+ margin: --negative(10px) 0 0 0;
1032
+ box-shadow: --shadow(var(--accent-color));
1033
+ }
1034
+ ```
1035
+
1036
+ ### Descriptor shape
1037
+
1038
+ | Field | Type | Notes |
1039
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
1040
+ | `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
1041
+ | `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
1042
+ | `returns` | `string` | Optional return type, e.g. `'<color>'`. |
1043
+ | `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
1044
+
1045
+ A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
1046
+
1047
+ 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).
1048
+
1049
+ > `@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.
1050
+
1051
+ ---
1052
+
787
1053
  ## Style Properties
788
1054
 
789
1055
  For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
@@ -796,4 +1062,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
796
1062
  - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
797
1063
  - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
798
1064
  - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
799
- - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin
1065
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin