@tenphi/tasty 0.0.0-snapshot.1f1c00a → 0.0.0-snapshot.1feecc6

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 (94) hide show
  1. package/README.md +403 -380
  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-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/chunks/{collector-D2ARGT2L.js → collector-Cb8ah2JF.js} +8 -6
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-CMYFZYQh.js} +5 -5
  10. package/dist/chunks/config-engine-CMYFZYQh.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-DotDkIXt.js → css-definitions-B4aWBkH3.js} +130 -96
  14. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  15. package/dist/chunks/{debug-D8pg9RGI.js → debug-D2Pu7Xhy.js} +6 -6
  16. package/dist/chunks/{debug-D8pg9RGI.js.map → debug-D2Pu7Xhy.js.map} +1 -1
  17. package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
  18. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  19. package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-DHiopXCu.js} +193 -64
  20. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  21. package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-NGCofNXy.js} +72 -53
  22. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  23. package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-lZjMbvwV.js} +28 -3
  24. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  25. package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-DnkV_4Jg.js} +488 -146
  26. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  27. package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-DcwaCvFs.js} +62 -27
  28. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  29. package/dist/{collector-w4mBj5gd.d.ts → collector-D2OT6I2G.d.ts} +2 -2
  30. package/dist/{config-CZWCzBr6.d.ts → config-C4ftFxgI.d.ts} +41 -23
  31. package/dist/core/index.d.ts +4 -4
  32. package/dist/core/index.js +7 -7
  33. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  34. package/dist/{index-G9JuwM9p.d.ts → index-DxQNRj50.d.ts} +65 -21
  35. package/dist/index.d.ts +5 -5
  36. package/dist/index.js +8 -8
  37. package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
  38. package/dist/ssr/astro.js +4 -4
  39. package/dist/ssr/client.d.ts +2 -0
  40. package/dist/ssr/client.js +2 -0
  41. package/dist/ssr/index.d.ts +3 -22
  42. package/dist/ssr/index.js +4 -4
  43. package/dist/ssr/index.js.map +1 -1
  44. package/dist/ssr/next-config.d.ts +1 -1
  45. package/dist/ssr/next-config.js +13 -18
  46. package/dist/ssr/next-config.js.map +1 -1
  47. package/dist/ssr/next.d.ts +1 -1
  48. package/dist/ssr/next.js +3 -3
  49. package/dist/static/index.d.ts +2 -2
  50. package/dist/{types-JEY8PVYP.d.ts → types-CYQIhUg1.d.ts} +10 -8
  51. package/dist/zero/babel.d.ts +73 -2
  52. package/dist/zero/babel.js +51 -48
  53. package/dist/zero/babel.js.map +1 -1
  54. package/dist/zero/index.d.ts +59 -3
  55. package/dist/zero/index.js +25 -2
  56. package/dist/zero/index.js.map +1 -0
  57. package/dist/zero/next.d.ts +2 -1
  58. package/dist/zero/next.js +3 -7
  59. package/dist/zero/next.js.map +1 -1
  60. package/docs/README.md +4 -1
  61. package/docs/adoption.md +25 -17
  62. package/docs/ai-agents.md +43 -34
  63. package/docs/comparison.md +9 -8
  64. package/docs/configuration.md +187 -69
  65. package/docs/debug.md +3 -2
  66. package/docs/design-system.md +117 -15
  67. package/docs/dsl.md +262 -116
  68. package/docs/getting-started.md +81 -24
  69. package/docs/injector.md +41 -40
  70. package/docs/methodology.md +46 -21
  71. package/docs/migration-v3.md +3 -3
  72. package/docs/pipeline.md +22 -19
  73. package/docs/plugins.md +21 -41
  74. package/docs/react-api.md +74 -11
  75. package/docs/runtime-benchmarks.md +11 -11
  76. package/docs/ssr.md +92 -66
  77. package/docs/styles.md +85 -19
  78. package/docs/tasty-static.md +175 -57
  79. package/package.json +45 -32
  80. package/tasty.config.ts +1 -0
  81. package/dist/babel-rZcEwPLM.d.ts +0 -82
  82. package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
  83. package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
  84. package/dist/chunks/build-config-CL4eRu2z.js +0 -42
  85. package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
  86. package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
  87. package/dist/chunks/config-engine-DEmmPPdp.js.map +0 -1
  88. package/dist/chunks/css-definitions-DotDkIXt.js.map +0 -1
  89. package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
  90. package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
  91. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
  92. package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
  93. package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
  94. package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
package/docs/dsl.md CHANGED
@@ -6,6 +6,8 @@ The same value syntax, state maps, tokens, units, extension semantics, and speci
6
6
 
7
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
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).
10
+
9
11
  ---
10
12
 
11
13
  ## Dictionary
@@ -18,6 +20,15 @@ Object where keys represent states and values are the styles to apply:
18
20
  fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
19
21
  ```
20
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
+
21
32
  #### State Key Types
22
33
 
23
34
  | Syntax | Example | Generated CSS |
@@ -34,17 +45,20 @@ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
34
45
 
35
46
  #### Automatic Native States
36
47
 
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:
48
+ `disabled`, `checked`, and `hidden` are built-in automatic states. A Tasty component sets `data-disabled`, `data-checked`, and `data-hidden` from the native `disabled`, `checked`, and `hidden` props (or `isDisabled`, `isChecked`, `isHidden`), so each pair below expresses the same component state:
38
49
 
39
- | Concise Tasty state | Explicit attribute selector |
40
- | ------------------- | --------------------------- |
41
- | `disabled` | `[disabled]` |
42
- | `checked` | `[checked]` |
50
+ | Concise Tasty state | Compiles to | Explicit attribute selector |
51
+ | ------------------- | ----------------- | --------------------------- |
52
+ | `disabled` | `[data-disabled]` | `[disabled]` |
53
+ | `checked` | `[data-checked]` | `[checked]` |
54
+ | `hidden` | `[data-hidden]` | `[hidden]` |
43
55
 
44
56
  Prefer the concise form when authoring Tasty component styles. Explicit attribute selectors remain valid and can be useful when targeting arbitrary attributes or when CSS-shaped syntax makes an introductory example easier to recognize.
45
57
 
46
58
  Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
47
59
 
60
+ A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
61
+
48
62
  `^` (XOR) means "exactly one of" — `A ^ B` expands to `(A & !B) | (!A & B)`. This is useful for mutually exclusive states where exactly one should be active:
49
63
 
50
64
  ```jsx
@@ -76,9 +90,7 @@ Element styled using a capitalized key. Identified by `data-element` attribute:
76
90
 
77
91
  ```jsx
78
92
  styles: {
79
- Title: {
80
- preset: 'h3';
81
- }
93
+ Title: { preset: 'h3' },
82
94
  }
83
95
  // Targets: <div data-element="Title">
84
96
  ```
@@ -117,20 +129,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
117
129
  const List = tasty({
118
130
  styles: {
119
131
  Item: {
120
- $: '>@:last-child',
121
- border: 'none',
132
+ $: '>@::after',
133
+ content: '""',
122
134
  },
123
135
  },
124
136
  });
125
- // → .t0 > [data-element="Item"]:last-child { border: none }
137
+ // → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
126
138
  ```
127
139
 
140
+ Keep conditions such as `:last-child` out of `$` and write them as `@own(:last-child)` in a state map; `tasty/no-state-in-selector` warns otherwise. When `$` ends in a pseudo-element, `@own()` describes the pseudo-element instead (see [`@own(...)`](#own--sub-elements-own-state)), so a condition on the element it belongs to stays in `$`, before the pseudo-element: `$: 'a[rel="next"]::before'`.
141
+
128
142
  ### Color Token
129
143
 
130
144
  Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
131
145
 
132
146
  ```jsx
133
- fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
147
+ fill: '#purple.5'; // → color-mix(in oklab, var(--purple-color) 50%, transparent)
134
148
  ```
135
149
 
136
150
  ### Modifier
@@ -154,19 +168,23 @@ color: '#purple.5', // 50% opacity
154
168
  color: '#purple.05', // 5% opacity
155
169
  color: '#purple.$fade', // Opacity from a custom property
156
170
  fill: '#current', // → currentcolor
171
+ fill: '#surface+#dark.04', // #dark at 4% opacity over #surface, as one color
157
172
  color: '(#primary, #secondary)', // Fallback syntax
158
173
  ```
159
174
 
160
- The suffix sets the alpha on the token's color with CSS relative color syntax:
175
+ `#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.
176
+
177
+ 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.
178
+
179
+ The suffix fades the token's color by mixing it with `transparent`:
161
180
 
162
181
  ```jsx
163
182
  fill: '#purple.5';
164
- // → oklch(from var(--purple-color) l c h / .5)
183
+ // → color-mix(in oklab, var(--purple-color) 50%, transparent)
165
184
  ```
166
185
 
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:
186
+ The mix asks nothing of the color beyond _being_ a color. That means the suffix
187
+ works on every one of these:
170
188
 
171
189
  - a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
172
190
  Tasty cannot convert — none of which have channels to decompose
@@ -174,13 +192,29 @@ these:
174
192
  - a `--name-color` variable declared in your own CSS, with no Tasty token
175
193
  definition behind it
176
194
 
177
- Two properties follow from writing the alpha slot rather than compositing:
195
+ `color-mix()` is Baseline widely available (Chrome 111, Firefox 113, Safari
196
+ 16.2). Two properties follow from mixing rather than writing an alpha channel:
178
197
 
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.
198
+ - **Alpha composes.** The mix is premultiplied, so a color that is already
199
+ translucent is faded further: a token holding `rgb(255 0 0 / .8)` faded to
200
+ `.5` is alpha `.4`. An opaque token — the usual case — ends at exactly the
201
+ suffix. System colors are whatever the platform draws, and some are
202
+ translucent: Chrome and Safari on macOS give `Highlight` an alpha of `.6`, so
203
+ a token holding it faded to `.5` ends at `.3` there.
204
+ - **A `$prop` alpha must be a number.** `#purple.$fade` emits
205
+ `calc(var(--fade) * 100%)`, because a mix percentage cannot be a `<number>`,
206
+ so `$fade` has to hold `.5`, not `50%`.
207
+
208
+ ### `#clear` is transparent
209
+
210
+ `#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
211
+ Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
212
+ `transparent`. The same rule applies to user-defined replace tokens resolving
213
+ to `transparent`, including aliases of `#clear`.
214
+
215
+ It does not read `--clear-color` or require an `@property` registration.
216
+ An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
217
+ default alias and uses the replacement's usual opacity behavior.
184
218
 
185
219
  ### `#current` is the keyword
186
220
 
@@ -203,42 +237,75 @@ A color that already reads the color it inherits — `#current`, a `#current` fa
203
237
  — is not published into it: resolving such a value a second time at a descendant
204
238
  would fade it twice.
205
239
 
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:
240
+ ### `#current` fades compose
241
+
242
+ `currentcolor` is the color an element **inherits**, which an ancestor may
243
+ already have faded, so `#current.4` means "40% of what reaches me":
209
244
 
210
245
  ```jsx
211
- { '#ink': '#current', fill: '#ink.5' }
212
- // --ink-color: currentcolor
213
- // fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
246
+ fill: '#current.4';
247
+ // → color-mix(in oklab, currentcolor 40%, transparent)
214
248
  ```
215
249
 
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.
250
+ A `#current` fade nested inside another one composes: a label at `#current.4`
251
+ with a fill of `#current.18` under it lands at `.072`. Color ramps built on
252
+ `#current` depend on that.
253
+
254
+ Fades always mix `in oklab`: it is unbounded, so a wide-gamut color is not
255
+ clamped, and rectangular, so there is no hue to interpolate against
256
+ `transparent`. Nothing configures it — see
257
+ [Color space](configuration.md#color-space).
219
258
 
220
- ### `#current` composes instead
259
+ ### Compound colors
221
260
 
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":
261
+ Join color tokens with `+` to paint each one, at its own opacity, over the
262
+ colors before it. The result is one color, so it works anywhere a token does:
226
263
 
227
264
  ```jsx
228
- fill: '#current.4';
229
- // → color-mix(in oklab, currentcolor 40%, transparent)
230
- ```
265
+ fill: '#surface+#dark.04',
266
+ // → color-mix(in srgb, var(--dark-color) 4%, var(--surface-color))
231
267
 
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.
268
+ border: '1bw #border+#dark.1',
269
+ color: 'light-dark(#primary+#black.2, #primary+#white.2)',
270
+ '#hover-surface': '#surface-2+#surface-text.03',
271
+ ```
238
272
 
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).
273
+ Read it left to right, bottom layer first: `#surface+#accent.1+#dark.04` paints
274
+ `#accent` at 10% over `#surface`, then `#dark` at 4% over that. Every operand is
275
+ an ordinary token — `#current`, `#clear`, a hex color, a replace token — and
276
+ takes its opacity suffix as it does anywhere: `#surface+#dark.$hover` reads the
277
+ opacity from `$hover`, and a faded base such as `#surface.5+#dark.04` is layered
278
+ as it is.
279
+
280
+ The layers mix in sRGB, the space browsers composite in, so the color is exactly
281
+ what stacking them as layers would show — but it is one color, which contrast
282
+ checkers can read and transitions interpolate. A faded base is exact too:
283
+ `#surface.5+#dark.04` is as translucent as the two layers would be.
284
+
285
+ Every layer's token has to be opaque. The mix counts a layer's own alpha as well
286
+ as its opacity suffix, and lowers the alpha of the whole color, so a layer token
287
+ that holds a translucent color, or turns transparent in some state, leaves the
288
+ result see-through: with `'#overlay': { '': '#clear', hovered: '#dark' }`,
289
+ `'#surface+#overlay.04'` is 96% opaque at rest. Vary the opacity instead
290
+ (`'#surface+#dark.$hover'`), or give each state its own color
291
+ (`fill: { '': '#surface', hovered: '#surface+#dark.04' }`).
292
+
293
+ - Write it as one word: `#surface + #dark.04` is three separate values, and
294
+ Tasty warns in development.
295
+ - A layer without an opacity covers everything before it: `#surface+#dark` is
296
+ `#dark`, with a development warning.
297
+ - A layer Tasty can see is transparent — `#clear`, a fade to `.0`, a color with
298
+ a zero alpha — is left out: `#surface+#clear` is `#surface`.
299
+ - Over a transparent base, a layer is just its fade: `#clear+#dark.04` compiles
300
+ to `#dark.04`.
301
+ - A `+` joining anything but color tokens (`#surface+1x`) is not a compound: the
302
+ token is dropped, with a development warning, and the style renders as if
303
+ that color were not there.
304
+
305
+ A `+` joins tokens only. To fade a whole compound, give it a token
306
+ (`'#hover-surface': '#surface+#dark.04'`) and fade that (`#hover-surface.5`). For
307
+ a mix that is not a layer over another color, such as an even blend in OKLCH,
308
+ write `color-mix()` itself.
242
309
 
243
310
  ---
244
311
 
@@ -256,6 +323,9 @@ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
256
323
  shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
257
324
  ```
258
325
 
326
+ Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
327
+ time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
328
+
259
329
  `light-dark()` is the one exception to "always a color": CSS lets it pick between
260
330
  values of any type, so it is treated as a color only when its arguments are
261
331
  colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
@@ -286,23 +356,52 @@ configure({
286
356
  });
287
357
 
288
358
  fill: '#solid.5'; // → hsl(220 90% 50% / .5)
289
- fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
359
+ fill: '#adaptive.5'; // → color-mix(in oklab, light-dark(…) 50%, transparent)
290
360
  ```
291
361
 
362
+ ### Color keywords
363
+
364
+ CSS named colors (`rebeccapurple`) and system colors (`Canvas`, `CanvasText`,
365
+ `Highlight`, `ButtonText`, `GrayText`, `LinkText`, …) are colors too: they land
366
+ in the color slot of any style and can be a color token's value. System colors
367
+ are what `forced-colors` styles are written in:
368
+
369
+ ```jsx
370
+ const Checkbox = tasty({
371
+ styles: {
372
+ '#forced-border': 'CanvasText',
373
+ border: {
374
+ '': '1bw #border',
375
+ '@media(forced-colors: active)': '1bw #forced-border',
376
+ },
377
+ outline: { '': false, focused: '2px Highlight' },
378
+ },
379
+ });
380
+ ```
381
+
382
+ A custom property whose fallback is a single color is read as a color, so it
383
+ also fills the color slot: `border: '1bw var(--accent, Highlight)'`, as does
384
+ `($accent, Highlight)`. Keywords are case-insensitive: a color token keeps the
385
+ case it was written in, and a property value such as `border` or `fill` emits
386
+ them lowercase.
387
+
388
+ The deprecated system colors (`Menu`, `Window`, `ButtonHighlight`, …) are not
389
+ recognized.
390
+
292
391
  ---
293
392
 
294
393
  ## Built-in Units
295
394
 
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)` |
395
+ | Unit | Description | Default | Example | CSS output |
396
+ | ---- | ------------------ | ---------------- | ------- | ---------------- |
397
+ | `x` | Spacing step | `8px` | `2x` | `16px` |
398
+ | `r` | Border radius | `6px` | `1r` | `6px` |
399
+ | `cr` | Card border radius | `10px` | `1cr` | `10px` |
400
+ | `bw` | Border width | `1px` | `2bw` | `2px` |
401
+ | `ow` | Outline width | `3px` | `1ow` | `3px` |
402
+ | `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
304
403
 
305
- You can register additional custom units via [`configure()`](configuration.md#options).
404
+ 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).
306
405
 
307
406
  ---
308
407
 
@@ -359,7 +458,7 @@ const CardWithPanel = tasty({
359
458
  });
360
459
  ```
361
460
 
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).
461
+ 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).
363
462
 
364
463
  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
464
 
@@ -439,12 +538,14 @@ fill: {
439
538
  Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
440
539
 
441
540
  ```jsx
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
541
+ const MyButton = tasty(Button, {
542
+ styles: {
543
+ fill: {
544
+ hovered: null, // removes the parent's hovered state
545
+ disabled: false, // tombstone — no CSS for disabled, blocks recipe too
546
+ },
547
+ },
548
+ });
448
549
  ```
449
550
 
450
551
  ### Resetting Properties with `null` and `false`
@@ -494,7 +595,7 @@ const SimpleButton = tasty(Button, {
494
595
 
495
596
  ### `@media(...)` — Media Queries
496
597
 
497
- Media queries support dimension shorthands and custom unit expansion:
598
+ Media queries support dimension shorthands:
498
599
 
499
600
  | Shorthand | Expands to |
500
601
  | --------- | ---------- |
@@ -516,10 +617,17 @@ fill: {
516
617
  | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
517
618
  | `@media:print` | `@media print` |
518
619
  | `@media:screen` | `@media screen` |
620
+ | `@media:all` | `@media all` |
621
+ | `@media:speech` | `@media speech` |
519
622
  | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
520
623
  | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
624
+ | `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
625
+
626
+ 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`.
521
627
 
522
- Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
628
+ 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`.
629
+
630
+ 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.
523
631
 
524
632
  In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
525
633
 
@@ -545,28 +653,30 @@ const Panel = tasty({
545
653
  });
546
654
  ```
547
655
 
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)` |
656
+ | Tasty syntax | CSS output |
657
+ | ---------------------------------- | -------------------------------------------- |
658
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
659
+ | `@(w < 600px)` | `@container (width < 600px)` |
660
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
661
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
662
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
663
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
664
+
665
+ 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"`.
556
666
 
557
- Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
667
+ 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.
558
668
 
559
669
  ### `@supports(...)` — Feature Queries
560
670
 
561
671
  Feature queries test CSS property support and accept CSS support functions such
562
672
  as `at-rule()`. Use `$` as the first argument to test selector support:
563
673
 
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))` |
674
+ | Tasty syntax | CSS output |
675
+ | ----------------------------- | ----------------------------------- |
676
+ | `@supports(display: grid)` | `@supports (display: grid)` |
677
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
678
+ | `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
679
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
570
680
  | `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
571
681
 
572
682
  ```jsx
@@ -620,12 +730,12 @@ inset: {
620
730
 
621
731
  ```css
622
732
  .t0.t0 {
623
- inset: 0...;
733
+ inset: 0 auto auto auto;
624
734
  }
625
- @container scroll-state(scrolled: block-end) {
626
- @supports (container-type: scroll-state) {
735
+ @supports (container-type: scroll-state) {
736
+ @container scroll-state(scrolled: block-end) {
627
737
  .t0.t0 {
628
- inset: -80px...;
738
+ inset: -640px auto auto auto;
629
739
  }
630
740
  }
631
741
  }
@@ -634,7 +744,7 @@ inset: {
634
744
  The floor is emitted as a bare rule (no negated `@supports` / container branches),
635
745
  so it always applies. When the override matches it wins because it is emitted
636
746
  later and all state selectors share the same specificity (see the note on
637
- `:where()` below).
747
+ `:where()` above).
638
748
 
639
749
  Notes:
640
750
 
@@ -706,7 +816,7 @@ color: {
706
816
  | `@root([lang="en"])` | `:root[lang="en"]` |
707
817
  | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
708
818
 
709
- Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
819
+ Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
710
820
 
711
821
  ### `@own(...)` — Sub-element's Own State
712
822
 
@@ -736,6 +846,20 @@ const Nav = tasty({
736
846
 
737
847
  `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
738
848
 
849
+ When `$` ends in a pseudo-element, `@own()` is the pseudo-element's own state and goes after it:
850
+
851
+ ```jsx
852
+ Label: {
853
+ $: '@::part(label)',
854
+ color: { '': '#text', '@own(:focus)': '#primary' },
855
+ },
856
+ // → .t0.t0 [data-element="Label"]::part(label):where(:focus) { … }
857
+ ```
858
+
859
+ 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.
860
+
861
+ 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.
862
+
739
863
  ### `@starting` — Entry Animation
740
864
 
741
865
  Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
@@ -752,11 +876,11 @@ const FadeIn = tasty({
752
876
 
753
877
  | Tasty syntax | CSS output |
754
878
  | ------------ | ------------------------------------ |
755
- | `@starting` | `@starting-style { .t0.t0 { ... } }` |
879
+ | `@starting` | `.t0.t0 { @starting-style { ... } }` |
756
880
 
757
881
  ### `@parent(...)` — Parent Element States
758
882
 
759
- Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
883
+ Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
760
884
 
761
885
  ```jsx
762
886
  const Highlight = tasty({
@@ -770,15 +894,15 @@ const Highlight = tasty({
770
894
  });
771
895
  ```
772
896
 
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) |
780
- | `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
781
- | `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
897
+ | Syntax | CSS Output |
898
+ | ------------------------------------- | -------------------------------------------------------------------------- |
899
+ | `@parent(hovered)` | `:where([data-hovered] *)` |
900
+ | `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
901
+ | `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
902
+ | `@parent(.active)` | `:where(.active *)` |
903
+ | `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
904
+ | `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
905
+ | `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
782
906
 
783
907
  For sub-elements, the parent check applies to the root element's ancestors:
784
908
 
@@ -793,12 +917,12 @@ const Card = tasty({
793
917
  },
794
918
  },
795
919
  });
796
- // → .t0.t0:is([data-hovered] *) [data-element="Label"]
920
+ // → .t0.t0:where([data-hovered] *) [data-element="Label"]
797
921
  ```
798
922
 
799
923
  ### `:is()`, `:has()` — CSS Structural Pseudo-classes
800
924
 
801
- 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 `*`.
925
+ 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()`.
802
926
 
803
927
  `:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
804
928
 
@@ -821,18 +945,18 @@ const Card = tasty({
821
945
  });
822
946
  ```
823
947
 
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`) |
948
+ | Syntax | CSS Output | Meaning |
949
+ | -------------------- | ------------------------------------- | --------------------------------------- |
950
+ | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
951
+ | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
952
+ | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
953
+ | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
954
+ | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
955
+ | `:has(>)` | `:has(> *)` | Has any direct child |
956
+ | `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
957
+ | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
958
+ | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
959
+ | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
836
960
 
837
961
  Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
838
962
 
@@ -865,6 +989,8 @@ const Pulse = tasty({
865
989
  });
866
990
  ```
867
991
 
992
+ 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.
993
+
868
994
  ---
869
995
 
870
996
  ## Properties (`@property`)
@@ -892,6 +1018,26 @@ Use explicit `@property` when you need non-default settings like `inherits: fals
892
1018
  },
893
1019
  ```
894
1020
 
1021
+ ### Default properties
1022
+
1023
+ 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.
1024
+
1025
+ | Token | Initial value | Read by |
1026
+ | ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
1027
+ | `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
1028
+ | `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
1029
+ | `#border` | `currentcolor` | `border` with no color |
1030
+ | `#outline` | `currentcolor` | `outline` with no color |
1031
+ | `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
1032
+ | `$transition` | `80ms` | `transition` with no duration |
1033
+ | `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
1034
+ | `$bold-font-weight` | `700` | `preset: 'name / strong'` |
1035
+ | `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
1036
+
1037
+ 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.
1038
+
1039
+ 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 })`.
1040
+
895
1041
  ---
896
1042
 
897
1043
  ## Font Face (`@font-face`)
@@ -952,7 +1098,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
952
1098
 
953
1099
  ```ts
954
1100
  const EmojiList = tasty({
955
- tag: 'ol',
1101
+ as: 'ol',
956
1102
  styles: {
957
1103
  '@counter-style': {
958
1104
  thumbs: {
@@ -1044,7 +1190,7 @@ Generated CSS:
1044
1190
 
1045
1191
  A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
1046
1192
 
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).
1193
+ 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).
1048
1194
 
1049
1195
  > `@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
1196