@tenphi/cookbook 0.13.0 → 0.16.0

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