@tenphi/tasty 0.0.0-snapshot.c8bdaeb → 0.0.0-snapshot.cae4fee

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