@tenphi/tasty 0.0.0-snapshot.b3fbcbb → 0.0.0-snapshot.b81f166

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 (185) hide show
  1. package/README.md +289 -206
  2. package/dist/chunks/cacheKey.js +16 -8
  3. package/dist/chunks/cacheKey.js.map +1 -1
  4. package/dist/chunks/definitions.js +2 -3
  5. package/dist/chunks/definitions.js.map +1 -1
  6. package/dist/chunks/renderChunk.js +31 -32
  7. package/dist/chunks/renderChunk.js.map +1 -1
  8. package/dist/config.d.ts +90 -12
  9. package/dist/config.js +134 -33
  10. package/dist/config.js.map +1 -1
  11. package/dist/core/index.d.ts +11 -10
  12. package/dist/core/index.js +8 -7
  13. package/dist/counter-style/index.js +51 -0
  14. package/dist/counter-style/index.js.map +1 -0
  15. package/dist/debug.d.ts +26 -141
  16. package/dist/debug.js +356 -635
  17. package/dist/debug.js.map +1 -1
  18. package/dist/font-face/index.js +63 -0
  19. package/dist/font-face/index.js.map +1 -0
  20. package/dist/hooks/resolve-ssr-collector.js +15 -0
  21. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  22. package/dist/hooks/useCounterStyle.d.ts +50 -0
  23. package/dist/hooks/useCounterStyle.js +47 -0
  24. package/dist/hooks/useCounterStyle.js.map +1 -0
  25. package/dist/hooks/useFontFace.d.ts +43 -0
  26. package/dist/hooks/useFontFace.js +71 -0
  27. package/dist/hooks/useFontFace.js.map +1 -0
  28. package/dist/hooks/useGlobalStyles.d.ts +3 -0
  29. package/dist/hooks/useGlobalStyles.js +24 -1
  30. package/dist/hooks/useGlobalStyles.js.map +1 -1
  31. package/dist/hooks/useKeyframes.js +14 -3
  32. package/dist/hooks/useKeyframes.js.map +1 -1
  33. package/dist/hooks/useProperty.js +32 -13
  34. package/dist/hooks/useProperty.js.map +1 -1
  35. package/dist/hooks/useRawCSS.js +9 -1
  36. package/dist/hooks/useRawCSS.js.map +1 -1
  37. package/dist/hooks/useStyles.d.ts +5 -0
  38. package/dist/hooks/useStyles.js +109 -8
  39. package/dist/hooks/useStyles.js.map +1 -1
  40. package/dist/index.d.ts +14 -11
  41. package/dist/index.js +10 -7
  42. package/dist/injector/index.d.ts +28 -2
  43. package/dist/injector/index.js +27 -1
  44. package/dist/injector/index.js.map +1 -1
  45. package/dist/injector/injector.d.ts +28 -1
  46. package/dist/injector/injector.js +56 -17
  47. package/dist/injector/injector.js.map +1 -1
  48. package/dist/injector/sheet-manager.d.ts +1 -0
  49. package/dist/injector/sheet-manager.js +3 -0
  50. package/dist/injector/sheet-manager.js.map +1 -1
  51. package/dist/injector/types.d.ts +61 -1
  52. package/dist/parser/classify.js +2 -1
  53. package/dist/parser/classify.js.map +1 -1
  54. package/dist/parser/parser.js +1 -1
  55. package/dist/pipeline/index.d.ts +1 -1
  56. package/dist/pipeline/index.js +65 -26
  57. package/dist/pipeline/index.js.map +1 -1
  58. package/dist/pipeline/materialize.js +380 -119
  59. package/dist/pipeline/materialize.js.map +1 -1
  60. package/dist/pipeline/parseStateKey.d.ts +1 -1
  61. package/dist/pipeline/parseStateKey.js +20 -11
  62. package/dist/pipeline/parseStateKey.js.map +1 -1
  63. package/dist/plugins/okhsl-plugin.js +2 -275
  64. package/dist/plugins/okhsl-plugin.js.map +1 -1
  65. package/dist/plugins/types.d.ts +9 -2
  66. package/dist/properties/index.js +14 -28
  67. package/dist/properties/index.js.map +1 -1
  68. package/dist/properties/property-type-resolver.js +12 -0
  69. package/dist/properties/property-type-resolver.js.map +1 -1
  70. package/dist/ssr/astro.d.ts +29 -0
  71. package/dist/ssr/astro.js +65 -0
  72. package/dist/ssr/astro.js.map +1 -0
  73. package/dist/ssr/async-storage.d.ts +17 -0
  74. package/dist/ssr/async-storage.js +35 -0
  75. package/dist/ssr/async-storage.js.map +1 -0
  76. package/dist/ssr/collect-auto-properties.js +40 -0
  77. package/dist/ssr/collect-auto-properties.js.map +1 -0
  78. package/dist/ssr/collector.d.ts +102 -0
  79. package/dist/ssr/collector.js +227 -0
  80. package/dist/ssr/collector.js.map +1 -0
  81. package/dist/ssr/context.d.ts +8 -0
  82. package/dist/ssr/context.js +14 -0
  83. package/dist/ssr/context.js.map +1 -0
  84. package/dist/ssr/format-global-rules.js +22 -0
  85. package/dist/ssr/format-global-rules.js.map +1 -0
  86. package/dist/ssr/format-keyframes.js +70 -0
  87. package/dist/ssr/format-keyframes.js.map +1 -0
  88. package/dist/ssr/format-property.js +50 -0
  89. package/dist/ssr/format-property.js.map +1 -0
  90. package/dist/ssr/format-rules.js +70 -0
  91. package/dist/ssr/format-rules.js.map +1 -0
  92. package/dist/ssr/hydrate.d.ts +22 -0
  93. package/dist/ssr/hydrate.js +50 -0
  94. package/dist/ssr/hydrate.js.map +1 -0
  95. package/dist/ssr/index.d.ts +5 -0
  96. package/dist/ssr/index.js +12 -0
  97. package/dist/ssr/index.js.map +1 -0
  98. package/dist/ssr/next.d.ts +45 -0
  99. package/dist/ssr/next.js +71 -0
  100. package/dist/ssr/next.js.map +1 -0
  101. package/dist/ssr/ssr-collector-ref.js +12 -0
  102. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  103. package/dist/states/index.js +12 -257
  104. package/dist/states/index.js.map +1 -1
  105. package/dist/styles/border.js +2 -2
  106. package/dist/styles/border.js.map +1 -1
  107. package/dist/styles/color.js +9 -5
  108. package/dist/styles/color.js.map +1 -1
  109. package/dist/styles/createStyle.js +24 -21
  110. package/dist/styles/createStyle.js.map +1 -1
  111. package/dist/styles/index.js +1 -1
  112. package/dist/styles/predefined.d.ts +0 -2
  113. package/dist/styles/predefined.js +1 -4
  114. package/dist/styles/predefined.js.map +1 -1
  115. package/dist/styles/preset.js +8 -8
  116. package/dist/styles/preset.js.map +1 -1
  117. package/dist/styles/scrollbar.d.ts +9 -5
  118. package/dist/styles/scrollbar.js +25 -89
  119. package/dist/styles/scrollbar.js.map +1 -1
  120. package/dist/styles/transition.js +1 -1
  121. package/dist/styles/transition.js.map +1 -1
  122. package/dist/styles/types.d.ts +67 -20
  123. package/dist/tasty.d.ts +30 -893
  124. package/dist/tasty.js +44 -18
  125. package/dist/tasty.js.map +1 -1
  126. package/dist/types.d.ts +1 -1
  127. package/dist/utils/cache-wrapper.js +4 -8
  128. package/dist/utils/cache-wrapper.js.map +1 -1
  129. package/dist/utils/color-math.d.ts +46 -0
  130. package/dist/utils/color-math.js +749 -0
  131. package/dist/utils/color-math.js.map +1 -0
  132. package/dist/utils/color-space.d.ts +5 -0
  133. package/dist/utils/color-space.js +229 -0
  134. package/dist/utils/color-space.js.map +1 -0
  135. package/dist/utils/colors.js +3 -1
  136. package/dist/utils/colors.js.map +1 -1
  137. package/dist/utils/has-keys.js +13 -0
  138. package/dist/utils/has-keys.js.map +1 -0
  139. package/dist/utils/mod-attrs.js +2 -2
  140. package/dist/utils/mod-attrs.js.map +1 -1
  141. package/dist/utils/process-tokens.d.ts +3 -13
  142. package/dist/utils/process-tokens.js +18 -98
  143. package/dist/utils/process-tokens.js.map +1 -1
  144. package/dist/utils/selector-transform.js +32 -0
  145. package/dist/utils/selector-transform.js.map +1 -0
  146. package/dist/utils/styles.d.ts +2 -79
  147. package/dist/utils/styles.js +28 -556
  148. package/dist/utils/styles.js.map +1 -1
  149. package/dist/utils/typography.d.ts +24 -13
  150. package/dist/utils/typography.js +6 -16
  151. package/dist/utils/typography.js.map +1 -1
  152. package/dist/zero/babel.d.ts +62 -8
  153. package/dist/zero/babel.js +103 -17
  154. package/dist/zero/babel.js.map +1 -1
  155. package/dist/zero/extractor.js +53 -1
  156. package/dist/zero/extractor.js.map +1 -1
  157. package/dist/zero/next.d.ts +44 -30
  158. package/dist/zero/next.js +102 -38
  159. package/dist/zero/next.js.map +1 -1
  160. package/docs/PIPELINE.md +519 -0
  161. package/docs/README.md +31 -0
  162. package/docs/adoption.md +296 -0
  163. package/docs/comparison.md +420 -0
  164. package/docs/configuration.md +326 -0
  165. package/docs/debug.md +318 -0
  166. package/docs/design-system.md +424 -0
  167. package/docs/dsl.md +675 -0
  168. package/docs/getting-started.md +217 -0
  169. package/docs/injector.md +528 -0
  170. package/docs/methodology.md +567 -0
  171. package/docs/runtime.md +485 -0
  172. package/docs/ssr.md +384 -0
  173. package/docs/styles.md +576 -0
  174. package/docs/tasty-static.md +433 -0
  175. package/package.json +51 -30
  176. package/dist/styles/styledScrollbar.d.ts +0 -47
  177. package/dist/styles/styledScrollbar.js +0 -38
  178. package/dist/styles/styledScrollbar.js.map +0 -1
  179. package/dist/tokens/typography.d.ts +0 -19
  180. package/dist/tokens/typography.js +0 -237
  181. package/dist/tokens/typography.js.map +0 -1
  182. package/dist/utils/hsl-to-rgb.js +0 -38
  183. package/dist/utils/hsl-to-rgb.js.map +0 -1
  184. package/dist/utils/okhsl-to-rgb.js +0 -296
  185. package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/docs/dsl.md ADDED
@@ -0,0 +1,675 @@
1
+ # Style DSL Reference
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()`.
4
+
5
+ For the runtime React API (`tasty()`, hooks, component props), see [Runtime API](runtime.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
6
+
7
+ ---
8
+
9
+ ## Dictionary
10
+
11
+ ### Style Mapping
12
+
13
+ Object where keys represent states and values are the styles to apply:
14
+
15
+ ```jsx
16
+ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
17
+ ```
18
+
19
+ #### State Key Types
20
+
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 | `hovered & .active` | `[data-hovered].active` |
29
+
30
+ ### Sub-element
31
+
32
+ Element styled using a capitalized key. Identified by `data-element` attribute:
33
+
34
+ ```jsx
35
+ styles: { Title: { preset: 'h3' } }
36
+ // Targets: <div data-element="Title">
37
+ ```
38
+
39
+ #### Selector Affix (`$`)
40
+
41
+ Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles:
42
+
43
+ | Pattern | Result | Description |
44
+ |---------|--------|-------------|
45
+ | *(none)* | ` [el]` | Descendant (default) |
46
+ | `>` | `> [el]` | Direct child |
47
+ | `>Body>Row>` | `> [Body] > [Row] > [el]` | Chained elements |
48
+ | `h1` | ` h1` | Tag selector (no key injection) |
49
+ | `h1 >` | ` h1 > [el]` | Key is direct child of tag |
50
+ | `h1 *` | ` h1 *` | Any descendant of tag |
51
+ | `*` | ` *` | All descendants |
52
+ | `::before` | `::before` | Root pseudo (no key) |
53
+ | `@::before` | `[el]::before` | Pseudo on the sub-element |
54
+ | `>@:hover` | `> [el]:hover` | Pseudo-class on the sub-element |
55
+ | `>@.active` | `> [el].active` | Class on the sub-element |
56
+
57
+ Rules for key injection (`[data-element="..."]`):
58
+
59
+ - **Trailing combinator** (`>`, `+`, `~`) — key is injected after it
60
+ - **Uppercase element name** (`Body`, `Row`) — key is injected as descendant
61
+ - **HTML tag** (`h1`, `a`, `span`) — no key injection; the tag IS the selector
62
+ - **Universal selector** (`*`) — no key injection
63
+ - **Pseudo / class / attribute** — no key injection
64
+
65
+ 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:
66
+
67
+ ```jsx
68
+ const List = tasty({
69
+ styles: {
70
+ Item: {
71
+ $: '>@:last-child',
72
+ border: 'none',
73
+ },
74
+ },
75
+ });
76
+ // → .t0 > [data-element="Item"]:last-child { border: none }
77
+ ```
78
+
79
+ ### Color Token
80
+
81
+ Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
82
+
83
+ ```jsx
84
+ fill: '#purple.5' // → var(--purple-color) with 50% opacity
85
+ ```
86
+
87
+ ### Modifier
88
+
89
+ State value via `mods` prop that generates `data-*` attributes:
90
+
91
+ ```jsx
92
+ mods={{ hovered: true, theme: 'danger' }}
93
+ // → data-hovered="" data-theme="danger"
94
+ ```
95
+
96
+ Modifiers can also be exposed as top-level component props via `modProps` — see [Runtime — Mod Props](runtime.md#mod-props).
97
+
98
+ ---
99
+
100
+ ## Color Tokens & Opacity
101
+
102
+ ```jsx
103
+ color: '#purple', // Full opacity
104
+ color: '#purple.5', // 50% opacity
105
+ color: '#purple.05', // 5% opacity
106
+ fill: '#current', // → currentcolor
107
+ fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
108
+ color: '(#primary, #secondary)', // Fallback syntax
109
+ ```
110
+
111
+ ---
112
+
113
+ ## Built-in Units
114
+
115
+ | Unit | Description | Example | CSS Output |
116
+ |------|-------------|---------|------------|
117
+ | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
118
+ | `r` | Border radius | `1r` | `var(--radius)` |
119
+ | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
120
+ | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
121
+ | `ow` | Outline width | `1ow` | `var(--outline-width)` |
122
+ | `fs` | Font size | `1fs` | `var(--font-size)` |
123
+ | `lh` | Line height | `1lh` | `var(--line-height)` |
124
+ | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
125
+
126
+ You can register additional custom units via [`configure()`](configuration.md#options).
127
+
128
+ ---
129
+
130
+ ## Replace Tokens
131
+
132
+ Tokens defined via [`configure({ replaceTokens })`](configuration.md#replace-tokens-parse-time-substitution) are replaced at parse time and baked into the generated CSS:
133
+
134
+ ```jsx
135
+ const Card = tasty({
136
+ styles: {
137
+ padding: '$card-padding',
138
+ fill: '#surface',
139
+ border: '1bw solid #accent',
140
+ },
141
+ });
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Recipes
147
+
148
+ Apply predefined style bundles (defined via [`configure({ recipes })`](configuration.md#recipes)) using the `recipe` style property:
149
+
150
+ ```jsx
151
+ const Card = tasty({
152
+ styles: {
153
+ recipe: 'card',
154
+ color: '#text',
155
+ },
156
+ });
157
+
158
+ // Compose multiple recipes
159
+ const ElevatedCard = tasty({
160
+ styles: {
161
+ recipe: 'card elevated',
162
+ color: '#text',
163
+ },
164
+ });
165
+ ```
166
+
167
+ **Post-merge recipes (`/` separator):**
168
+
169
+ Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
170
+
171
+ ```jsx
172
+ const Input = tasty({
173
+ styles: {
174
+ recipe: 'reset input / input-autofill',
175
+ preset: 't3',
176
+ },
177
+ });
178
+ ```
179
+
180
+ Use `none` to skip base recipes and apply only post recipes:
181
+
182
+ ```jsx
183
+ const Custom = tasty({
184
+ styles: {
185
+ recipe: 'none / disabled',
186
+ padding: '2x',
187
+ },
188
+ });
189
+ ```
190
+
191
+ ---
192
+
193
+ ## Extending vs. Replacing State Maps
194
+
195
+ When a style property uses a state map, the merge behavior depends on whether the child provides a `''` (default) key:
196
+
197
+ - **No `''` key** — extend mode: parent states are preserved, child adds/overrides
198
+ - **Has `''` key** — replace mode: child defines everything from scratch
199
+
200
+ ```jsx
201
+ // Parent has: fill: { '': '#white', hovered: '#blue', disabled: '#gray' }
202
+
203
+ // Extend — no '' key, parent states preserved
204
+ const MyButton = tasty(Button, {
205
+ styles: {
206
+ fill: {
207
+ 'loading': '#yellow', // append new state
208
+ 'disabled': '#gray.20', // override existing state in place
209
+ },
210
+ },
211
+ });
212
+
213
+ // Replace — has '' key, parent states dropped
214
+ const MyButton = tasty(Button, {
215
+ styles: {
216
+ fill: {
217
+ '': '#red',
218
+ 'hovered': '#blue',
219
+ },
220
+ },
221
+ });
222
+ ```
223
+
224
+ Use `'@inherit'` to pull a parent state value. In extend mode it repositions the state; in replace mode it cherry-picks it:
225
+
226
+ ```jsx
227
+ // Extend mode: reposition disabled to end (highest CSS priority)
228
+ fill: {
229
+ 'loading': '#yellow',
230
+ disabled: '@inherit',
231
+ }
232
+
233
+ // Replace mode: cherry-pick disabled from parent
234
+ fill: {
235
+ '': '#red',
236
+ disabled: '@inherit',
237
+ }
238
+ ```
239
+
240
+ Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
241
+
242
+ ```jsx
243
+ fill: { pressed: null } // removes pressed from the result
244
+ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe too
245
+ ```
246
+
247
+ ### Resetting Properties with `null` and `false`
248
+
249
+ ```jsx
250
+ const SimpleButton = tasty(Button, {
251
+ styles: {
252
+ fill: null, // discard parent's fill, let recipe fill in
253
+ border: false, // no border at all (tombstone — blocks recipe too)
254
+ },
255
+ });
256
+ ```
257
+
258
+ | Value | Meaning | Recipe fills in? |
259
+ |-------|---------|-----------------|
260
+ | `undefined` | Not provided — parent preserved | N/A |
261
+ | `null` | Intentional unset — parent discarded | Yes |
262
+ | `false` | Tombstone — blocks everything | No |
263
+
264
+ ---
265
+
266
+ ## Advanced States (`@` prefix)
267
+
268
+ | Prefix | Purpose | Example |
269
+ |--------|---------|---------|
270
+ | `@media` | Media queries | `@media(w < 768px)` |
271
+ | `@(...)` | Container queries | `@(panel, w >= 300px)` |
272
+ | `@supports` | Feature/selector support | `@supports(display: grid)` |
273
+ | `@root` | Root element states | `@root(schema=dark)` |
274
+ | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
275
+ | `@own` | Sub-element's own state | `@own(hovered)` |
276
+ | `@starting` | Entry animation | `@starting` |
277
+ | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
278
+ | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
279
+ | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
280
+ | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
281
+
282
+ ### `@media(...)` — Media Queries
283
+
284
+ Media queries support dimension shorthands and custom unit expansion:
285
+
286
+ | Shorthand | Expands to |
287
+ |-----------|------------|
288
+ | `w` | `width` |
289
+ | `h` | `height` |
290
+
291
+ ```jsx
292
+ fill: {
293
+ '': '#surface',
294
+ '@media(w < 768px)': '#surface-mobile',
295
+ '@media(600px <= w < 1200px)': '#surface-tablet',
296
+ '@media(prefers-color-scheme: dark)': '#surface-dark',
297
+ }
298
+ ```
299
+
300
+ | Tasty syntax | CSS output |
301
+ |--------------|------------|
302
+ | `@media(w < 768px)` | `@media (width < 768px)` |
303
+ | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
304
+ | `@media:print` | `@media print` |
305
+ | `@media:screen` | `@media screen` |
306
+ | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
307
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
308
+
309
+ Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
310
+
311
+ In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
312
+
313
+ ### `@(...)` — Container Queries
314
+
315
+ 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`.
316
+
317
+ | Shorthand | Expands to |
318
+ |-----------|------------|
319
+ | `w` | `width` |
320
+ | `h` | `height` |
321
+ | `is` | `inline-size` |
322
+ | `bs` | `block-size` |
323
+
324
+ ```jsx
325
+ const Panel = tasty({
326
+ styles: {
327
+ flow: {
328
+ '': 'column',
329
+ '@(layout, w >= 600px)': 'row',
330
+ },
331
+ },
332
+ });
333
+ ```
334
+
335
+ | Tasty syntax | CSS output |
336
+ |--------------|------------|
337
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
338
+ | `@(w < 600px)` | `@container (width < 600px)` |
339
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
340
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
341
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
342
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
343
+
344
+ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
345
+
346
+ ### `@supports(...)` — Feature Queries
347
+
348
+ Feature queries test CSS property support. Use `$` as the first argument to test selector support:
349
+
350
+ | Tasty syntax | CSS output |
351
+ |--------------|------------|
352
+ | `@supports(display: grid)` | `@supports (display: grid)` |
353
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
354
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
355
+
356
+ ```jsx
357
+ display: {
358
+ '': 'flex',
359
+ '@supports(display: grid)': 'grid',
360
+ }
361
+ ```
362
+
363
+ ### `@root(...)` — Root Element States
364
+
365
+ Root states generate selectors on the `:root` element. They are useful for theme modes, feature flags, and other page-level conditions:
366
+
367
+ 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.
368
+
369
+ ```jsx
370
+ color: {
371
+ '': '#text',
372
+ '@root(schema=dark)': '#text-on-dark',
373
+ '@root(.premium-user)': '#gold',
374
+ }
375
+ ```
376
+
377
+ | Tasty syntax | CSS selector |
378
+ |--------------|-------------|
379
+ | `@root(schema=dark)` | `:root[data-schema="dark"]` |
380
+ | `@root(hovered)` | `:root[data-hovered]` |
381
+ | `@root(.premium-user)` | `:root.premium-user` |
382
+ | `@root([lang="en"])` | `:root[lang="en"]` |
383
+ | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
384
+
385
+ Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
386
+
387
+ ### `@own(...)` — Sub-element's Own State
388
+
389
+ 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:
390
+
391
+ ```jsx
392
+ const Nav = tasty({
393
+ styles: {
394
+ NavItem: {
395
+ color: {
396
+ '': '#text',
397
+ '@own(:hover)': '#primary',
398
+ '@own(:focus-visible)': '#primary',
399
+ 'selected': '#primary', // root-level modifier
400
+ },
401
+ },
402
+ },
403
+ elements: { NavItem: 'a' },
404
+ });
405
+ ```
406
+
407
+ | Tasty syntax (inside sub-element) | CSS output |
408
+ |-----------------------------------|------------|
409
+ | `@own(:hover)` | `:hover` on the sub-element selector |
410
+ | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
411
+ | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
412
+
413
+ `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
414
+
415
+ ### `@starting` — Entry Animation
416
+
417
+ Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
418
+
419
+ ```jsx
420
+ const FadeIn = tasty({
421
+ styles: {
422
+ opacity: { '': '1', '@starting': '0' },
423
+ transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
424
+ transition: 'opacity 0.3s, translate 0.3s',
425
+ },
426
+ });
427
+ ```
428
+
429
+ | Tasty syntax | CSS output |
430
+ |--------------|------------|
431
+ | `@starting` | `@starting-style { .t0.t0 { ... } }` |
432
+
433
+ ### `@parent(...)` — Parent Element States
434
+
435
+ Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`) is supported inside `@parent()`.
436
+
437
+ ```jsx
438
+ const Highlight = tasty({
439
+ styles: {
440
+ fill: {
441
+ '': '#white',
442
+ '@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
443
+ '@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
444
+ },
445
+ },
446
+ });
447
+ ```
448
+
449
+ | Syntax | CSS Output |
450
+ |--------|------------|
451
+ | `@parent(hovered)` | `:is([data-hovered] *)` |
452
+ | `!@parent(hovered)` | `:not([data-hovered] *)` |
453
+ | `@parent(hovered, >)` | `:is([data-hovered] > *)` (direct parent) |
454
+ | `@parent(.active)` | `:is(.active *)` |
455
+ | `@parent(hovered & focused)` | `:is([data-hovered][data-focused] *)` (same ancestor) |
456
+ | `@parent(hovered) & @parent(focused)` | `:is([data-hovered] *):is([data-focused] *)` (independent ancestors) |
457
+ | `@parent(hovered \| focused)` | `:is([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
458
+
459
+ For sub-elements, the parent check applies to the root element's ancestors:
460
+
461
+ ```jsx
462
+ const Card = tasty({
463
+ styles: {
464
+ Label: {
465
+ color: {
466
+ '': '#text',
467
+ '@parent(hovered)': '#primary',
468
+ },
469
+ },
470
+ },
471
+ });
472
+ // → .t0.t0:is([data-hovered] *) [data-element="Label"]
473
+ ```
474
+
475
+ ### `:is()`, `:has()` — CSS Structural Pseudo-classes
476
+
477
+ 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 `*`.
478
+
479
+ `:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
480
+
481
+ > **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.
482
+
483
+ ```jsx
484
+ const Card = tasty({
485
+ styles: {
486
+ display: {
487
+ '': 'block',
488
+ ':has(> Icon)': 'grid', // has Icon as direct child
489
+ ':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
490
+ ':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
491
+ ':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
492
+ ':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
493
+ ':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
494
+ '!:has(> Icon)': 'flex', // negation: no Icon child
495
+ },
496
+ },
497
+ });
498
+ ```
499
+
500
+ | Syntax | CSS Output | Meaning |
501
+ |--------|------------|---------|
502
+ | `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
503
+ | `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
504
+ | `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
505
+ | `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
506
+ | `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
507
+ | `:has(>)` | `:has(> *)` | Has any direct child |
508
+ | `:is(> Field + input)` | `:is(> [data-element="Field"] + input)` | Structural match |
509
+ | `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
510
+ | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
511
+ | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
512
+
513
+ Combine with other states using boolean logic:
514
+
515
+ ```jsx
516
+ ':has(> Icon) & hovered' // structural + data attribute
517
+ '@parent(hovered) & :has(> Icon)' // parent check + structural
518
+ ':has(> Icon) | :has(> Button)' // OR: either sub-element present
519
+ ```
520
+
521
+ > **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.
522
+
523
+ ---
524
+
525
+ ## Keyframes
526
+
527
+ Define animations inline using the `@keyframes` key in styles:
528
+
529
+ ```jsx
530
+ const Pulse = tasty({
531
+ styles: {
532
+ animation: 'pulse 2s infinite',
533
+ '@keyframes': {
534
+ pulse: {
535
+ '0%, 100%': { transform: 'scale(1)' },
536
+ '50%': { transform: 'scale(1.05)' },
537
+ },
538
+ },
539
+ },
540
+ });
541
+ ```
542
+
543
+ ---
544
+
545
+ ## Properties (`@property`)
546
+
547
+ 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:
548
+
549
+ ```jsx
550
+ const AnimatedGradient = tasty({
551
+ styles: {
552
+ '$gradient-angle': '0deg',
553
+ '#theme': 'okhsl(280 80% 50%)',
554
+ background: 'linear-gradient($gradient-angle, #theme, transparent)',
555
+ transition: '$$gradient-angle 0.3s, ##theme 0.3s',
556
+ },
557
+ });
558
+ ```
559
+
560
+ 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.
561
+
562
+ Use explicit `@properties` when you need non-default settings like `inherits: false`:
563
+
564
+ ```jsx
565
+ '@properties': {
566
+ '$gradient-angle': { syntax: '<angle>', inherits: false, initialValue: '0deg' },
567
+ },
568
+ ```
569
+
570
+ ---
571
+
572
+ ## Font Face (`@fontFace`)
573
+
574
+ 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).
575
+
576
+ ```ts
577
+ const Heading = tasty({
578
+ styles: {
579
+ '@fontFace': {
580
+ 'Brand Sans': {
581
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
582
+ fontDisplay: 'swap',
583
+ },
584
+ },
585
+ fontFamily: '"Brand Sans", sans-serif',
586
+ },
587
+ });
588
+ ```
589
+
590
+ ### Multiple weights
591
+
592
+ Supply an array to register several variants of the same family:
593
+
594
+ ```ts
595
+ '@fontFace': {
596
+ 'Brand Sans': [
597
+ { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
598
+ { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
599
+ ],
600
+ }
601
+ ```
602
+
603
+ ### Supported descriptors
604
+
605
+ | Descriptor | CSS property | Type |
606
+ |---|---|---|
607
+ | `src` (required) | `src` | `string` |
608
+ | `fontWeight` | `font-weight` | `string \| number` |
609
+ | `fontStyle` | `font-style` | `string` |
610
+ | `fontStretch` | `font-stretch` | `string` |
611
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
612
+ | `unicodeRange` | `unicode-range` | `string` |
613
+ | `ascentOverride` | `ascent-override` | `string` |
614
+ | `descentOverride` | `descent-override` | `string` |
615
+ | `lineGapOverride` | `line-gap-override` | `string` |
616
+ | `sizeAdjust` | `size-adjust` | `string` |
617
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
618
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
619
+
620
+ > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
621
+
622
+ ---
623
+
624
+ ## Counter Style (`@counterStyle`)
625
+
626
+ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
627
+
628
+ ```ts
629
+ const EmojiList = tasty({
630
+ tag: 'ol',
631
+ styles: {
632
+ '@counterStyle': {
633
+ thumbs: {
634
+ system: 'cyclic',
635
+ symbols: '"👍"',
636
+ suffix: '" "',
637
+ },
638
+ },
639
+ listStyleType: 'thumbs',
640
+ },
641
+ });
642
+ ```
643
+
644
+ ### Supported descriptors
645
+
646
+ | Descriptor | CSS property | Type |
647
+ |---|---|---|
648
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
649
+ | `symbols` | `symbols` | `string` |
650
+ | `additiveSymbols` | `additive-symbols` | `string` |
651
+ | `prefix` | `prefix` | `string` |
652
+ | `suffix` | `suffix` | `string` |
653
+ | `negative` | `negative` | `string` |
654
+ | `range` | `range` | `string` |
655
+ | `pad` | `pad` | `string` |
656
+ | `fallback` | `fallback` | `string` |
657
+ | `speakAs` | `speak-as` | `string` |
658
+
659
+ > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
660
+
661
+ ---
662
+
663
+ ## Style Properties
664
+
665
+ For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
666
+
667
+ ---
668
+
669
+ ## Learn more
670
+
671
+ - **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, hooks
672
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
673
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
674
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
675
+ - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin