@tenphi/tasty 0.0.0-snapshot.047dfbb → 0.0.0-snapshot.04fb534

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 (134) hide show
  1. package/README.md +452 -370
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config--0qoqt_P.js +60 -0
  6. package/dist/chunks/build-config--0qoqt_P.js.map +1 -0
  7. package/dist/{collector-J6LwZR0N.js → chunks/collector-zp5BrLF0.js} +68 -101
  8. package/dist/chunks/collector-zp5BrLF0.js.map +1 -0
  9. package/dist/chunks/config-engine-BaLq8HrX.js +272 -0
  10. package/dist/chunks/config-engine-BaLq8HrX.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-CfXZ3tU9.js +910 -0
  14. package/dist/chunks/css-definitions-CfXZ3tU9.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug--OC-WA-Q.js +502 -0
  18. package/dist/chunks/debug--OC-WA-Q.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DnZ6M1Iv.js +691 -0
  24. package/dist/chunks/react-runtime-DnZ6M1Iv.js.map +1 -0
  25. package/dist/chunks/runtime-engine-J9X_h-Pw.js +2435 -0
  26. package/dist/chunks/runtime-engine-J9X_h-Pw.js.map +1 -0
  27. package/dist/chunks/runtime-state-o_v3Bj7b.js +152 -0
  28. package/dist/chunks/runtime-state-o_v3Bj7b.js.map +1 -0
  29. package/dist/{merge-styles-CAdKaHxh.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D6lC3O3G.js +5626 -0
  32. package/dist/chunks/style-engine-D6lC3O3G.js.map +1 -0
  33. package/dist/{css-writer-IC7tdnIf.js → chunks/zero-engine-BnjoV04F.js} +95 -136
  34. package/dist/chunks/zero-engine-BnjoV04F.js.map +1 -0
  35. package/dist/{collector-CddJZDOr.d.ts → collector-D2OT6I2G.d.ts} +64 -8
  36. package/dist/{config-C3SKYuxY.d.ts → config-C4ftFxgI.d.ts} +514 -92
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-ByBYTH9l.d.ts → index-DxQNRj50.d.ts} +586 -400
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-CvUi7SOD.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +160 -86
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +5 -32
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +9 -8
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/{index-C5owZ15q.d.ts → types-CYQIhUg1.d.ts} +874 -598
  78. package/dist/zero/babel.d.ts +12 -19
  79. package/dist/zero/babel.js +97 -156
  80. package/dist/zero/babel.js.map +1 -1
  81. package/dist/zero/index.d.ts +76 -7
  82. package/dist/zero/index.js +25 -2
  83. package/dist/zero/index.js.map +1 -0
  84. package/dist/zero/next.d.ts +4 -5
  85. package/dist/zero/next.js +3 -38
  86. package/dist/zero/next.js.map +1 -1
  87. package/docs/README.md +20 -9
  88. package/docs/adoption.md +69 -36
  89. package/docs/ai-agents.md +259 -0
  90. package/docs/comparison.md +77 -47
  91. package/docs/configuration.md +617 -98
  92. package/docs/debug.md +28 -15
  93. package/docs/design-system.md +166 -33
  94. package/docs/dsl.md +637 -205
  95. package/docs/getting-started.md +130 -50
  96. package/docs/injector.md +160 -69
  97. package/docs/llms.txt +31 -0
  98. package/docs/methodology.md +82 -51
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +57 -33
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +215 -50
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -118
  105. package/docs/styles.md +209 -41
  106. package/docs/tasty-static.md +289 -136
  107. package/harness/dev.harnesspm/rules/usage.md +12 -0
  108. package/harness/dev.harnesspm/scripts/render.mjs +441 -0
  109. package/harness/dev.harnesspm/scripts/styles.mjs +412 -0
  110. package/harness/plugin.json +20 -0
  111. package/package.json +148 -49
  112. package/tasty.config.ts +5 -0
  113. package/dist/async-storage-DKK-wTD4.js +0 -44
  114. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  115. package/dist/collector-J6LwZR0N.js.map +0 -1
  116. package/dist/config-C3F4Ogo1.js +0 -10993
  117. package/dist/config-C3F4Ogo1.js.map +0 -1
  118. package/dist/context-CA8YKeMn.js +0 -24
  119. package/dist/context-CA8YKeMn.js.map +0 -1
  120. package/dist/core-DxHmF6S9.js +0 -1598
  121. package/dist/core-DxHmF6S9.js.map +0 -1
  122. package/dist/css-writer-IC7tdnIf.js.map +0 -1
  123. package/dist/format-global-rules-DklyaXv-.js +0 -22
  124. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  125. package/dist/format-rules-DTLY39Hm.js +0 -143
  126. package/dist/format-rules-DTLY39Hm.js.map +0 -1
  127. package/dist/hydrate-8Zglgy_C.js +0 -45
  128. package/dist/hydrate-8Zglgy_C.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/keyframes-DgGkipNK.js +0 -595
  131. package/dist/keyframes-DgGkipNK.js.map +0 -1
  132. package/dist/merge-styles-CAdKaHxh.js.map +0 -1
  133. package/dist/resolve-recipes-BQNdunBd.js +0 -144
  134. package/dist/resolve-recipes-BQNdunBd.js.map +0 -1
package/docs/dsl.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Style DSL Reference
2
2
 
3
- This is the Tasty style language reference — the value syntax, state mappings, tokens, units, extending semantics, and special declarations that apply to both runtime `tasty()` and build-time `tastyStatic()`.
3
+ This is the language behind Tasty’s predictable state resolution. Every property can use a state map; later branches declare higher priority, and Tasty compiles them so only one generated selector can match.
4
4
 
5
- For the runtime React API (`tasty()`, hooks, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
5
+ The same value syntax, state maps, tokens, units, extension semantics, and special declarations apply to React `tasty()`—whether rendered on the client or server—and build-time `tastyStatic()`.
6
+
7
+ For the React API (`tasty()`, style functions, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
8
+
9
+ To autocomplete your own token and preset names, see [TypeScript autocomplete](getting-started.md#typescript-autocomplete); to check state keys, tokens, units, and values at lint time, see [ESLint plugin](getting-started.md#eslint-plugin).
6
10
 
7
11
  ---
8
12
 
@@ -16,22 +20,65 @@ Object where keys represent states and values are the styles to apply:
16
20
  fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
17
21
  ```
18
22
 
23
+ Define an alias for one component by adding an `'@name': '<state expression>'` key to its styles. It works like a global alias from [`configure({ states })`](configuration.md#options), scoped to that component:
24
+
25
+ ```jsx
26
+ styles: {
27
+ '@narrow': '@media(w < 600px)',
28
+ fill: { '': '#surface', '@narrow': '#surface-mobile' },
29
+ }
30
+ ```
31
+
32
+ An alias can use other aliases, anywhere in its expression:
33
+
34
+ ```jsx
35
+ configure({
36
+ states: {
37
+ '@mobile': '@media(w < 768px)',
38
+ '@collapsed': '@mobile & !expanded',
39
+ },
40
+ });
41
+
42
+ styles: {
43
+ '@compact': '@collapsed | @media:print', // local, built on a global alias
44
+ padding: { '': '4x', '@compact': '2x' },
45
+ }
46
+ ```
47
+
48
+ - A local alias sees the component's aliases first, then the global ones. Aliases declared inside a sub-element also see the root-level ones.
49
+ - A global alias sees only global aliases. It means the same thing in every component: if a component redefines `@mobile` locally, the global `@collapsed` keeps using the global `@mobile`.
50
+ - A circular alias (`'@a': '@b'` with `'@b': '@a'`, or `'@a': '@a & hovered'`) never matches, and a `CIRCULAR_STATE_ALIAS` warning names the loop.
51
+
19
52
  #### State Key Types
20
53
 
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]` |
54
+ | Syntax | Example | Generated CSS |
55
+ | ------------------ | ------------------------ | ------------------------------------------------------------------------ |
56
+ | Boolean modifier | `hovered` | `[data-hovered]` |
57
+ | Value modifier | `theme=danger` | `[data-theme="danger"]` |
58
+ | Pseudo-class | `:hover` | `:hover` |
59
+ | Class selector | `.active` | `.active` |
60
+ | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
61
+ | Combined (AND) | `hovered & .active` | `[data-hovered].active` |
62
+ | Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
63
+ | Negated (NOT) | `!disabled` | `:not([data-disabled])` |
64
+ | Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
65
+
66
+ #### Automatic Native States
67
+
68
+ `disabled`, `checked`, and `hidden` are built-in automatic states. A Tasty component sets `data-disabled`, `data-checked`, and `data-hidden` from the native `disabled`, `checked`, and `hidden` props (or `isDisabled`, `isChecked`, `isHidden`), so each pair below expresses the same component state:
69
+
70
+ | Concise Tasty state | Compiles to | Explicit attribute selector |
71
+ | ------------------- | ----------------- | --------------------------- |
72
+ | `disabled` | `[data-disabled]` | `[disabled]` |
73
+ | `checked` | `[data-checked]` | `[checked]` |
74
+ | `hidden` | `[data-hidden]` | `[hidden]` |
75
+
76
+ 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
77
 
33
78
  Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
34
79
 
80
+ A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
81
+
35
82
  `^` (XOR) means "exactly one of" — `A ^ B` expands to `(A & !B) | (!A & B)`. This is useful for mutually exclusive states where exactly one should be active:
36
83
 
37
84
  ```jsx
@@ -41,6 +88,8 @@ fill: {
41
88
  }
42
89
  ```
43
90
 
91
+ 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.
92
+
44
93
  #### Default State Ordering
45
94
 
46
95
  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 +102,16 @@ color: { '': '#text', hovered: '#accent' }
53
102
  color: { hovered: '#accent', '': '#text' }
54
103
  ```
55
104
 
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.
105
+ 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
106
 
58
107
  ### Sub-element
59
108
 
60
109
  Element styled using a capitalized key. Identified by `data-element` attribute:
61
110
 
62
111
  ```jsx
63
- styles: { Title: { preset: 'h3' } }
112
+ styles: {
113
+ Title: { preset: 'h3' },
114
+ }
64
115
  // Targets: <div data-element="Title">
65
116
  ```
66
117
 
@@ -70,19 +121,19 @@ Control how a sub-element selector attaches to the root selector using the `$` p
70
121
 
71
122
  Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
72
123
 
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 |
124
+ | Pattern | Result | Description |
125
+ | ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
126
+ | _(none)_ | `[data-element="Cell"]` | Descendant (default) |
127
+ | `>` | `> [data-element="Cell"]` | Direct child |
128
+ | `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
129
+ | `> 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 |
130
+ | `h1` | `h1` | Tag selector (no key injection) |
131
+ | `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
132
+ | `h1 *` | `h1 *` | Any descendant of tag |
133
+ | `*` | `*` | All descendants |
134
+ | `&::before` | `::before` | Root pseudo (no key); `&` is required |
135
+ | `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
136
+ | `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
86
137
 
87
138
  Rules for key injection (`[data-element="..."]`):
88
139
 
@@ -98,20 +149,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
98
149
  const List = tasty({
99
150
  styles: {
100
151
  Item: {
101
- $: '>@:last-child',
102
- border: 'none',
152
+ $: '>@::after',
153
+ content: '""',
103
154
  },
104
155
  },
105
156
  });
106
- // → .t0 > [data-element="Item"]:last-child { border: none }
157
+ // → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
107
158
  ```
108
159
 
160
+ Keep conditions such as `:last-child` out of `$` and write them as `@own(:last-child)` in a state map; `tasty/no-state-in-selector` warns otherwise. When `$` ends in a pseudo-element, `@own()` describes the pseudo-element instead (see [`@own(...)`](#own--sub-elements-own-state)), so a condition on the element it belongs to stays in `$`, before the pseudo-element: `$: 'a[rel="next"]::before'`.
161
+
109
162
  ### Color Token
110
163
 
111
164
  Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
112
165
 
113
166
  ```jsx
114
- fill: '#purple.5' // → var(--purple-color) with 50% opacity
167
+ fill: '#purple.5'; // → color-mix(in oklab, var(--purple-color) 50%, transparent)
115
168
  ```
116
169
 
117
170
  ### Modifier
@@ -123,7 +176,7 @@ mods={{ hovered: true, theme: 'danger' }}
123
176
  // → data-hovered="" data-theme="danger"
124
177
  ```
125
178
 
126
- Modifiers can also be exposed as top-level component props via `modProps` — see [Runtime — Mod Props](react-api.md#mod-props).
179
+ Modifiers can also be exposed as top-level component props via `modProps` — see [React API — Mod Props](react-api.md#mod-props).
127
180
 
128
181
  ---
129
182
 
@@ -133,25 +186,242 @@ Modifiers can also be exposed as top-level component props via `modProps` — se
133
186
  color: '#purple', // Full opacity
134
187
  color: '#purple.5', // 50% opacity
135
188
  color: '#purple.05', // 5% opacity
189
+ color: '#purple.$fade', // Opacity from a custom property
136
190
  fill: '#current', // → currentcolor
137
- fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
191
+ fill: '#surface+#dark.04', // #dark at 4% opacity over #surface, as one color
138
192
  color: '(#primary, #secondary)', // Fallback syntax
139
193
  ```
140
194
 
195
+ `#white`, `#black`, `#border`, and `#outline` are registered by default (see [Default properties](#default-properties)), and `#clear` is a built-in alias for `transparent` (see [below](#clear-is-transparent)), so they work before you define any tokens.
196
+
197
+ A name that is also a hex color is read as a token with the literal as its fallback, in every color style: `color: '#ddd'` emits `var(--ddd-color, #ddd)`, and `#ddd.5` emits `color-mix(in oklab, var(--ddd-color, #ddd) 50%, transparent)`. A `#ddd` token, if you define one, wins over the literal.
198
+
199
+ The suffix fades the token's color by mixing it with `transparent`:
200
+
201
+ ```jsx
202
+ fill: '#purple.5';
203
+ // → color-mix(in oklab, var(--purple-color) 50%, transparent)
204
+ ```
205
+
206
+ The mix asks nothing of the color beyond _being_ a color. That means the suffix
207
+ works on every one of these:
208
+
209
+ - a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
210
+ Tasty cannot convert — none of which have channels to decompose
211
+ - `#current`, which resolves to the color the element inherits
212
+ - a `--name-color` variable declared in your own CSS, with no Tasty token
213
+ definition behind it
214
+
215
+ `color-mix()` is Baseline widely available (Chrome 111, Firefox 113, Safari
216
+ 16.2). Two properties follow from mixing rather than writing an alpha channel:
217
+
218
+ - **Alpha composes.** The mix is premultiplied, so a color that is already
219
+ translucent is faded further: a token holding `rgb(255 0 0 / .8)` faded to
220
+ `.5` is alpha `.4`. An opaque token — the usual case — ends at exactly the
221
+ suffix. System colors are whatever the platform draws, and some are
222
+ translucent: Chrome and Safari on macOS give `Highlight` an alpha of `.6`, so
223
+ a token holding it faded to `.5` ends at `.3` there.
224
+ - **A `$prop` alpha must be a number.** `#purple.$fade` emits
225
+ `calc(var(--fade) * 100%)`, because a mix percentage cannot be a `<number>`,
226
+ so `$fade` has to hold `.5`, not `50%`.
227
+
228
+ ### `#clear` is transparent
229
+
230
+ `#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
231
+ Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
232
+ `transparent`. The same rule applies to user-defined replace tokens resolving
233
+ to `transparent`, including aliases of `#clear`.
234
+
235
+ It does not read `--clear-color` or require an `@property` registration.
236
+ An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
237
+ default alias and uses the replacement's usual opacity behavior.
238
+
239
+ ### `#current` is the keyword
240
+
241
+ `#current` emits the `currentcolor` keyword, so it resolves against the element
242
+ that reads it. That is what lets it follow a color an ancestor faded — a ramp
243
+ that expresses its disabled state once, in `color`, fades everything painted from
244
+ `#current` below it with no further declarations.
245
+
246
+ The `color` style also publishes `--current-color` beside every color it sets,
247
+ for anything that needs the inherited color _as a color_ rather than as the
248
+ keyword — hand-authored CSS, or a place the keyword will not do. Read it as
249
+ `$current-color`. It is registered with `initial-value: currentcolor`, so where
250
+ nothing published it, it still resolves against each element's own color:
251
+
252
+ ```jsx
253
+ fill: '$current-color'; // → var(--current-color)
254
+ ```
255
+
256
+ A color that already reads the color it inherits — `#current`, a `#current` fade
257
+ — is not published into it: resolving such a value a second time at a descendant
258
+ would fade it twice.
259
+
260
+ ### `#current` fades compose
261
+
262
+ `currentcolor` is the color an element **inherits**, which an ancestor may
263
+ already have faded, so `#current.4` means "40% of what reaches me":
264
+
265
+ ```jsx
266
+ fill: '#current.4';
267
+ // → color-mix(in oklab, currentcolor 40%, transparent)
268
+ ```
269
+
270
+ A `#current` fade nested inside another one composes: a label at `#current.4`
271
+ with a fill of `#current.18` under it lands at `.072`. Color ramps built on
272
+ `#current` depend on that.
273
+
274
+ Fades always mix `in oklab`: it is unbounded, so a wide-gamut color is not
275
+ clamped, and rectangular, so there is no hue to interpolate against
276
+ `transparent`. Nothing configures it — see
277
+ [Color space](configuration.md#color-space).
278
+
279
+ ### Compound colors
280
+
281
+ Join color tokens with `+` to paint each one, at its own opacity, over the
282
+ colors before it. The result is one color, so it works anywhere a token does:
283
+
284
+ ```jsx
285
+ fill: '#surface+#dark.04',
286
+ // → color-mix(in srgb, var(--dark-color) 4%, var(--surface-color))
287
+
288
+ border: '1bw #border+#dark.1',
289
+ color: 'light-dark(#primary+#black.2, #primary+#white.2)',
290
+ '#hover-surface': '#surface-2+#surface-text.03',
291
+ ```
292
+
293
+ Read it left to right, bottom layer first: `#surface+#accent.1+#dark.04` paints
294
+ `#accent` at 10% over `#surface`, then `#dark` at 4% over that. Every operand is
295
+ an ordinary token — `#current`, `#clear`, a hex color, a replace token — and
296
+ takes its opacity suffix as it does anywhere: `#surface+#dark.$hover` reads the
297
+ opacity from `$hover`, and a faded base such as `#surface.5+#dark.04` is layered
298
+ as it is.
299
+
300
+ The layers mix in sRGB, the space browsers composite in, so the color is exactly
301
+ what stacking them as layers would show — but it is one color, which contrast
302
+ checkers can read and transitions interpolate. A faded base is exact too:
303
+ `#surface.5+#dark.04` is as translucent as the two layers would be.
304
+
305
+ Every layer's token has to be opaque. The mix counts a layer's own alpha as well
306
+ as its opacity suffix, and lowers the alpha of the whole color, so a layer token
307
+ that holds a translucent color, or turns transparent in some state, leaves the
308
+ result see-through: with `'#overlay': { '': '#clear', hovered: '#dark' }`,
309
+ `'#surface+#overlay.04'` is 96% opaque at rest. Vary the opacity instead
310
+ (`'#surface+#dark.$hover'`), or give each state its own color
311
+ (`fill: { '': '#surface', hovered: '#surface+#dark.04' }`).
312
+
313
+ - Write it as one word: `#surface + #dark.04` is three separate values, and
314
+ Tasty warns in development.
315
+ - A layer without an opacity covers everything before it: `#surface+#dark` is
316
+ `#dark`, with a development warning.
317
+ - A layer Tasty can see is transparent — `#clear`, a fade to `.0`, a color with
318
+ a zero alpha — is left out: `#surface+#clear` is `#surface`.
319
+ - Over a transparent base, a layer is just its fade: `#clear+#dark.04` compiles
320
+ to `#dark.04`.
321
+ - A `+` joining anything but color tokens (`#surface+1x`) is not a compound: the
322
+ token is dropped, with a development warning, and the style renders as if
323
+ that color were not there.
324
+
325
+ A `+` joins tokens only. To fade a whole compound, give it a token
326
+ (`'#hover-surface': '#surface+#dark.04'`) and fade that (`#hover-surface.5`). For
327
+ a mix that is not a layer over another color, such as an even blend in OKLCH,
328
+ write `color-mix()` itself.
329
+
330
+ ---
331
+
332
+ ## CSS Color Functions
333
+
334
+ Every CSS color function is recognized as a color, so it lands in the color slot
335
+ of whichever style property you use it in — and tokens inside it are expanded:
336
+
337
+ ```jsx
338
+ fill: 'color-mix(in oklab, #primary 50%, #surface)',
339
+ color: 'light-dark(#dark, #light)',
340
+ color: 'contrast-color(#primary)',
341
+ fill: 'color(display-p3 1 .5 0)',
342
+ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
343
+ shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
344
+ ```
345
+
346
+ Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
347
+ time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
348
+
349
+ `light-dark()` is the one exception to "always a color": CSS lets it pick between
350
+ values of any type, so it is treated as a color only when its arguments are
351
+ colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
352
+
353
+ A color token defined as one of these functions takes the
354
+ [opacity suffix](#color-tokens--opacity) like any other:
355
+
356
+ ```jsx
357
+ const Card = tasty({
358
+ styles: {
359
+ '#brand': 'color-mix(in oklab, #primary 50%, #surface)',
360
+ fill: '#brand.5',
361
+ },
362
+ });
363
+ ```
364
+
365
+ A [replace token](configuration.md#replace-tokens-parse-time-substitution) is
366
+ substituted while parsing, so its color is right there to fade in place. A
367
+ channel function takes the alpha after a slash; a derived function has no alpha
368
+ channel, so it gets wrapped:
369
+
370
+ ```jsx
371
+ configure({
372
+ replaceTokens: {
373
+ '#solid': 'hsl(220 90% 50%)',
374
+ '#adaptive': 'light-dark(#dark, #light)',
375
+ },
376
+ });
377
+
378
+ fill: '#solid.5'; // → hsl(220 90% 50% / .5)
379
+ fill: '#adaptive.5'; // → color-mix(in oklab, light-dark(…) 50%, transparent)
380
+ ```
381
+
382
+ ### Color keywords
383
+
384
+ CSS named colors (`rebeccapurple`) and system colors (`Canvas`, `CanvasText`,
385
+ `Highlight`, `ButtonText`, `GrayText`, `LinkText`, …) are colors too: they land
386
+ in the color slot of any style and can be a color token's value. System colors
387
+ are what `forced-colors` styles are written in:
388
+
389
+ ```jsx
390
+ const Checkbox = tasty({
391
+ styles: {
392
+ '#forced-border': 'CanvasText',
393
+ border: {
394
+ '': '1bw #border',
395
+ '@media(forced-colors: active)': '1bw #forced-border',
396
+ },
397
+ outline: { '': false, focused: '2px Highlight' },
398
+ },
399
+ });
400
+ ```
401
+
402
+ A custom property whose fallback is a single color is read as a color, so it
403
+ also fills the color slot: `border: '1bw var(--accent, Highlight)'`, as does
404
+ `($accent, Highlight)`. Keywords are case-insensitive: a color token keeps the
405
+ case it was written in, and a property value such as `border` or `fill` emits
406
+ them lowercase.
407
+
408
+ The deprecated system colors (`Menu`, `Window`, `ButtonHighlight`, …) are not
409
+ recognized.
410
+
141
411
  ---
142
412
 
143
413
  ## Built-in Units
144
414
 
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)` |
415
+ | Unit | Description | Default | Example | CSS output |
416
+ | ---- | ------------------ | ---------------- | ------- | ---------------- |
417
+ | `x` | Spacing step | `8px` | `2x` | `16px` |
418
+ | `r` | Border radius | `6px` | `1r` | `6px` |
419
+ | `cr` | Card border radius | `10px` | `1cr` | `10px` |
420
+ | `bw` | Border width | `1px` | `2bw` | `2px` |
421
+ | `ow` | Outline width | `3px` | `1ow` | `3px` |
422
+ | `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
153
423
 
154
- You can register additional custom units via [`configure()`](configuration.md#options).
424
+ Units compile to plain values. Change the scale with `configure({ units: { x: '4px' } })`, or point a unit at a custom property when it must change at runtime: with `units: { x: 'var(--gap)' }`, `2x` compiles to `calc(2 * var(--gap))`. Setting a `$gap` or `$radius` token does not change the units. Register additional units the same way via [`configure()`](configuration.md#options).
155
425
 
156
426
  ---
157
427
 
@@ -192,9 +462,29 @@ const ElevatedCard = tasty({
192
462
  });
193
463
  ```
194
464
 
465
+ **Where recipes resolve:**
466
+
467
+ The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
468
+
469
+ ```jsx
470
+ const CardWithPanel = tasty({
471
+ styles: {
472
+ recipe: 'card',
473
+ Panel: {
474
+ recipe: 'card elevated',
475
+ padding: '2x', // Overrides the panel's base recipe padding
476
+ },
477
+ },
478
+ });
479
+ ```
480
+
481
+ At each level, base recipes are collected in the order listed (later recipes replace earlier values for the same property), then local styles are merged, then post recipes are merged. The merges with local styles and post recipes follow the [state-map extension and replacement rules](#extending-vs-replacing-state-maps).
482
+
483
+ 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.
484
+
195
485
  **Post-merge recipes (`/` separator):**
196
486
 
197
- Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
487
+ Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
198
488
 
199
489
  ```jsx
200
490
  const Input = tasty({
@@ -232,8 +522,8 @@ When a style property uses a state map, the merge behavior depends on whether th
232
522
  const MyButton = tasty(Button, {
233
523
  styles: {
234
524
  fill: {
235
- 'loading': '#yellow', // append new state
236
- 'disabled': '#gray.20', // override existing state in place
525
+ loading: '#yellow', // append new state
526
+ disabled: '#gray.20', // override existing state in place
237
527
  },
238
528
  },
239
529
  });
@@ -243,7 +533,7 @@ const MyButton = tasty(Button, {
243
533
  styles: {
244
534
  fill: {
245
535
  '': '#red',
246
- 'hovered': '#blue',
536
+ hovered: '#blue',
247
537
  },
248
538
  },
249
539
  });
@@ -268,8 +558,14 @@ fill: {
268
558
  Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
269
559
 
270
560
  ```jsx
271
- fill: { pressed: null } // removes pressed from the result
272
- fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe too
561
+ const MyButton = tasty(Button, {
562
+ styles: {
563
+ fill: {
564
+ hovered: null, // removes the parent's hovered state
565
+ disabled: false, // tombstone — no CSS for disabled, blocks recipe too
566
+ },
567
+ },
568
+ });
273
569
  ```
274
570
 
275
571
  ### Resetting Properties with `null` and `false`
@@ -277,36 +573,36 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
277
573
  ```jsx
278
574
  const SimpleButton = tasty(Button, {
279
575
  styles: {
280
- fill: null, // discard parent's fill, let recipe fill in
576
+ fill: null, // discard parent's fill, let recipe fill in
281
577
  border: false, // no border at all (tombstone — blocks recipe too)
282
578
  },
283
579
  });
284
580
  ```
285
581
 
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 |
582
+ | Value | Meaning | Recipe fills in? |
583
+ | ----------- | ------------------------------------ | ---------------- |
584
+ | `undefined` | Not provided — parent preserved | N/A |
585
+ | `null` | Intentional unset — parent discarded | Yes |
586
+ | `false` | Tombstone — blocks everything | No |
291
587
 
292
588
  ---
293
589
 
294
590
  ## Advanced States (`@` prefix)
295
591
 
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)` |
592
+ | Prefix | Purpose | Example |
593
+ | ----------- | ----------------------------------------- | -------------------------- |
594
+ | `@media` | Media queries | `@media(w < 768px)` |
595
+ | `@(...)` | Container queries | `@(panel, w >= 300px)` |
596
+ | `@supports` | Feature/selector support | `@supports(display: grid)` |
597
+ | `@root` | Root element states | `@root(schema=dark)` |
598
+ | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
599
+ | `@own` | Sub-element's own state | `@own(hovered)` |
600
+ | `@starting` | Entry animation | `@starting` |
601
+ | `_` | Fallback floor (always-on, never negated) | `_` |
602
+ | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
603
+ | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
604
+ | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
605
+ | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
310
606
 
311
607
  > **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
312
608
  > `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
@@ -319,12 +615,12 @@ const SimpleButton = tasty(Button, {
319
615
 
320
616
  ### `@media(...)` — Media Queries
321
617
 
322
- Media queries support dimension shorthands and custom unit expansion:
618
+ Media queries support dimension shorthands:
323
619
 
324
620
  | Shorthand | Expands to |
325
- |-----------|------------|
326
- | `w` | `width` |
327
- | `h` | `height` |
621
+ | --------- | ---------- |
622
+ | `w` | `width` |
623
+ | `h` | `height` |
328
624
 
329
625
  ```jsx
330
626
  fill: {
@@ -335,16 +631,23 @@ fill: {
335
631
  }
336
632
  ```
337
633
 
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` |
634
+ | Tasty syntax | CSS output |
635
+ | ------------------------------------ | ------------------------------------- |
636
+ | `@media(w < 768px)` | `@media (width < 768px)` |
637
+ | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
638
+ | `@media:print` | `@media print` |
639
+ | `@media:screen` | `@media screen` |
640
+ | `@media:all` | `@media all` |
641
+ | `@media:speech` | `@media speech` |
344
642
  | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
345
- | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
643
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
644
+ | `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
645
+
646
+ Tasty units resolve to their literal length inside query conditions, built-in and configured units alike: `@media(w < 40x)` emits `@media (width < 320px)`. A query condition cannot read a custom property, so a unit configured as one (`units: { x: 'var(--gap)' }`) cannot be used there; write that length in `px`, `em`, or `rem`.
346
647
 
347
- Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
648
+ Units are only converted in features that take a length: `width`, `height`, `inline-size`, and `block-size`, with or without `min-`/`max-` (`@media(min-width: 40x)` converts too). Every other feature keeps its value as written, so `@media(min-resolution: 2x)` and `@media(resolution >= 2x)` reach the browser unchanged: there `x` is CSS's own resolution unit, an alias of `dppx`.
649
+
650
+ When it combines or orders conditions, Tasty compares bounds only within one unit. `@media(w >= 600px) & @media(w < 40em)` keeps both bounds, because a query `em` follows the user's font size, so `600px` and `40em` cannot be ordered at build time.
348
651
 
349
652
  In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
350
653
 
@@ -352,12 +655,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
352
655
 
353
656
  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
657
 
355
- | Shorthand | Expands to |
356
- |-----------|------------|
357
- | `w` | `width` |
358
- | `h` | `height` |
359
- | `is` | `inline-size` |
360
- | `bs` | `block-size` |
658
+ | Shorthand | Expands to |
659
+ | --------- | ------------- |
660
+ | `w` | `width` |
661
+ | `h` | `height` |
662
+ | `is` | `inline-size` |
663
+ | `bs` | `block-size` |
361
664
 
362
665
  ```jsx
363
666
  const Panel = tasty({
@@ -370,26 +673,31 @@ const Panel = tasty({
370
673
  });
371
674
  ```
372
675
 
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)` |
676
+ | Tasty syntax | CSS output |
677
+ | ---------------------------------- | -------------------------------------------- |
678
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
679
+ | `@(w < 600px)` | `@container (width < 600px)` |
680
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
681
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
682
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
683
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
684
+
685
+ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: value)`. The value is emitted unquoted, so it matches a custom property set to the identifier `danger`, not the string `"danger"`.
381
686
 
382
- Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
687
+ Other size features pass through as written: `@(aspect-ratio > 1)` → `@container (aspect-ratio > 1)`, `@(orientation: portrait)` → `@container (orientation: portrait)`. They need a container with `containerType: 'size'`, since an `inline-size` container has no block size to compare against.
383
688
 
384
689
  ### `@supports(...)` — Feature Queries
385
690
 
386
- Feature queries test CSS property support. Use `$` as the first argument to test selector support:
691
+ Feature queries test CSS property support and accept CSS support functions such
692
+ as `at-rule()`. Use `$` as the first argument to test selector support:
387
693
 
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))` |
694
+ | Tasty syntax | CSS output |
695
+ | ----------------------------- | ----------------------------------- |
696
+ | `@supports(display: grid)` | `@supports (display: grid)` |
697
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
698
+ | `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
699
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
700
+ | `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
393
701
 
394
702
  ```jsx
395
703
  display: {
@@ -398,6 +706,25 @@ display: {
398
706
  }
399
707
  ```
400
708
 
709
+ `at-rule()` tests whether the browser supports the named at-rule. Its surrounding
710
+ parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
711
+ other states use the same syntax as property queries:
712
+
713
+ ```jsx
714
+ color: {
715
+ _: 'red',
716
+ '@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
717
+ }
718
+ ```
719
+
720
+ Use `_` to keep a base value when a browser cannot evaluate a query. A support
721
+ query only detects a browser feature; it does not add an API for authoring the
722
+ queried at-rule in a Tasty style object. For conditional stylesheet imports such
723
+ as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
724
+ stylesheet or document-level `useRawCSS()`. Put imports before other rules in
725
+ that stylesheet. Imports cannot be used in constructable stylesheets, including
726
+ Tasty's adopted-sheet mode for Shadow DOM.
727
+
401
728
  ### `_` — Fallback Floor
402
729
 
403
730
  By default Tasty makes states **mutually exclusive**: a higher-priority state
@@ -407,7 +734,7 @@ that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
407
734
  just true/false), and `not(unknown)` is also unknown — so a negated default
408
735
  branch silently never applies. The classic case is `scroll-state`: a browser can
409
736
  support `container-type: scroll-state` while a specific `scroll-state(...)` query
410
- is unknown, leaving *no* branch active.
737
+ is unknown, leaving _no_ branch active.
411
738
 
412
739
  The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
413
740
  **always applies** as a guaranteed floor: it never receives negation, and
@@ -422,10 +749,14 @@ inset: {
422
749
  ```
423
750
 
424
751
  ```css
425
- .t0.t0 { inset: 0 ...; }
426
- @container scroll-state(scrolled: block-end) {
427
- @supports (container-type: scroll-state) {
428
- .t0.t0 { inset: -80px ...; }
752
+ .t0.t0 {
753
+ inset: 0 auto auto auto;
754
+ }
755
+ @supports (container-type: scroll-state) {
756
+ @container scroll-state(scrolled: block-end) {
757
+ .t0.t0 {
758
+ inset: -640px auto auto auto;
759
+ }
429
760
  }
430
761
  }
431
762
  ```
@@ -433,7 +764,7 @@ inset: {
433
764
  The floor is emitted as a bare rule (no negated `@supports` / container branches),
434
765
  so it always applies. When the override matches it wins because it is emitted
435
766
  later and all state selectors share the same specificity (see the note on
436
- `:where()` below).
767
+ `:where()` above).
437
768
 
438
769
  Notes:
439
770
 
@@ -456,13 +787,13 @@ cause is always the same: **`''` is mutually exclusive (turned off by negation),
456
787
  while `_` is always on (layered underneath).**
457
788
 
458
789
  - **Unknown / invalid branches.** If a higher-priority branch sits behind a query
459
- that can be *unknown* (`@supports`, container, `scroll-state`) or uses a
790
+ that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
460
791
  selector the browser drops, the negated `''` default disappears along with it
461
792
  (`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
462
793
  survives because it is an unconditional bare rule. This is the case `_` exists
463
794
  for.
464
795
 
465
- - **Empty / "unset" states.** A state can intentionally produce *no* output (an
796
+ - **Empty / "unset" states.** A state can intentionally produce _no_ output (an
466
797
  empty value) to leave a property unset while that state is active. With `''`
467
798
  this works — the default is negated away and nothing replaces it, so the
468
799
  property unsets. With `_` the floor can never be turned off, so its value keeps
@@ -474,14 +805,14 @@ while `_` is always on (layered underneath).**
474
805
  ```
475
806
 
476
807
  - **States with different output shapes.** Because `_` layers additively, when
477
- different states emit *different sets* of declarations, the floor's
808
+ different states emit _different sets_ of declarations, the floor's
478
809
  declarations bleed through wherever the winning state does not override the
479
810
  same property — which can produce inconsistent combinations. A `''` default is
480
811
  swapped out cleanly by its mutually-exclusive condition.
481
812
 
482
813
  Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
483
814
  supports unsetting), and reach for `_` only when a value must survive an
484
- *unknown* higher-priority branch.
815
+ _unknown_ higher-priority branch.
485
816
 
486
817
  ### `@root(...)` — Root Element States
487
818
 
@@ -497,15 +828,15 @@ color: {
497
828
  }
498
829
  ```
499
830
 
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"])` |
831
+ | Tasty syntax | CSS selector |
832
+ | ---------------------- | --------------------------------- |
833
+ | `@root(schema=dark)` | `:root[data-schema="dark"]` |
834
+ | `@root(hovered)` | `:root[data-hovered]` |
835
+ | `@root(.premium-user)` | `:root.premium-user` |
836
+ | `@root([lang="en"])` | `:root[lang="en"]` |
837
+ | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
507
838
 
508
- Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
839
+ Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
509
840
 
510
841
  ### `@own(...)` — Sub-element's Own State
511
842
 
@@ -519,7 +850,7 @@ const Nav = tasty({
519
850
  '': '#text',
520
851
  '@own(:hover)': '#primary',
521
852
  '@own(:focus-visible)': '#primary',
522
- 'selected': '#primary', // root-level modifier
853
+ selected: '#primary', // root-level modifier
523
854
  },
524
855
  },
525
856
  },
@@ -527,14 +858,28 @@ const Nav = tasty({
527
858
  });
528
859
  ```
529
860
 
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 |
861
+ | Tasty syntax (inside sub-element) | CSS output |
862
+ | --------------------------------- | ------------------------------------------------- |
863
+ | `@own(:hover)` | `:hover` on the sub-element selector |
864
+ | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
865
+ | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
535
866
 
536
867
  `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
537
868
 
869
+ When `$` ends in a pseudo-element, `@own()` is the pseudo-element's own state and goes after it:
870
+
871
+ ```jsx
872
+ Label: {
873
+ $: '@::part(label)',
874
+ color: { '': '#text', '@own(:focus)': '#primary' },
875
+ },
876
+ // → .t0.t0 [data-element="Label"]::part(label):where(:focus) { … }
877
+ ```
878
+
879
+ A pseudo-element has no attributes, classes, or place in the DOM tree. So a state that tests a modifier (`@own(hovered)`), an attribute (`@own([open])`), a class, or a tree position (`@own(:first-child)`, `@own(:has(…))`) can never match it. Tasty ignores such a state and warns. To condition on the element the pseudo-element belongs to, write it in `$` before the pseudo-element (`$: 'a[rel="next"]::before'`), or use `@parent()` for its ancestors.
880
+
881
+ This covers every pseudo-element form: `::before`, `::marker`, `::backdrop`, vendor-prefixed ones such as `::-webkit-details-marker`, functional ones such as `::part(label)`, and the legacy `:before`, `:after`, `:first-line`, `:first-letter`. Each item of a `$` list is judged on its own. Tasty emits pseudo-class states regardless of browser support. Only some pseudo-elements, such as `::part()` and `::-webkit-scrollbar-thumb`, match states like `:hover` or `:focus` today.
882
+
538
883
  ### `@starting` — Entry Animation
539
884
 
540
885
  Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
@@ -544,40 +889,40 @@ const FadeIn = tasty({
544
889
  styles: {
545
890
  opacity: { '': '1', '@starting': '0' },
546
891
  transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
547
- transition: 'opacity 0.3s, translate 0.3s',
892
+ transition: 'opacity, translate',
548
893
  },
549
894
  });
550
895
  ```
551
896
 
552
- | Tasty syntax | CSS output |
553
- |--------------|------------|
554
- | `@starting` | `@starting-style { .t0.t0 { ... } }` |
897
+ | Tasty syntax | CSS output |
898
+ | ------------ | ------------------------------------ |
899
+ | `@starting` | `.t0.t0 { @starting-style { ... } }` |
555
900
 
556
901
  ### `@parent(...)` — Parent Element States
557
902
 
558
- Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
903
+ Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
559
904
 
560
905
  ```jsx
561
906
  const Highlight = tasty({
562
907
  styles: {
563
908
  fill: {
564
909
  '': '#white',
565
- '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
566
- '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
910
+ '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
911
+ '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
567
912
  },
568
913
  },
569
914
  });
570
915
  ```
571
916
 
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) |
579
- | `@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) |
917
+ | Syntax | CSS Output |
918
+ | ------------------------------------- | -------------------------------------------------------------------------- |
919
+ | `@parent(hovered)` | `:where([data-hovered] *)` |
920
+ | `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
921
+ | `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
922
+ | `@parent(.active)` | `:where(.active *)` |
923
+ | `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
924
+ | `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
925
+ | `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
581
926
 
582
927
  For sub-elements, the parent check applies to the root element's ancestors:
583
928
 
@@ -592,12 +937,12 @@ const Card = tasty({
592
937
  },
593
938
  },
594
939
  });
595
- // → .t0.t0:is([data-hovered] *) [data-element="Label"]
940
+ // → .t0.t0:where([data-hovered] *) [data-element="Label"]
596
941
  ```
597
942
 
598
943
  ### `:is()`, `:has()` — CSS Structural Pseudo-classes
599
944
 
600
- Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`.
945
+ Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`. Leading combinators (`> Icon`, `+ Icon`) are relative selectors and are valid only inside `:has()`.
601
946
 
602
947
  `:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
603
948
 
@@ -608,38 +953,38 @@ const Card = tasty({
608
953
  styles: {
609
954
  display: {
610
955
  '': '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
956
+ ':has(> Icon)': 'grid', // has Icon as direct child
957
+ ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
958
+ ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
959
+ ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
960
+ ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
961
+ ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
962
+ '!:has(> Icon)': 'flex', // negation: no Icon child
618
963
  },
619
964
  },
620
965
  });
621
966
  ```
622
967
 
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`) |
968
+ | Syntax | CSS Output | Meaning |
969
+ | -------------------- | ------------------------------------- | --------------------------------------- |
970
+ | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
971
+ | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
972
+ | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
973
+ | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
974
+ | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
975
+ | `:has(>)` | `:has(> *)` | Has any direct child |
976
+ | `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
977
+ | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
978
+ | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
979
+ | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
635
980
 
636
981
  Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
637
982
 
638
983
  ```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
984
+ ':has(> Icon) & hovered'; // AND: structural + data attribute
985
+ '@parent(hovered) & :has(> Icon)'; // AND: parent check + structural
986
+ ':has(> Icon) | :has(> Button)'; // OR: either sub-element present
987
+ ':has(> Icon) ^ :has(> Button)'; // XOR: exactly one present
643
988
  ```
644
989
 
645
990
  > **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.
@@ -664,6 +1009,8 @@ const Pulse = tasty({
664
1009
  });
665
1010
  ```
666
1011
 
1012
+ 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.
1013
+
667
1014
  ---
668
1015
 
669
1016
  ## Properties (`@property`)
@@ -675,38 +1022,58 @@ const AnimatedGradient = tasty({
675
1022
  styles: {
676
1023
  '$gradient-angle': '0deg',
677
1024
  '#theme': 'okhst(280 80% 50%)',
678
- background: 'linear-gradient($gradient-angle, #theme, transparent)',
679
- transition: '$$gradient-angle 0.3s, ##theme 0.3s',
1025
+ image: 'linear-gradient($gradient-angle, #theme, #clear)',
1026
+ transition: '$$gradient-angle, ##theme',
680
1027
  },
681
1028
  });
682
1029
  ```
683
1030
 
684
1031
  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
1032
 
686
- Use explicit `@properties` when you need non-default settings like `inherits: false`:
1033
+ Use explicit `@property` when you need non-default settings like `inherits: false`:
687
1034
 
688
1035
  ```jsx
689
- '@properties': {
1036
+ '@property': {
690
1037
  '$gradient-angle': { syntax: '<angle>', inherits: false, initialValue: '0deg' },
691
1038
  },
692
1039
  ```
693
1040
 
1041
+ ### Default properties
1042
+
1043
+ Tasty registers these properties itself. Style handlers read their defaults from them rather than repeating the values inline, so styles work before you define any tokens, and defining a token replaces the initial value.
1044
+
1045
+ | Token | Initial value | Read by |
1046
+ | ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
1047
+ | `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
1048
+ | `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
1049
+ | `#border` | `currentcolor` | `border` with no color |
1050
+ | `#outline` | `currentcolor` | `outline` with no color |
1051
+ | `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
1052
+ | `$transition` | `80ms` | `transition` with no duration |
1053
+ | `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
1054
+ | `$bold-font-weight` | `700` | `preset: 'name / strong'` |
1055
+ | `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
1056
+
1057
+ Every rendering path emits them: the client injector, the SSR collector (`TastyRegistry`, `tastyIntegration()`, `runWithCollector()`), the `withTastyNext()` shared stylesheet, and the Babel plugin. CSS written with the programmatic API needs [`extractConfigProperties()`](tasty-static.md#programmatic-api), once per stylesheet. Server rendering without a collector, such as Astro without `tastyIntegration()`, emits none of them.
1058
+
1059
+ The initial values need `@property` support: Chrome and Edge 85+, Firefox 128+, Safari 16.4+. In older engines a handler that reads one of these tokens resolves to nothing unless your tokens define it: a `border` with no color draws no border, and a `transition` with no duration does not animate. To support those engines, define the tokens your styles rely on in `configure({ tokens })`.
1060
+
694
1061
  ---
695
1062
 
696
- ## Font Face (`@fontFace`)
1063
+ ## Font Face (`@font-face`)
697
1064
 
698
1065
  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
1066
 
700
1067
  ```ts
701
1068
  const Heading = tasty({
702
1069
  styles: {
703
- '@fontFace': {
1070
+ '@font-face': {
704
1071
  'Brand Sans': {
705
1072
  src: 'url("/fonts/brand-sans.woff2") format("woff2")',
706
1073
  fontDisplay: 'swap',
707
1074
  },
708
1075
  },
709
- fontFamily: '"Brand Sans", sans-serif',
1076
+ font: '"Brand Sans", sans-serif',
710
1077
  },
711
1078
  });
712
1079
  ```
@@ -716,7 +1083,7 @@ const Heading = tasty({
716
1083
  Supply an array to register several variants of the same family:
717
1084
 
718
1085
  ```ts
719
- '@fontFace': {
1086
+ '@font-face': {
720
1087
  'Brand Sans': [
721
1088
  { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
722
1089
  { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
@@ -726,34 +1093,34 @@ Supply an array to register several variants of the same family:
726
1093
 
727
1094
  ### Supported descriptors
728
1095
 
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` |
1096
+ | Descriptor | CSS property | Type |
1097
+ | ----------------------- | ------------------------- | --------------------------------------------------------- |
1098
+ | `src` (required) | `src` | `string` |
1099
+ | `fontWeight` | `font-weight` | `string \| number` |
1100
+ | `fontStyle` | `font-style` | `string` |
1101
+ | `fontStretch` | `font-stretch` | `string` |
1102
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
1103
+ | `unicodeRange` | `unicode-range` | `string` |
1104
+ | `ascentOverride` | `ascent-override` | `string` |
1105
+ | `descentOverride` | `descent-override` | `string` |
1106
+ | `lineGapOverride` | `line-gap-override` | `string` |
1107
+ | `sizeAdjust` | `size-adjust` | `string` |
1108
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
1109
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
743
1110
 
744
1111
  > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
745
1112
 
746
1113
  ---
747
1114
 
748
- ## Counter Style (`@counterStyle`)
1115
+ ## Counter Style (`@counter-style`)
749
1116
 
750
1117
  Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
751
1118
 
752
1119
  ```ts
753
1120
  const EmojiList = tasty({
754
- tag: 'ol',
1121
+ as: 'ol',
755
1122
  styles: {
756
- '@counterStyle': {
1123
+ '@counter-style': {
757
1124
  thumbs: {
758
1125
  system: 'cyclic',
759
1126
  symbols: '"👍"',
@@ -767,23 +1134,88 @@ const EmojiList = tasty({
767
1134
 
768
1135
  ### Supported descriptors
769
1136
 
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` |
1137
+ | Descriptor | CSS property | Type |
1138
+ | ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
1139
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
1140
+ | `symbols` | `symbols` | `string` |
1141
+ | `additiveSymbols` | `additive-symbols` | `string` |
1142
+ | `prefix` | `prefix` | `string` |
1143
+ | `suffix` | `suffix` | `string` |
1144
+ | `negative` | `negative` | `string` |
1145
+ | `range` | `range` | `string` |
1146
+ | `pad` | `pad` | `string` |
1147
+ | `fallback` | `fallback` | `string` |
1148
+ | `speakAs` | `speak-as` | `string` |
782
1149
 
783
1150
  > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
784
1151
 
785
1152
  ---
786
1153
 
1154
+ ## Functions (`@function`)
1155
+
1156
+ 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.
1157
+
1158
+ The token convention follows Tasty's `$` vs `$$` distinction:
1159
+
1160
+ - **`$$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.
1161
+ - **`$name`** — a custom-property declaration/reference (`var(--name)`). Used for **parameters** and **local variables**, exactly like declaring custom props in a styles object.
1162
+ - **Local variables** are declared directly as `$name` keys on the descriptor — the body reads like a mini styles object.
1163
+ - `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.
1164
+
1165
+ ```ts
1166
+ const Box = tasty({
1167
+ styles: {
1168
+ '@function': {
1169
+ // simplest: one bare param + result (auto-calc, no explicit calc())
1170
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
1171
+
1172
+ // typed param + default + return type + local variable
1173
+ $$shadow: {
1174
+ args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
1175
+ returns: '<color>',
1176
+ $offset: '2px', // local variable
1177
+ result: '$offset $offset ($shadow-color, black)',
1178
+ },
1179
+ },
1180
+ margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
1181
+ shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
1182
+ },
1183
+ });
1184
+ ```
1185
+
1186
+ Generated CSS:
1187
+
1188
+ ```css
1189
+ @function --negative(--value) {
1190
+ result: calc(-1 * var(--value));
1191
+ }
1192
+ @function --shadow(--shadow-color <color>: inherit) returns <color> {
1193
+ --offset: 2px;
1194
+ result: var(--offset) var(--offset) var(--shadow-color, black);
1195
+ }
1196
+ .t0 {
1197
+ margin: --negative(10px) 0 0 0;
1198
+ box-shadow: --shadow(var(--accent-color));
1199
+ }
1200
+ ```
1201
+
1202
+ ### Descriptor shape
1203
+
1204
+ | Field | Type | Notes |
1205
+ | ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
1206
+ | `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
1207
+ | `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
1208
+ | `returns` | `string` | Optional return type, e.g. `'<color>'`. |
1209
+ | `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
1210
+
1211
+ A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
1212
+
1213
+ Functions can also be registered with the [`useFunction`](react-api.md#usefunction) style function or globally via [`configure({ functions })`](configuration.md#functions) (the same map also accepts bare-key parse functions).
1214
+
1215
+ > `@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.
1216
+
1217
+ ---
1218
+
787
1219
  ## Style Properties
788
1220
 
789
1221
  For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
@@ -796,4 +1228,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
796
1228
  - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
797
1229
  - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
798
1230
  - **[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
1231
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin