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

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 (331) hide show
  1. package/README.md +377 -238
  2. package/dist/babel-rZcEwPLM.d.ts +82 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/chunks/collector-D2ARGT2L.js +208 -0
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/collector-w4mBj5gd.d.ts +164 -0
  34. package/dist/config-CZWCzBr6.d.ts +1349 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-G9JuwM9p.d.ts +1920 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +6 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +18 -0
  54. package/dist/ssr/astro-middleware.js +7 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +127 -0
  57. package/dist/ssr/astro.js +221 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +36 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +128 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +46 -0
  66. package/dist/ssr/next.js +60 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +90 -5
  69. package/dist/static/index.js +31 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +4 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-JEY8PVYP.d.ts +1567 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +230 -106
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +80 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +57 -33
  81. package/dist/zero/next.js +93 -59
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +684 -56
  88. package/docs/debug.md +170 -343
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1065 -0
  91. package/docs/getting-started.md +240 -0
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +765 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +683 -0
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +211 -63
  101. package/docs/tasty-static.md +273 -67
  102. package/package.json +182 -58
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -417
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -856
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -451
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -221
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -23
  256. package/dist/styles/scrollbar.js +0 -34
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/selector-transform.js +0 -32
  314. package/dist/utils/selector-transform.js.map +0 -1
  315. package/dist/utils/string.js +0 -8
  316. package/dist/utils/string.js.map +0 -1
  317. package/dist/utils/styles.d.ts +0 -177
  318. package/dist/utils/styles.js +0 -730
  319. package/dist/utils/styles.js.map +0 -1
  320. package/dist/utils/typography.d.ts +0 -36
  321. package/dist/utils/typography.js +0 -53
  322. package/dist/utils/typography.js.map +0 -1
  323. package/dist/utils/warnings.d.ts +0 -16
  324. package/dist/utils/warnings.js +0 -16
  325. package/dist/utils/warnings.js.map +0 -1
  326. package/dist/zero/css-writer.d.ts +0 -45
  327. package/dist/zero/css-writer.js +0 -74
  328. package/dist/zero/css-writer.js.map +0 -1
  329. package/dist/zero/extractor.d.ts +0 -24
  330. package/dist/zero/extractor.js.map +0 -1
  331. package/docs/usage.md +0 -695
@@ -1,6 +1,8 @@
1
1
  # Configuration
2
2
 
3
- Configure the Tasty style system before your app renders using the `configure()` function. Configuration must be done **before any styles are generated** (before first render).
3
+ Tasty works without upfront configuration. Use `configure()` when your app or design system is ready to define shared tokens, state aliases, units, recipes, presets, or extension points.
4
+
5
+ Call it **before any styles are generated** (before first render). For a guided setup, see [Getting Started](getting-started.md). For the higher-level docs map, see the [Docs Hub](README.md).
4
6
 
5
7
  ```jsx
6
8
  import { configure } from '@tenphi/tasty';
@@ -13,7 +15,7 @@ configure({
13
15
  states: {
14
16
  '@mobile': '@media(w < 768px)',
15
17
  '@tablet': '@media(768px <= w < 1024px)',
16
- '@dark': '@root(theme=dark)',
18
+ '@dark': '@root(schema=dark)',
17
19
  },
18
20
 
19
21
  // Parser configuration
@@ -26,56 +28,504 @@ configure({
26
28
  custom: (n) => `${n * 10}px`, // Function-based unit
27
29
  },
28
30
 
29
- // Custom functions for the parser
30
- funcs: {
31
+ // Custom functions — a single map for both flavors, discriminated by value type:
32
+ functions: {
33
+ // Bare key + function value → parse-time function, called as `double(...)`
31
34
  double: (groups) => {
32
35
  const value = parseFloat(groups[0]?.output || '0');
33
36
  return `${value * 2}px`;
34
37
  },
38
+ // `$$name` key + object value → declarative CSS @function, called as `$$negative(...)`
39
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
35
40
  },
36
41
  });
37
42
  ```
38
43
 
44
+ These docs use `data-schema="dark"` in examples. If your app already standardizes on a different attribute such as `data-theme`, keep the same pattern and swap the attribute name consistently everywhere you define root-state aliases.
45
+
39
46
  ---
40
47
 
41
48
  ## Options
42
49
 
43
- | Option | Type | Default | Description |
44
- |--------|------|---------|-------------|
45
- | `nonce` | `string` | - | CSP nonce for style elements |
46
- | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
47
- | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
48
- | `units` | `Record<string, string \| Function>` | Built-in | Custom units (merged with built-in). See [built-in units](usage.md#built-in-units) |
49
- | `funcs` | `Record<string, Function>` | - | Custom parser functions (merged with existing) |
50
- | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in) |
51
- | `tokens` | `Record<string, string \| number>` | - | Predefined tokens replaced during parsing |
52
- | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
53
- | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
54
- | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
55
- | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
50
+ | Option | Type | Default | Description |
51
+ | -------------------- | ------------------------------------------------ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
52
+ | `nonce` | `string` | - | CSP nonce for style elements |
53
+ | `maxRulesPerSheet` | `number` | `8192` | Maximum rules per injected stylesheet |
54
+ | `forceTextInjection` | `boolean` | auto (`true` in test envs) | Force text-node CSS injection instead of constructable stylesheets |
55
+ | `devMode` | `boolean` | auto | Enable development-mode features: performance metrics and debug info |
56
+ | `states` | `Record<string, string>` | - | Global state aliases for advanced state mapping |
57
+ | `parserCacheSize` | `number` | `1000` | Parser LRU cache size |
58
+ | `units` | `Record<string, string \| UnitHandler>` | Built-in | Custom units (merged with built-in). See [built-in units](dsl.md#built-in-units) |
59
+ | `functions` | `Record<string, FunctionDefinition \| Function>` | - | Custom functions (merged). Bare keys → parse functions; `$$name` keys → declarative CSS `@function` definitions |
60
+ | `handlers` | `Record<string, StyleHandlerDefinition>` | Built-in | Custom style handlers (replace built-in). See [Custom Style Handlers](#custom-style-handlers) |
61
+ | `propHandlers` | `Record<string, PropHandlerDefinition>` | - | Props middleware for every component — props in, props out. See [Props Middleware](#props-middleware) |
62
+ | `baseStyleProps` | `readonly string[]` | - | Style names exposed as props on **every** component. See [Base Style Props](#base-style-props) |
63
+ | `tokens` | `Record<string, value \| stateMap>` | - | Design tokens injected as `:root` CSS custom properties |
64
+ | `replaceTokens` | `Record<string, string \| number \| boolean>` | - | Parse-time token substitution (inline replacement). `boolean` is allowed for `#` color tokens |
65
+ | `keyframes` | `Record<string, KeyframesSteps>` | - | Global keyframes for animations |
66
+ | `properties` | `Record<string, PropertyDefinition>` | - | Global CSS @property definitions |
67
+ | `fontFaces` | `Record<string, FontFaceInput>` | - | Global @font-face definitions |
68
+ | `counterStyles` | `Record<string, CounterStyleDescriptors>` | - | Global @counter-style definitions |
69
+ | `polyfills` | `{ functions?: boolean }` | `{}` | Opt-in polyfills for not-yet-baseline features. `functions: true` inlines `@function` calls into plain CSS at parse time |
70
+ | `autoPropertyTypes` | `boolean` | `true` | Auto-infer and register `@property` types from values |
71
+ | `recipes` | `Record<string, RecipeStyles>` | - | Predefined style recipes (named style bundles) |
72
+ | `presets` | `Record<string, TypographyPreset>` | - | Typography presets — shorthand for `generateTypographyTokens()` |
73
+ | `globalStyles` | `Record<string, Styles>` | - | Global Tasty styles keyed by CSS selector |
74
+ | `plugins` | `TastyPlugin[]` | - | Plugins that bundle any of the above (processed in order; later override earlier, and direct config wins over all). See [Plugins](plugins.md) |
75
+ | `gc` | `GCConfig` | - | Garbage-collection tuning for unused styles (`{ touchInterval, capacity }`) |
76
+ | `batchInjection` | `boolean \| 'always'` | `false` | Defer stylesheet writes and apply them in one batch. See [Batched injection](#batched-injection) |
77
+ | `colorSpace` | `'rgb' \| 'hsl' \| 'oklch'` | - | **Deprecated** — no longer has any effect. See [Color space](#color-space) |
78
+ | `namePrefix` | `string` | `'t'` (`tasty`) / `'ts'` (build-time) | Prefix prepended to every generated identifier (class, keyframe, counter-style names). Must match `^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$`. See [Name prefix](#name-prefix). |
56
79
 
57
80
  ---
58
81
 
59
- ## Predefined Tokens
82
+ ## Batched Injection
83
+
84
+ Every `insertRule()` on a live stylesheet invalidates style for that sheet's
85
+ scope. Components inject during React's render phase, and if anything else reads
86
+ layout in the same pass, the two interleave:
87
+
88
+ ```
89
+ inject -> read (forced style recalc) -> inject -> read (forced recalc) -> ...
90
+ ```
91
+
92
+ A UI kit that measures during render — popovers, autosizing inputs, virtualized
93
+ lists — can turn one mount into a dozen full-tree recalculations. `batchInjection`
94
+ queues the writes instead and applies them together, so the tree is invalidated
95
+ once per flush.
96
+
97
+ ```tsx
98
+ import { configure, TastyBatchProvider } from '@tenphi/tasty';
99
+
100
+ configure({ batchInjection: true });
101
+
102
+ createRoot(el).render(
103
+ <TastyBatchProvider>
104
+ <App />
105
+ </TastyBatchProvider>,
106
+ );
107
+ ```
108
+
109
+ ### Why the provider is required
110
+
111
+ Deferring a write past React's layout phase would let a `useLayoutEffect`
112
+ measure an element whose rules are not in the sheet yet and read its _unstyled_
113
+ box — a wrong number, not a stale one, so it never self-corrects.
114
+
115
+ `TastyBatchProvider` closes that hole. It opens a _batch window_ during its
116
+ render and closes it — flushing — in `useInsertionEffect`, which React runs in
117
+ the mutation phase, before any layout effect:
118
+
119
+ ```
120
+ provider renders -> window OPEN
121
+ children render -> injections queued
122
+ provider insertionEffect -> FLUSH, window CLOSED
123
+ layout effects run -> rules are in the sheet
124
+ ```
125
+
126
+ With `batchInjection: true` a write is only ever queued inside such a window, so
127
+ turning the flag on can make injection cheaper but can never make a measurement
128
+ wrong. Injections outside a window are written straight through, exactly as with
129
+ batching off:
130
+
131
+ - a deep update that did not re-render the provider
132
+ - an injection from a layout effect, an event handler or an async callback
133
+ - SSR and RSC, where there is no live sheet at all
134
+
135
+ Mount the provider as high in the tree as you can: batching applies to the
136
+ commits it takes part in.
137
+
138
+ ### Modes
139
+
140
+ | Value | Behaviour |
141
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
142
+ | `false` (default) | One `insertRule()` per component, synchronously. |
143
+ | `true` | Batch inside a provider window only. Cannot affect measurement. Without the provider nothing is batched, and dev mode says so once. |
144
+ | `'always'` | Batch every injection, flushing on a microtask when no window is open. Covers more commits; a `useLayoutEffect` measuring a freshly mounted element can read its unstyled box. Paint is unaffected — microtasks always drain before the browser paints. |
145
+
146
+ ### Ordering
147
+
148
+ All writes share one FIFO queue — component rules, global rules, raw CSS,
149
+ `@property`, `@keyframes`, `@font-face`, `@counter-style` and `@function`.
150
+ Draining it in insertion order keeps the sheet byte-identical to unbatched
151
+ output, which matters because equal-specificity rules resolve by document order.
152
+
153
+ ### Client rendering, server rendering, and build-time extraction
154
+
155
+ **Server render — nothing to batch, safe to leave enabled.** SSR and RSC collect
156
+ CSS as text through `ServerStyleCollector`; the runtime injector never runs
157
+ there, so `batchInjection` changes nothing either way. `<TastyBatchProvider>`
158
+ renders its children and does nothing else: the window it opens is a no-op
159
+ without a `document`, and the `useInsertionEffect` that would close it never
160
+ fires on the server. Configure the flag once in shared code — no environment
161
+ branching needed.
162
+
163
+ **Hydration — the better your SSR coverage, the less there is to batch.**
164
+ `hydrateTastyClasses()` (wired up for you by `@tenphi/tasty/ssr/next` and the
165
+ Astro integration) pre-populates the injector from `window.__TASTY__`, so
166
+ hydrating a server-rendered class is a cache hit that produces no sheet write at
167
+ all. Batching pays off on what SSR could not cover: client-only routes, styles
168
+ that first appear after hydration (a `styles` prop that changes on interaction, a
169
+ modal or popover mounting), and dynamic tokens.
170
+
171
+ **Astro islands — one provider per island, or `'always'`.** Every island is its
172
+ own React root, so a provider inside one island does not open a window for
173
+ another. With `batchInjection: true`, wrap each island root that renders enough
174
+ tasty components to be worth it. `'always'` needs no provider and covers every
175
+ island, at the cost of the measurement hazard above. Either way, an island that
176
+ only re-hydrates server-rendered classes has nothing to batch.
177
+
178
+ **Build-time extraction (`tastyStatic`) — unaffected.** The Babel plugin never
179
+ touches the injector: the babel plugin emits either a CSS file import or an
180
+ `injectCSS()` call from `@tenphi/tasty/static/inject`, which appends text to a
181
+ single `<style data-tasty-static>` element. `batchInjection` only defers CSSOM
182
+ writes made by the browser injector, so extracted styles are unchanged. In an app
183
+ that mixes both, it still applies to the `tasty()` half.
184
+
185
+ ### `flushStyles()`
186
+
187
+ Applies every pending write immediately. Every injector read API calls it for
188
+ you — `getCSSText`, `getCSSTextForClasses`, `getCSSTextForNode`,
189
+ `getRawCSSText`, `isPropertyDefined`, `getMetrics`, `cleanup`, `gc` and
190
+ `destroy` — so a read never observes a partial sheet.
191
+ Call it directly before measuring in code that runs outside a batch window under
192
+ `'always'`:
193
+
194
+ ```tsx
195
+ import { flushStyles } from '@tenphi/tasty';
196
+
197
+ useLayoutEffect(() => {
198
+ flushStyles();
199
+ const { width } = ref.current.getBoundingClientRect();
200
+ }, []);
201
+ ```
202
+
203
+ `hasPendingStyleWrites()` reports whether anything is queued, and
204
+ `resetStyleBatch()` drops the queue without applying it (tests only).
205
+
206
+ ---
207
+
208
+ ## Color Space
209
+
210
+ > **Deprecated.** `configure({ colorSpace })` no longer has any effect and will
211
+ > be removed in the next major. Setting it warns in development.
212
+
213
+ A `#name` token's value used to be rewritten into a configured color space, so
214
+ `#brand: '#ff8800'` declared `--brand-color: oklch(0.75 0.16 55)`. That existed
215
+ to serve the opacity suffix, which needed numeric channels to write an alpha
216
+ into. Opacity now uses CSS relative color syntax —
217
+ `oklch(from var(--brand-color) l c h / .5)` — which has the browser read the
218
+ channels, so there is nothing left for the setting to decide.
219
+
220
+ A color is emitted exactly as authored:
221
+
222
+ ```jsx
223
+ configure({ tokens: { '#brand': '#ff8800' } });
224
+ // → --brand-color: #ff8800
225
+ ```
226
+
227
+ That holds for every form: a hex literal, a native color function, a bare CSS
228
+ color name, a `color-mix()`, a `light-dark()`, a fallback chain. A `#token`
229
+ reference still resolves to its `var()` chain, and a plugin color function such
230
+ as `okhsl()` is still resolved by the parser to the color it denotes.
231
+
232
+ To address a token's channels, use relative color syntax against the token:
60
233
 
61
- Define reusable tokens that are replaced during style parsing. Unlike component-level `tokens` prop (which renders as inline CSS custom properties), predefined tokens are baked into the generated CSS.
234
+ ```css
235
+ background: oklch(from var(--brand-color) calc(l * 1.2) c h);
236
+ ```
237
+
238
+ This works on any `<color>`, including the ones no build-time conversion could
239
+ have evaluated — and it is what the [opacity suffix](dsl.md#color-tokens--opacity)
240
+ itself uses. Its space is always `oklch`, which is unbounded, so a wide-gamut
241
+ color survives a round trip a narrower space would clamp.
62
242
 
63
- Use `$name` for custom property tokens and `#name` for color tokens:
243
+ ### Migrating off `colorSpace`
244
+
245
+ Drop the option. If you relied on the uniform output format, nothing in Tasty
246
+ needs it — author your tokens in the space you want them emitted in, since the
247
+ value now passes through untouched:
248
+
249
+ ```jsx
250
+ // before: any input, normalized to the configured space on the way out
251
+ configure({ colorSpace: 'oklch', tokens: { '#brand': '#ff8800' } });
252
+
253
+ // after: author it in the space you want
254
+ configure({ tokens: { '#brand': 'oklch(0.75 0.16 55)' } });
255
+ ```
256
+
257
+ ### Migrating off the channel companions
258
+
259
+ A `#name` token used to declare a second variable beside `--name-color` holding
260
+ its channels decomposed, suffixed with the configured space —
261
+ `--brand-color-oklch: 0.75 0.16 55` — and a `color` style emitted
262
+ `--current-color-{space}` beside `--current-color`. Both are gone, for the same
263
+ reason: they existed so an opacity suffix had channels to write an alpha into.
264
+
265
+ These were never part of the public API, but they were visible in the emitted
266
+ CSS, so hand-authored CSS may reference one. Address the token itself instead:
267
+
268
+ ```css
269
+ /* before */
270
+ color: oklch(var(--brand-color-oklch) / 0.5);
271
+ background: oklch(var(--brand-color-oklch));
272
+
273
+ /* after */
274
+ color: oklch(from var(--brand-color) l c h / 0.5);
275
+ background: var(--brand-color);
276
+ ```
277
+
278
+ The replacement is strictly more capable — the companion could only be
279
+ decomposed for a color the engine could evaluate at build time, while relative
280
+ color syntax works on every `<color>`, including a `color-mix()`, a
281
+ `light-dark()`, and a variable Tasty never defined.
282
+
283
+ ---
284
+
285
+ ## Name Prefix
286
+
287
+ Every identifier Tasty generates — class names, keyframe names, counter-style names — starts with a configurable prefix. The `tasty()` client, SSR, and RSC paths default to `'t'`; the build-time extraction path (`tastyStatic` via the Babel plugin) defaults to `'ts'` so extracted classes can never collide with `tasty()` classes when both are loaded on the same page.
288
+
289
+ ```jsx
290
+ configure({
291
+ namePrefix: 'mb',
292
+ });
293
+ ```
294
+
295
+ The prefix is prepended verbatim to the hash, so include any separator inside the prefix string itself:
296
+
297
+ | Setting | Class | Keyframe | Counter-style |
298
+ | --------------------------- | ------------- | -------------- | -------------- |
299
+ | `'t'` (`tasty` default) | `t1a2b3` | `tk1a2b3` | `tc1a2b3` |
300
+ | `'ts'` (build-time default) | `ts1a2b3` | `tsk1a2b3` | `tsc1a2b3` |
301
+ | `'mb'` | `mb1a2b3` | `mbk1a2b3` | `mbc1a2b3` |
302
+ | `'myapp-'` | `myapp-1a2b3` | `myapp-k1a2b3` | `myapp-c1a2b3` |
303
+
304
+ The single-letter discriminators (`k` for keyframes, `c` for counter-styles) keep the three kinds visually distinct in devtools — they are not required for correctness because CSS keeps these in separate namespaces.
305
+
306
+ ### Rules
307
+
308
+ - Must match `^[a-zA-Z_][a-zA-Z0-9_-]{0,31}$`. Examples that pass: `'t'`, `'ts'`, `'app'`, `'myapp-'`, `'_foo'`. Examples that fail: `''`, `'1foo'`, `'my app'`.
309
+ - Validated at `configure()` time; an invalid prefix throws synchronously rather than silently producing broken hydration.
310
+ - Locked once styles have been generated, like all other config.
311
+
312
+ ### Coexistence with build-time extraction
313
+
314
+ The `tasty()` and `tastyStatic()` paths **must use different prefixes** when both are loaded on the same page. Defaults already guarantee this; if you customize one, customize the other accordingly:
315
+
316
+ ```jsx
317
+ // app config (client / SSR / RSC)
318
+ configure({ namePrefix: 'mb' });
319
+
320
+ // tasty-zero.config.ts (Babel plugin)
321
+ export default { namePrefix: 'mbs' };
322
+ ```
323
+
324
+ If you only use one of the two builds, you only need to set `namePrefix` on that path.
325
+
326
+ ---
327
+
328
+ ## Design Tokens
329
+
330
+ Design tokens define CSS custom properties on `:root`. They are injected automatically when the first style is rendered. Values are parsed through the Tasty DSL, so you can use units, color syntax, and other DSL features.
331
+
332
+ Tokens support state maps for responsive or theme-aware values:
64
333
 
65
334
  ```jsx
66
335
  configure({
67
336
  tokens: {
337
+ $gap: '4px',
338
+ $radius: '6px',
339
+ '#primary': {
340
+ '': '#purple',
341
+ '@dark': '#light-purple',
342
+ },
343
+ '$font-size': {
344
+ '': '14px',
345
+ '@mobile': '12px',
346
+ },
347
+ },
348
+ });
349
+ ```
350
+
351
+ - `$name` keys become `--name` CSS custom properties
352
+ - `#name` keys become `--name-color` custom properties
353
+ - Names keep their case, since CSS custom properties are case-sensitive: `$myVar` is `--myVar` and is referenced as `$myVar`. A leading capital is not supported and folds — `$Foo` and `#Purple` become `--foo` and `--purple-color` — so start names lowercase. Kebab-case (`$my-var`) remains the convention.
354
+
355
+ Tokens are automatically emitted in all delivery modes: client rendering, server rendering, and build-time extraction with the Babel plugin.
356
+
357
+ ---
358
+
359
+ ## Replace Tokens (Parse-Time Substitution)
360
+
361
+ Replace tokens are **substituted inline at parse time** — they are baked into the generated CSS, not resolved via CSS custom properties at runtime. This makes them ideal for value aliases and shorthand references.
362
+
363
+ Use `$name` for value tokens and `#name` for color token aliases:
364
+
365
+ ```jsx
366
+ configure({
367
+ replaceTokens: {
68
368
  $spacing: '2x',
69
369
  '$card-padding': '4x',
70
- '$button-height': '40px',
71
370
  '#accent': '#purple',
72
- '#surface': '#white',
73
371
  '#surface-hover': '#gray.05',
74
372
  },
75
373
  });
76
374
  ```
77
375
 
78
- Once defined, tokens can be used in any component's styles — see [Using Predefined Tokens](usage.md#predefined-tokens) in the usage guide.
376
+ When a component uses `padding: '$card-padding'`, the parser replaces it with `'4x'` before generating CSS. When a component uses `fill: '#accent'`, it is replaced with `'#purple'`, which in turn resolves to `var(--purple-color)`.
377
+
378
+ See [Replace Tokens](dsl.md#replace-tokens) in the Style DSL reference.
379
+
380
+ ---
381
+
382
+ ## Font Face
383
+
384
+ Register custom fonts globally so every component can reference them by family name. Values are descriptor objects or arrays (for multiple weights/styles). Rules are injected eagerly when styles are first generated.
385
+
386
+ ```ts
387
+ configure({
388
+ fontFaces: {
389
+ 'Brand Sans': [
390
+ {
391
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
392
+ fontWeight: 400,
393
+ fontDisplay: 'swap',
394
+ },
395
+ {
396
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
397
+ fontWeight: 700,
398
+ fontDisplay: 'swap',
399
+ },
400
+ ],
401
+ Icons: {
402
+ src: 'url("/fonts/icons.woff2") format("woff2")',
403
+ fontDisplay: 'block',
404
+ },
405
+ },
406
+ });
407
+ ```
408
+
409
+ Now any component can use `font: '"Brand Sans", sans-serif'` and the browser will already have the `@font-face` rules in the stylesheet.
410
+
411
+ See [Font Face (`@font-face`)](dsl.md#font-face-font-face) for inline usage inside component styles and the full list of supported descriptors.
412
+
413
+ ---
414
+
415
+ ## Counter Style
416
+
417
+ Define custom list-marker algorithms globally. Rules are injected eagerly when styles are first generated.
418
+
419
+ ```ts
420
+ configure({
421
+ counterStyles: {
422
+ thumbs: {
423
+ system: 'cyclic',
424
+ symbols: '"👍"',
425
+ suffix: '" "',
426
+ },
427
+ 'lower-roman-parens': {
428
+ system: 'extends lower-roman',
429
+ suffix: '") "',
430
+ },
431
+ },
432
+ });
433
+ ```
434
+
435
+ Components can then reference `listStyleType: 'thumbs'` directly.
436
+
437
+ See [Counter Style (`@counter-style`)](dsl.md#counter-style-counter-style) for inline usage inside component styles and the full list of supported descriptors.
438
+
439
+ ---
440
+
441
+ ## Functions
442
+
443
+ The single `functions` map holds both kinds of custom functions, discriminated by the value type:
444
+
445
+ - **Parse functions** — a **bare key** with a **function value** `(groups) => string`. Runs at parse time and is called as `name(...)`. Use these for computed/derived CSS that JavaScript produces (e.g. color-space conversions).
446
+ - **CSS `@function` definitions** — a **`$$name` key** with an **object value** (a [`FunctionDefinition`](https://developer.mozilla.org/en-US/docs/Web/CSS/@function)). Injected eagerly as a native `@function` rule and called as `$$name(...)` (→ `--name(...)`).
447
+
448
+ ```ts
449
+ configure({
450
+ functions: {
451
+ // Parse function — bare key, function value
452
+ double: (groups) => `calc(2 * ${groups[0]?.output ?? '0'})`,
453
+
454
+ // CSS @function — `$$` key, object value
455
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
456
+ $$shadow: {
457
+ args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
458
+ returns: '<color>',
459
+ $offset: '2px',
460
+ result: '$offset $offset ($shadow-color, black)',
461
+ },
462
+ },
463
+ });
464
+ ```
465
+
466
+ Components then invoke parse functions as `double(...)` and CSS functions with the `$$name(...)` sugar, e.g. `margin: '$$negative(10px) top'`.
467
+
468
+ > A key whose prefix doesn't match its value type (an object under a bare key, or a function under a `$$` key) is **ignored with a dev-mode warning**.
469
+
470
+ See [Functions (`@function`)](dsl.md#functions-function) for inline usage inside component styles, the full descriptor shape, and token conventions. `@function` is an experimental CSS feature — unsupported browsers safely ignore the native rule (see the polyfill below).
471
+
472
+ ### Custom color functions
473
+
474
+ A parse function whose output is an already-supported color (`rgb`, `hsl`, `#…`, `oklch`, …) is treated as a **color function**: it works everywhere a color is accepted — style values, `#token.alpha` opacity injection, and `parseColor` — with no extra registration. This is the same mechanism the built-in `okhsl`/`okhst` plugins use; they are ordinary plugins registered by default.
475
+
476
+ ```ts
477
+ import { configure, createColorFunc } from '@tenphi/tasty';
478
+
479
+ // A custom color space is just a `functions` entry.
480
+ const myColorPlugin = () => ({
481
+ name: 'mycolor',
482
+ functions: {
483
+ // Hand-written parse function:
484
+ mycolor: (groups) => {
485
+ const [r, g, b] = groups[0].all;
486
+ return `rgb(${r} ${g} ${b})`;
487
+ },
488
+ },
489
+ });
490
+
491
+ configure({ plugins: [myColorPlugin()] });
492
+
493
+ // Now `mycolor(...)` is a color in every context:
494
+ // fill: 'mycolor(255 0 0)'
495
+ // fill: '#brand.5' (with replaceTokens: { '#brand': 'mycolor(255 0 0)' })
496
+ ```
497
+
498
+ For HSL-style color spaces (a hue angle plus two percentages), the exported `createColorFunc(name, convert, label?)` helper handles angle/percentage parsing, clamping, alpha, and caching. `convert` returns sRGB `[r, g, b]` in 0-1; `label` is an optional string used only in dev warnings (e.g. `'H S L'`) and has no effect on output. This is exactly how `okhslPlugin`/`okhstPlugin` are implemented.
499
+
500
+ ---
501
+
502
+ ## Polyfills
503
+
504
+ `@function` only ships natively in Chromium 139+. To use CSS functions in browsers that don't support the at-rule yet (Firefox, Safari), enable the **functions polyfill**, which expands every `$$name(...)` call into plain CSS (`calc()`/`var()`/`color-mix()`) at parse time instead of emitting the native `@function` rule:
505
+
506
+ ```ts
507
+ configure({
508
+ polyfills: {
509
+ functions: true, // default: false
510
+ },
511
+ functions: {
512
+ $$negative: { args: ['$value'], result: '(-1 * $value)' },
513
+ },
514
+ });
515
+
516
+ // Now `margin: '$$negative(10px) top'` renders `margin: calc(-1 * 10px) 0 0 0`
517
+ // — no native @function rule is emitted.
518
+ ```
519
+
520
+ This works across all rendering modes (client, SSR/RSC, and `tastyStatic`) because expansion happens in the parser. Note `polyfills.functions` (the feature toggle) is distinct from the top-level `functions` (the definitions map).
521
+
522
+ **Decided limitations when the polyfill is on:**
523
+
524
+ - **No native fallback** — functions are always inlined; we do exactly what is configured.
525
+ - **Conditional results** (`@media`/`@supports`/`if()` inside `result`) are inlined verbatim; the conditional nuance is not resolved per-element.
526
+ - **Typed params / `returns`** are dropped (inlining is purely lexical substitution).
527
+ - **Param name collisions** are avoided by fully inlining argument values (no function-internal custom properties are emitted) and by namespacing the function's own variables.
528
+ - **Recursion** — self/mutually-recursive functions are not expanded; the cycle guard bails and leaves the call untouched.
79
529
 
80
530
  ---
81
531
 
@@ -99,9 +549,91 @@ configure({
99
549
  });
100
550
  ```
101
551
 
102
- Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@properties`. Recipes cannot reference other recipes.
552
+ Recipe values are flat tasty styles (no sub-element keys). They may contain base styles, tokens, local states, `@keyframes`, and `@property`.
553
+
554
+ **Recipes cannot reference other recipes.** A `recipe` key inside a configured recipe's value is not recursively resolved:
555
+
556
+ ```jsx
557
+ // Unsupported: applying 'elevatedCard' does not expand 'card elevated'.
558
+ configure({
559
+ recipes: {
560
+ elevatedCard: {
561
+ recipe: 'card elevated',
562
+ padding: '6x',
563
+ },
564
+ },
565
+ });
566
+ ```
567
+
568
+ Instead, compose the names where you apply the styles: `styles: { recipe: 'card elevated', padding: '6x' }`. Recipe references are resolved on the component root and independently inside each sub-element's styles (for example, `styles: { Panel: { recipe: 'card elevated' } }`). This sub-element support does not allow one recipe definition to inherit another. Tasty warns in development when a recipe definition contains a `recipe` key.
569
+
570
+ For how to apply, compose, and override recipes in components, see [Recipes](dsl.md#recipes) in the Style DSL reference.
571
+
572
+ ---
573
+
574
+ ## Typography Presets
575
+
576
+ Typography presets are a shorthand for `generateTypographyTokens()`. Instead of calling the function manually and spreading the result into `tokens`, pass the presets directly:
577
+
578
+ ```jsx
579
+ configure({
580
+ presets: {
581
+ h1: { fontSize: '32px', lineHeight: '1.2', fontWeight: '700' },
582
+ t2: { fontSize: '16px', lineHeight: '1.5', fontWeight: '400' },
583
+ tag: {
584
+ fontSize: '10px',
585
+ lineHeight: '1.4',
586
+ letterSpacing: '0.04em',
587
+ fontWeight: '600',
588
+ },
589
+ },
590
+ });
591
+ ```
592
+
593
+ Each preset generates `$name-font-size`, `$name-line-height`, `$name-letter-spacing`, `$name-font-weight`, and optional `$name-bold-font-weight`, `$name-icon-size`, `$name-text-transform`, `$name-font-family`, `$name-font-style` tokens.
594
+
595
+ Preset values support state maps for responsive or theme-aware typography:
596
+
597
+ ```jsx
598
+ configure({
599
+ presets: {
600
+ t2: {
601
+ fontSize: '16px',
602
+ lineHeight: '1.5',
603
+ fontWeight: { '': '400', '@dark': '300' },
604
+ },
605
+ },
606
+ });
607
+ ```
608
+
609
+ The generated tokens are merged **under** explicit `tokens` — if both `presets` and `tokens` define `$t2-font-weight`, the `tokens` value wins. Plugins can also provide `presets`; plugin presets are merged first, then config presets, then explicit tokens on top.
610
+
611
+ ---
612
+
613
+ ## Global Styles
614
+
615
+ Apply Tasty styles to any selector via configuration, without needing `useGlobalStyles(selector, ...)` at runtime:
616
+
617
+ ```jsx
618
+ configure({
619
+ globalStyles: {
620
+ body: {
621
+ fill: '#surface',
622
+ color: '#text',
623
+ preset: 't2',
624
+ margin: 0,
625
+ font: 'system-ui, sans-serif',
626
+ },
627
+ html: {
628
+ overflow: 'hidden',
629
+ },
630
+ },
631
+ });
632
+ ```
103
633
 
104
- For how to apply, compose, and override recipes in components, see [Using Recipes](usage.md#recipes) in the usage guide.
634
+ Each key is a CSS selector, and each value is a Tasty `Styles` object supporting the full style syntax including style properties, tokens, state maps, and selector-based sub-styling (e.g. `$: '> .app'` for elements outside React scope). Global styles are injected alongside `:root` tokens when the first style is rendered.
635
+
636
+ Global styles are automatically emitted in all delivery modes: client rendering, server rendering, and build-time extraction with the Babel plugin. Plugins can also provide `globalStyles`; they are merged per selector with config global styles (config wins on conflict).
105
637
 
106
638
  ---
107
639
 
@@ -109,25 +641,25 @@ For how to apply, compose, and override recipes in components, see [Using Recipe
109
641
 
110
642
  CSS cannot transition or animate custom properties unless their type is declared via [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property). Tasty handles this automatically — when a custom property is assigned a concrete value (e.g. `'$scale': 1`, `'$gap': '10px'`, `'#accent': 'purple'`), the type is inferred and a `@property` rule is registered.
111
643
 
112
- This works across all declaration contexts: component styles, `@keyframes`, global config, and the zero-runtime Babel plugin. It also resolves `var()` chains — if `$a` references `var(--b)`, the type propagates once `--b` is resolved.
644
+ This works across all declaration contexts: component styles, `@keyframes`, global config, and build-time extraction with the Babel plugin. It also resolves `var()` chains — if `$a` references `var(--b)`, the type propagates once `--b` is resolved.
113
645
 
114
646
  Supported types:
115
647
 
116
- | Detection | Inferred syntax |
117
- |-----------|-----------------|
118
- | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
119
- | `10px`, `2rem`, `100vw` (length units) | `<length>` |
120
- | `50%` | `<percentage>` |
121
- | `45deg`, `0.5turn` (angle units) | `<angle>` |
122
- | `300ms`, `1s` (time units) | `<time>` |
123
- | `#name` tokens (by naming convention) | `<color>` |
648
+ | Detection | Inferred syntax |
649
+ | -------------------------------------- | --------------- |
650
+ | `1`, `0.5`, `-3` (bare numbers) | `<number>` |
651
+ | `10px`, `2rem`, `100vw` (length units) | `<length>` |
652
+ | `50%` | `<percentage>` |
653
+ | `45deg`, `0.5turn` (angle units) | `<angle>` |
654
+ | `300ms`, `1s` (time units) | `<time>` |
655
+ | `#name` tokens (by naming convention) | `<color>` |
124
656
 
125
- Auto-inferred properties use `inherits: true` (the CSS default). Use explicit `@properties` when you need different settings:
657
+ Auto-inferred properties use `inherits: true` (the CSS default). Use explicit `@property` when you need different settings:
126
658
 
127
659
  ```jsx
128
660
  // In component styles
129
661
  styles: {
130
- '@properties': {
662
+ '@property': {
131
663
  '$scale': { syntax: '<number>', inherits: false, initialValue: 1 },
132
664
  },
133
665
  }
@@ -140,7 +672,7 @@ configure({
140
672
  });
141
673
  ```
142
674
 
143
- To disable auto-inference entirely (only explicit `@properties` will be used):
675
+ To disable auto-inference entirely (only explicit `@property` will be used):
144
676
 
145
677
  ```jsx
146
678
  configure({ autoPropertyTypes: false });
@@ -152,27 +684,19 @@ configure({ autoPropertyTypes: false });
152
684
 
153
685
  Override or extend the built-in style property handlers. A handler definition can take three forms:
154
686
 
155
- | Form | Syntax | Description |
156
- |------|--------|-------------|
157
- | Function only | `handler` | Triggered by its key name; receives only that property |
158
- | Single dep | `['styleName', handler]` | Triggered by the specified style property |
159
- | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
687
+ | Form | Syntax | Description |
688
+ | ------------- | ---------------------------------- | --------------------------------------------------------------- |
689
+ | Function only | `handler` | Triggered by its key name; receives only that property |
690
+ | Single dep | `['styleName', handler]` | Triggered by the specified style property |
691
+ | Multi dep | `[['dep1', 'dep2', ...], handler]` | Triggered by any of the listed properties; receives all of them |
160
692
 
161
- The multi-dep form is useful when output depends on several style properties together (e.g., `gap` needs to know `display` and `flow` to decide the CSS strategy).
693
+ The multi-dep form is useful when output depends on several style properties together (e.g., `gap` needs to know `display` and `flow` to decide the CSS strategy). Use `defineHandler` for it and the dependency types are inferred from the dependency list, so a typo in the destructure is a type error instead of a silent `undefined`.
162
694
 
163
695
  ```jsx
164
- import { configure, styleHandlers } from '@tenphi/tasty';
696
+ import { configure, defineHandler, styleHandlers } from '@tenphi/tasty';
165
697
 
166
698
  configure({
167
699
  handlers: {
168
- // Function only — overrides built-in fill handler
169
- fill: ({ fill }) => {
170
- if (fill?.startsWith('gradient:')) {
171
- return { background: fill.slice(9) };
172
- }
173
- return styleHandlers.fill({ fill });
174
- },
175
-
176
700
  // Function only — new single-prop handler
177
701
  elevation: ({ elevation }) => {
178
702
  const level = parseInt(elevation) || 1;
@@ -182,16 +706,120 @@ configure({
182
706
  };
183
707
  },
184
708
 
709
+ // Overriding a built-in: declare every style the built-in handled and pass
710
+ // them all through, or the ones you leave out stop working (see below).
711
+ fill: defineHandler(
712
+ [
713
+ 'fill',
714
+ 'backgroundColor',
715
+ 'image',
716
+ 'backgroundImage',
717
+ 'backgroundPosition',
718
+ 'backgroundSize',
719
+ 'backgroundRepeat',
720
+ ],
721
+ (props) => {
722
+ if (
723
+ typeof props.fill === 'string' &&
724
+ props.fill.startsWith('gradient:')
725
+ ) {
726
+ return { background: props.fill.slice(9) };
727
+ }
728
+ return styleHandlers.fill(props);
729
+ },
730
+ ),
731
+
185
732
  // Multi dep — handler reads multiple style properties
186
- gap: [['display', 'flow', 'gap'], ({ display, flow, gap }) => {
733
+ gap: defineHandler(['display', 'flow', 'gap'], ({ display, flow, gap }) => {
187
734
  if (!gap) return;
188
- const isGrid = display?.includes('grid');
735
+ const isGrid = String(display ?? '').includes('grid');
189
736
  return { gap: isGrid ? gap : `/* custom logic for ${flow} */` };
190
- }],
737
+ }),
191
738
  },
192
739
  });
193
740
  ```
194
741
 
742
+ ### Return shape
743
+
744
+ A handler returns a `CSSMap`, an array of them, or nothing:
745
+
746
+ - Keys are **kebab-case** CSS property names (`'background-color'`, not `backgroundColor`) or `--custom-property` names. A camelCase key warns in development and is emitted verbatim, which the browser ignores.
747
+ - Values are stringified, so numbers are fine (`{ '-webkit-line-clamp': 3 }`).
748
+ - The reserved `$` key is a **selector suffix**: `{ $: '& > *:not(:last-child)', 'margin-right': gap }` applies the declarations to a nested selector. It accepts an array to fan out over several.
749
+ - Return an array of maps to emit several declaration sets, each with its own `$`.
750
+
751
+ Values arrive **state-resolved but unparsed** — the raw authored DSL string (`'2x'`, `'#purple.5'`, `true`, `4`). Call the exported `parseStyle()` / `parseColor()` yourself; nothing parses them for you.
752
+
753
+ ### Replacing a built-in handler
754
+
755
+ Built-in handlers are shared across several style names. Registering a handler for one of those names unregisters the built-in from **all** of them, and the displaced names then fall back to auto-generated CSS aliases — so `hide: true` starts emitting a literal `hide: true` declaration. A development-mode warning lists exactly what was displaced.
756
+
757
+ The shared groups worth knowing:
758
+
759
+ | Registering a handler for | Also takes over |
760
+ | ------------------------------ | --------------------------------------------------------------------------------------------------------- |
761
+ | `fill` | `backgroundColor`, `image`, `backgroundImage`, `backgroundPosition`, `backgroundSize`, `backgroundRepeat` |
762
+ | `display` | `hide`, `overflow`, `whiteSpace`, `textOverflow`, `flow`, `gap` |
763
+ | `preset` | `font`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform` |
764
+ | `padding` / `margin` / `inset` | their `*Top`/`*Right`/`*Bottom`/`*Left`/`*Block`/`*Inline` longhands |
765
+
766
+ Either declare the whole group and delegate the rest to `styleHandlers.*`, or pick a name that isn't shared.
767
+
768
+ ### Chunk membership
769
+
770
+ Tasty renders and caches CSS in independent chunks, and a chunk's cache key covers only its own style values. All of a handler's dependencies must therefore live in one chunk. Custom style names are pulled into their handler's chunk automatically at registration; a handler whose dependencies span two _built-in_ chunks (say `fill` and `padding`) warns, because it would be invoked once per chunk with a subset of its inputs.
771
+
772
+ `configure({ handlers })` must run before the first render, like every other config option.
773
+
774
+ ---
775
+
776
+ ## Props Middleware
777
+
778
+ `propHandlers` are middleware over a component's props — props in, props out. Where a style _handler_ turns a style property into CSS declarations, a prop handler turns a **component prop** into other props, including `styles`. It is the extension point for props whose value isn't a style value.
779
+
780
+ ```jsx
781
+ import { configure, mergeStyles } from '@tenphi/tasty';
782
+
783
+ configure({
784
+ propHandlers: {
785
+ glaze: (props) => {
786
+ const { glaze, ...rest } = props;
787
+ if (!glaze) return rest;
788
+
789
+ return { ...rest, styles: mergeStyles(glazeStyles(glaze), rest.styles) };
790
+ },
791
+ },
792
+ });
793
+
794
+ <Element glaze="purple" />;
795
+ ```
796
+
797
+ The map key is the handler's name and, by default, the prop that triggers it, so an absent prop costs one property check rather than a call. A tuple overrides that: `['glaze', fn]`, `[['glaze', 'tint'], fn]`, or `['*', fn]` for unconditional.
798
+
799
+ Handlers run at the very top of every component's render, before any prop is destructured, so one can rewrite `styles`, `mods`, `tokens`, `variant`, `as`, `element`, and `qa`. They run in registration order — plugins first, then direct config — each receiving the previous one's output.
800
+
801
+ Handlers must be **pure** and must not mutate their input, and should memoize the styles they build per input value: style values are cached by object identity, so mutating one in place yields stale CSS, and a reference-stable object avoids re-serializing on every render.
802
+
803
+ Injected styles occupy the `styles` slot, so they beat a component's own default styles and lose to a style prop at the call site. Prop handlers do not apply to sub-elements or to build-time `tastyStatic()`, which has no props.
804
+
805
+ See [Plugins → Props middleware](plugins.md#props-middleware) for the full contract and a worked example.
806
+
807
+ ---
808
+
809
+ ## Base Style Props
810
+
811
+ `baseStyleProps` exposes style properties as props on **every** `tasty()` component, on top of the built-in base styles (`display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, `transition`):
812
+
813
+ ```jsx
814
+ configure({ baseStyleProps: ['radius', 'shadow'] });
815
+
816
+ <Card radius="1r" shadow />;
817
+ ```
818
+
819
+ `configure()` may run after your components are defined — each factory resolves its prop list lazily.
820
+
821
+ Each name costs one property check per render of every component, and the effect is app-global, so keep the list short and use a factory's own `styleProps` for anything narrower. Avoid names that collide with real DOM or component props (`width`, `size`, `color`), since every component will then swallow them as styles.
822
+
195
823
  ---
196
824
 
197
825
  ## Extending Style Types (TypeScript)
@@ -208,4 +836,4 @@ declare module '@tenphi/tasty' {
208
836
  }
209
837
  ```
210
838
 
211
- See [Usage Guide](usage.md) for component creation, state mappings, sub-elements, variants, and hooks.
839
+ See [Style DSL](dsl.md) for state maps, tokens, units, and extending semantics, and [React API](react-api.md) for `tasty()`, style functions, and component props.