@tenphi/tasty 0.0.0-snapshot.05c1c22

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