@tenphi/tasty 0.0.0-snapshot.fa94a5a → 0.0.0-snapshot.fc19da9

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 (372) hide show
  1. package/README.md +437 -362
  2. package/dist/babel-types-DpUCD2L_.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/chunks/collector-DqcB0UUT.js +210 -0
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  14. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/{debug.js → chunks/debug-BzYPQ0H2.js} +197 -149
  18. package/dist/chunks/debug-BzYPQ0H2.js.map +1 -0
  19. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  20. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B2e-Wha-.js +689 -0
  24. package/dist/chunks/react-runtime-B2e-Wha-.js.map +1 -0
  25. package/dist/chunks/runtime-engine-yeyCAx2e.js +2431 -0
  26. package/dist/chunks/runtime-engine-yeyCAx2e.js.map +1 -0
  27. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  28. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  32. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  33. package/dist/chunks/zero-engine-DpkieEPZ.js +310 -0
  34. package/dist/chunks/zero-engine-DpkieEPZ.js.map +1 -0
  35. package/dist/collector-D4POJ53X.d.ts +164 -0
  36. package/dist/config-DvPUj4cw.d.ts +1364 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DC4q-xDq.d.ts +1946 -0
  41. package/dist/index.d.ts +5 -51
  42. package/dist/index.js +11 -36
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +110 -12
  60. package/dist/ssr/astro.js +206 -50
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -5
  65. package/dist/ssr/index.js +7 -9
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -12
  71. package/dist/ssr/next.js +40 -51
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-ZbF2_6LV.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +20 -120
  81. package/dist/zero/babel.js +189 -148
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +117 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +16 -5
  87. package/dist/zero/next.js +8 -42
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +23 -12
  90. package/docs/adoption.md +72 -37
  91. package/docs/ai-agents.md +252 -0
  92. package/docs/comparison.md +83 -54
  93. package/docs/configuration.md +698 -81
  94. package/docs/debug.md +39 -24
  95. package/docs/design-system.md +174 -41
  96. package/docs/dsl.md +615 -197
  97. package/docs/getting-started.md +132 -52
  98. package/docs/injector.md +195 -90
  99. package/docs/methodology.md +153 -47
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +703 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +395 -149
  106. package/docs/styles.md +194 -45
  107. package/docs/tasty-static.md +327 -101
  108. package/package.json +153 -35
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -78
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -259
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -60
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -366
  119. package/dist/config.js +0 -504
  120. package/dist/config.js.map +0 -1
  121. package/dist/counter-style/index.js +0 -51
  122. package/dist/counter-style/index.js.map +0 -1
  123. package/dist/debug.d.ts +0 -89
  124. package/dist/debug.js.map +0 -1
  125. package/dist/font-face/index.js +0 -63
  126. package/dist/font-face/index.js.map +0 -1
  127. package/dist/hooks/resolve-ssr-collector.js +0 -15
  128. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  129. package/dist/hooks/useCounterStyle.d.ts +0 -50
  130. package/dist/hooks/useCounterStyle.js +0 -47
  131. package/dist/hooks/useCounterStyle.js.map +0 -1
  132. package/dist/hooks/useFontFace.d.ts +0 -43
  133. package/dist/hooks/useFontFace.js +0 -71
  134. package/dist/hooks/useFontFace.js.map +0 -1
  135. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  136. package/dist/hooks/useGlobalStyles.js +0 -79
  137. package/dist/hooks/useGlobalStyles.js.map +0 -1
  138. package/dist/hooks/useKeyframes.d.ts +0 -56
  139. package/dist/hooks/useKeyframes.js +0 -65
  140. package/dist/hooks/useKeyframes.js.map +0 -1
  141. package/dist/hooks/useProperty.d.ts +0 -79
  142. package/dist/hooks/useProperty.js +0 -110
  143. package/dist/hooks/useProperty.js.map +0 -1
  144. package/dist/hooks/useRawCSS.d.ts +0 -53
  145. package/dist/hooks/useRawCSS.js +0 -36
  146. package/dist/hooks/useRawCSS.js.map +0 -1
  147. package/dist/hooks/useStyles.d.ts +0 -45
  148. package/dist/hooks/useStyles.js +0 -270
  149. package/dist/hooks/useStyles.js.map +0 -1
  150. package/dist/injector/index.d.ts +0 -183
  151. package/dist/injector/index.js +0 -180
  152. package/dist/injector/index.js.map +0 -1
  153. package/dist/injector/injector.d.ts +0 -166
  154. package/dist/injector/injector.js +0 -465
  155. package/dist/injector/injector.js.map +0 -1
  156. package/dist/injector/sheet-manager.d.ts +0 -136
  157. package/dist/injector/sheet-manager.js +0 -731
  158. package/dist/injector/sheet-manager.js.map +0 -1
  159. package/dist/injector/types.d.ts +0 -204
  160. package/dist/keyframes/index.js +0 -206
  161. package/dist/keyframes/index.js.map +0 -1
  162. package/dist/parser/classify.js +0 -320
  163. package/dist/parser/classify.js.map +0 -1
  164. package/dist/parser/const.js +0 -33
  165. package/dist/parser/const.js.map +0 -1
  166. package/dist/parser/lru.js +0 -109
  167. package/dist/parser/lru.js.map +0 -1
  168. package/dist/parser/parser.d.ts +0 -25
  169. package/dist/parser/parser.js +0 -116
  170. package/dist/parser/parser.js.map +0 -1
  171. package/dist/parser/tokenizer.js +0 -69
  172. package/dist/parser/tokenizer.js.map +0 -1
  173. package/dist/parser/types.d.ts +0 -51
  174. package/dist/parser/types.js +0 -46
  175. package/dist/parser/types.js.map +0 -1
  176. package/dist/pipeline/conditions.d.ts +0 -134
  177. package/dist/pipeline/conditions.js +0 -406
  178. package/dist/pipeline/conditions.js.map +0 -1
  179. package/dist/pipeline/exclusive.js +0 -231
  180. package/dist/pipeline/exclusive.js.map +0 -1
  181. package/dist/pipeline/index.d.ts +0 -53
  182. package/dist/pipeline/index.js +0 -699
  183. package/dist/pipeline/index.js.map +0 -1
  184. package/dist/pipeline/materialize.js +0 -1105
  185. package/dist/pipeline/materialize.js.map +0 -1
  186. package/dist/pipeline/parseStateKey.d.ts +0 -15
  187. package/dist/pipeline/parseStateKey.js +0 -447
  188. package/dist/pipeline/parseStateKey.js.map +0 -1
  189. package/dist/pipeline/simplify.js +0 -516
  190. package/dist/pipeline/simplify.js.map +0 -1
  191. package/dist/pipeline/warnings.js +0 -18
  192. package/dist/pipeline/warnings.js.map +0 -1
  193. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  194. package/dist/plugins/okhsl-plugin.js +0 -98
  195. package/dist/plugins/okhsl-plugin.js.map +0 -1
  196. package/dist/plugins/types.d.ts +0 -76
  197. package/dist/properties/index.js +0 -223
  198. package/dist/properties/index.js.map +0 -1
  199. package/dist/properties/property-type-resolver.d.ts +0 -24
  200. package/dist/properties/property-type-resolver.js +0 -91
  201. package/dist/properties/property-type-resolver.js.map +0 -1
  202. package/dist/ssr/async-storage.d.ts +0 -17
  203. package/dist/ssr/async-storage.js +0 -35
  204. package/dist/ssr/async-storage.js.map +0 -1
  205. package/dist/ssr/collect-auto-properties.js +0 -40
  206. package/dist/ssr/collect-auto-properties.js.map +0 -1
  207. package/dist/ssr/collector.d.ts +0 -102
  208. package/dist/ssr/collector.js +0 -227
  209. package/dist/ssr/collector.js.map +0 -1
  210. package/dist/ssr/context.d.ts +0 -8
  211. package/dist/ssr/context.js +0 -14
  212. package/dist/ssr/context.js.map +0 -1
  213. package/dist/ssr/format-global-rules.js +0 -22
  214. package/dist/ssr/format-global-rules.js.map +0 -1
  215. package/dist/ssr/format-keyframes.js +0 -70
  216. package/dist/ssr/format-keyframes.js.map +0 -1
  217. package/dist/ssr/format-property.js +0 -50
  218. package/dist/ssr/format-property.js.map +0 -1
  219. package/dist/ssr/format-rules.js +0 -70
  220. package/dist/ssr/format-rules.js.map +0 -1
  221. package/dist/ssr/hydrate.d.ts +0 -22
  222. package/dist/ssr/hydrate.js +0 -50
  223. package/dist/ssr/hydrate.js.map +0 -1
  224. package/dist/ssr/ssr-collector-ref.js +0 -12
  225. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  226. package/dist/states/index.d.ts +0 -49
  227. package/dist/states/index.js +0 -171
  228. package/dist/states/index.js.map +0 -1
  229. package/dist/static/tastyStatic.d.ts +0 -46
  230. package/dist/static/tastyStatic.js +0 -31
  231. package/dist/static/tastyStatic.js.map +0 -1
  232. package/dist/static/types.d.ts +0 -49
  233. package/dist/static/types.js +0 -24
  234. package/dist/static/types.js.map +0 -1
  235. package/dist/styles/align.d.ts +0 -15
  236. package/dist/styles/align.js +0 -14
  237. package/dist/styles/align.js.map +0 -1
  238. package/dist/styles/border.d.ts +0 -25
  239. package/dist/styles/border.js +0 -114
  240. package/dist/styles/border.js.map +0 -1
  241. package/dist/styles/color.d.ts +0 -14
  242. package/dist/styles/color.js +0 -27
  243. package/dist/styles/color.js.map +0 -1
  244. package/dist/styles/createStyle.js +0 -80
  245. package/dist/styles/createStyle.js.map +0 -1
  246. package/dist/styles/dimension.js +0 -97
  247. package/dist/styles/dimension.js.map +0 -1
  248. package/dist/styles/display.d.ts +0 -37
  249. package/dist/styles/display.js +0 -67
  250. package/dist/styles/display.js.map +0 -1
  251. package/dist/styles/fade.d.ts +0 -15
  252. package/dist/styles/fade.js +0 -58
  253. package/dist/styles/fade.js.map +0 -1
  254. package/dist/styles/fill.d.ts +0 -42
  255. package/dist/styles/fill.js +0 -52
  256. package/dist/styles/fill.js.map +0 -1
  257. package/dist/styles/flow.d.ts +0 -16
  258. package/dist/styles/flow.js +0 -12
  259. package/dist/styles/flow.js.map +0 -1
  260. package/dist/styles/gap.d.ts +0 -31
  261. package/dist/styles/gap.js +0 -37
  262. package/dist/styles/gap.js.map +0 -1
  263. package/dist/styles/height.d.ts +0 -17
  264. package/dist/styles/height.js +0 -20
  265. package/dist/styles/height.js.map +0 -1
  266. package/dist/styles/index.d.ts +0 -2
  267. package/dist/styles/index.js +0 -9
  268. package/dist/styles/index.js.map +0 -1
  269. package/dist/styles/inset.d.ts +0 -52
  270. package/dist/styles/inset.js +0 -150
  271. package/dist/styles/inset.js.map +0 -1
  272. package/dist/styles/justify.d.ts +0 -15
  273. package/dist/styles/justify.js +0 -14
  274. package/dist/styles/justify.js.map +0 -1
  275. package/dist/styles/list.d.ts +0 -16
  276. package/dist/styles/list.js +0 -98
  277. package/dist/styles/list.js.map +0 -1
  278. package/dist/styles/margin.d.ts +0 -24
  279. package/dist/styles/margin.js +0 -104
  280. package/dist/styles/margin.js.map +0 -1
  281. package/dist/styles/outline.d.ts +0 -29
  282. package/dist/styles/outline.js +0 -65
  283. package/dist/styles/outline.js.map +0 -1
  284. package/dist/styles/padding.d.ts +0 -24
  285. package/dist/styles/padding.js +0 -104
  286. package/dist/styles/padding.js.map +0 -1
  287. package/dist/styles/predefined.d.ts +0 -71
  288. package/dist/styles/predefined.js +0 -238
  289. package/dist/styles/predefined.js.map +0 -1
  290. package/dist/styles/preset.d.ts +0 -47
  291. package/dist/styles/preset.js +0 -112
  292. package/dist/styles/preset.js.map +0 -1
  293. package/dist/styles/radius.d.ts +0 -14
  294. package/dist/styles/radius.js +0 -51
  295. package/dist/styles/radius.js.map +0 -1
  296. package/dist/styles/scrollbar.d.ts +0 -25
  297. package/dist/styles/scrollbar.js +0 -48
  298. package/dist/styles/scrollbar.js.map +0 -1
  299. package/dist/styles/shadow.d.ts +0 -14
  300. package/dist/styles/shadow.js +0 -24
  301. package/dist/styles/shadow.js.map +0 -1
  302. package/dist/styles/transition.d.ts +0 -14
  303. package/dist/styles/transition.js +0 -158
  304. package/dist/styles/transition.js.map +0 -1
  305. package/dist/styles/types.d.ts +0 -545
  306. package/dist/styles/width.d.ts +0 -17
  307. package/dist/styles/width.js +0 -20
  308. package/dist/styles/width.js.map +0 -1
  309. package/dist/tasty.d.ts +0 -119
  310. package/dist/tasty.js +0 -232
  311. package/dist/tasty.js.map +0 -1
  312. package/dist/types.d.ts +0 -184
  313. package/dist/utils/cache-wrapper.js +0 -22
  314. package/dist/utils/cache-wrapper.js.map +0 -1
  315. package/dist/utils/case-converter.js +0 -8
  316. package/dist/utils/case-converter.js.map +0 -1
  317. package/dist/utils/color-math.d.ts +0 -46
  318. package/dist/utils/color-math.js +0 -749
  319. package/dist/utils/color-math.js.map +0 -1
  320. package/dist/utils/color-space.d.ts +0 -5
  321. package/dist/utils/color-space.js +0 -229
  322. package/dist/utils/color-space.js.map +0 -1
  323. package/dist/utils/colors.d.ts +0 -5
  324. package/dist/utils/colors.js +0 -11
  325. package/dist/utils/colors.js.map +0 -1
  326. package/dist/utils/css-types.d.ts +0 -7
  327. package/dist/utils/dotize.d.ts +0 -26
  328. package/dist/utils/dotize.js +0 -122
  329. package/dist/utils/dotize.js.map +0 -1
  330. package/dist/utils/filter-base-props.d.ts +0 -15
  331. package/dist/utils/filter-base-props.js +0 -45
  332. package/dist/utils/filter-base-props.js.map +0 -1
  333. package/dist/utils/get-display-name.d.ts +0 -7
  334. package/dist/utils/get-display-name.js +0 -10
  335. package/dist/utils/get-display-name.js.map +0 -1
  336. package/dist/utils/has-keys.js +0 -13
  337. package/dist/utils/has-keys.js.map +0 -1
  338. package/dist/utils/is-dev-env.js +0 -19
  339. package/dist/utils/is-dev-env.js.map +0 -1
  340. package/dist/utils/is-valid-element-type.js +0 -15
  341. package/dist/utils/is-valid-element-type.js.map +0 -1
  342. package/dist/utils/merge-styles.js.map +0 -1
  343. package/dist/utils/mod-attrs.d.ts +0 -8
  344. package/dist/utils/mod-attrs.js +0 -21
  345. package/dist/utils/mod-attrs.js.map +0 -1
  346. package/dist/utils/process-tokens.d.ts +0 -21
  347. package/dist/utils/process-tokens.js +0 -91
  348. package/dist/utils/process-tokens.js.map +0 -1
  349. package/dist/utils/resolve-recipes.d.ts +0 -17
  350. package/dist/utils/resolve-recipes.js +0 -147
  351. package/dist/utils/resolve-recipes.js.map +0 -1
  352. package/dist/utils/selector-transform.js +0 -32
  353. package/dist/utils/selector-transform.js.map +0 -1
  354. package/dist/utils/string.js +0 -8
  355. package/dist/utils/string.js.map +0 -1
  356. package/dist/utils/styles.d.ts +0 -101
  357. package/dist/utils/styles.js +0 -223
  358. package/dist/utils/styles.js.map +0 -1
  359. package/dist/utils/typography.d.ts +0 -47
  360. package/dist/utils/typography.js +0 -43
  361. package/dist/utils/typography.js.map +0 -1
  362. package/dist/utils/warnings.d.ts +0 -16
  363. package/dist/utils/warnings.js +0 -16
  364. package/dist/utils/warnings.js.map +0 -1
  365. package/dist/zero/css-writer.d.ts +0 -45
  366. package/dist/zero/css-writer.js +0 -74
  367. package/dist/zero/css-writer.js.map +0 -1
  368. package/dist/zero/extractor.d.ts +0 -24
  369. package/dist/zero/extractor.js +0 -267
  370. package/dist/zero/extractor.js.map +0 -1
  371. package/docs/PIPELINE.md +0 -519
  372. package/docs/runtime.md +0 -485
@@ -0,0 +1,703 @@
1
+ # React API
2
+
3
+ Use `tasty()` to turn state-aware style definitions into normal React components, extend existing Tasty components, and expose typed styling APIs to consumers.
4
+
5
+ Every Tasty style function except `useStyles()` — `tasty()` components, `computeStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, `useCounterStyle()`, and `useFunction()` — is hook-free and works in React Server Components with no `'use client'` directive. `useStyles()` reads the `TastyRegistry` collector from React context, so it is a real hook; in Server Components and outside React, call `computeStyles()` instead. For state maps, tokens, units, and extension semantics, see [Style DSL](dsl.md). For global configuration, see [Configuration](configuration.md). For the broader docs map, see the [Docs Hub](README.md).
6
+
7
+ > **Note:** This file was previously named `runtime.md`. All functionality documented here works in both server and client contexts — "runtime" referred to style computation during React rendering, not to client-side JavaScript.
8
+
9
+ ---
10
+
11
+ ## Component Creation
12
+
13
+ ### Create a new component
14
+
15
+ ```jsx
16
+ import { tasty } from '@tenphi/tasty';
17
+
18
+ const Card = tasty({
19
+ as: 'div',
20
+ styles: {
21
+ padding: '4x',
22
+ fill: '#white',
23
+ border: true,
24
+ radius: true,
25
+ },
26
+ styleProps: ['padding', 'fill'],
27
+ });
28
+
29
+ <Card>Hello World</Card>
30
+ <Card padding="6x" fill="#gray.05">Custom Card</Card>
31
+ ```
32
+
33
+ ### Extend an existing component
34
+
35
+ ```jsx
36
+ const PrimaryButton = tasty(Button, {
37
+ styles: {
38
+ fill: '#purple',
39
+ color: '#white',
40
+ padding: '2x 4x',
41
+ },
42
+ });
43
+ ```
44
+
45
+ Style maps merge intelligently — see [Style DSL — Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps) for extend mode, replace mode, `@inherit`, `null`, and `false` tombstones.
46
+
47
+ The extension form forwards props; it does not re-run the factory. `styleProps`, `modProps`, `tokenProps`, `variants`, and `elements` passed to `tasty(Component, …)` are ignored even though they type-check, and the base's sub-components are not copied (`tasty(Card, …).Title` is `undefined`). Declare them on the base component, or create the component with `tasty({ … })` directly.
48
+
49
+ `tasty(Component, ...)` always wraps `Component` and forwards every prop to it, so `Component` must be Tasty-aware (i.e. it accepts `styles`, `mods`, `qa`, etc. and renders them through its own Tasty pipeline). To apply styles to a third-party component or a string DOM tag via `className`, use the options-only form with `as`:
50
+
51
+ ```jsx
52
+ import NextLink from 'next/link';
53
+
54
+ const Link = tasty({
55
+ as: NextLink,
56
+ styles: {
57
+ color: { '': '#accent-text', ':hover': '#text' },
58
+ textDecoration: 'underline',
59
+ },
60
+ styleProps: ['padding'],
61
+ });
62
+
63
+ const Span = tasty({
64
+ as: 'span',
65
+ styles: { preset: 'strong' },
66
+ });
67
+
68
+ <Link href="/blog" padding="1x">
69
+ Blog
70
+ </Link>;
71
+ ```
72
+
73
+ The wrapped component only needs to forward `className` (and ideally `style`/`ref`). Tasty's own props (`styles`, `mods`, `tokens`, `qa`, `qaVal`, `theme`, `element`, the `is*` props) and the props you declared with `styleProps`, `modProps`, or `tokenProps` are consumed by Tasty; mods, `qa`, `qaVal`, `theme`, and `element` reach the DOM only as `data-*` attributes.
74
+
75
+ Props forwarded to the `as` component keep their declared types and requiredness. For example, a component with `position: 'top-right' | 'bottom-left'` accepts those values through `tasty({ as: Component })`; CSS positioning can still be set through `styles.position`. A prop explicitly listed in `styleProps` is consumed as a style value instead. The always-available base style props below are also consumed by Tasty, so keep component-specific prop names separate from those reserved names.
76
+
77
+ ---
78
+
79
+ ## Style Props
80
+
81
+ Use `styleProps` to expose style properties as direct component props:
82
+
83
+ ```jsx
84
+ const FlexibleBox = tasty({
85
+ as: 'div',
86
+ styles: {
87
+ display: 'flex',
88
+ padding: '2x',
89
+ },
90
+ styleProps: ['gap', 'align', 'placeContent', 'fill'],
91
+ });
92
+
93
+ <FlexibleBox gap="2x" align="center" fill="#surface">
94
+ Content
95
+ </FlexibleBox>;
96
+ ```
97
+
98
+ Style props accept state maps, so responsive values work through the same API:
99
+
100
+ ```jsx
101
+ <FlexibleBox
102
+ gap={{ '': '2x', '@tablet': '4x' }}
103
+ fill={{ '': '#surface', '@dark': '#surface-dark' }}
104
+ >
105
+ ```
106
+
107
+ For predefined style prop lists (`FLOW_STYLES`, `POSITION_STYLES`, `DIMENSION_STYLES`, etc.) and guidance on which props to expose per component category, see [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api).
108
+
109
+ ### Always-available style props
110
+
111
+ A small set of style properties — `display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, and `transition` — are always harvested as style props on every `tasty()` component, even when `styleProps` is omitted. This means you can pass `<Card display="grid" />` or `<Text preset="h1" />` without declaring them. When you do declare `styleProps`, these base props are unioned with your list (not replaced).
112
+
113
+ ---
114
+
115
+ ## `Element`
116
+
117
+ `Element` is the unstyled base component exported from the main entry — equivalent to `tasty({})` (a `div` with no default styles). It accepts the props every Tasty component has (`as`, `styles`, `mods`, `tokens`, `qa`, `theme`, the `is*` props) plus the [always-available style props](#always-available-style-props), and is useful as a generic box or as a building block for layout primitives. Other style names, such as `padding`, are not props on it: create a component with `styleProps` for those, or pass them through `styles`.
118
+
119
+ ```jsx
120
+ import { Element } from '@tenphi/tasty';
121
+
122
+ <Element as="section" display="grid" preset="t2" styles={{ padding: '4x' }}>
123
+ Content
124
+ </Element>;
125
+ ```
126
+
127
+ > Note: `Element` shadows the global DOM `Element` type when imported from `@tenphi/tasty`. In files that need the DOM type, alias the import: `import { Element as TastyElement } from '@tenphi/tasty'`.
128
+
129
+ ---
130
+
131
+ ## Mod Props
132
+
133
+ Use `modProps` to expose modifier keys as direct component props instead of requiring the `mods` object:
134
+
135
+ ```jsx
136
+ // Before: mods object
137
+ <Button mods={{ isLoading: true, size: 'large' }}>Submit</Button>
138
+
139
+ // After: mod props
140
+ <Button isLoading size="large">Submit</Button>
141
+ ```
142
+
143
+ ### Array form
144
+
145
+ List modifier key names. Types default to `ModValue` (`boolean | string | number | undefined | null`):
146
+
147
+ ```jsx
148
+ const Button = tasty({
149
+ as: 'button',
150
+ modProps: ['isLoading', 'isSelected'] as const,
151
+ styles: {
152
+ fill: { '': '#surface', isLoading: '#surface.5' },
153
+ border: { '': '1bw solid #outline', isSelected: '2bw solid #primary' },
154
+ },
155
+ });
156
+
157
+ <Button isLoading isSelected>Submit</Button>
158
+ // Renders: <button data-is-loading="" data-is-selected="">Submit</button>
159
+ ```
160
+
161
+ ### Object form (typed)
162
+
163
+ Map modifier names to type descriptors for precise TypeScript types:
164
+
165
+ ```tsx
166
+ const Button = tasty({
167
+ as: 'button',
168
+ modProps: {
169
+ isLoading: Boolean, // isLoading?: boolean
170
+ isSelected: Boolean, // isSelected?: boolean
171
+ size: ['small', 'medium', 'large'] as const, // size?: 'small' | 'medium' | 'large'
172
+ },
173
+ styles: {
174
+ padding: { '': '2x 4x', 'size=small': '1x 2x', 'size=large': '3x 6x' },
175
+ fill: { '': '#surface', isLoading: '#surface.5' },
176
+ },
177
+ });
178
+
179
+ <Button isLoading size="large">
180
+ Submit
181
+ </Button>;
182
+ // Renders: <button data-is-loading="" data-size="large">Submit</button>
183
+ ```
184
+
185
+ Available type descriptors:
186
+
187
+ | Descriptor | TypeScript type | Example |
188
+ | --------------------- | --------------- | ----------------------------------- |
189
+ | `Boolean` | `boolean` | `isLoading: Boolean` |
190
+ | `String` | `string` | `label: String` |
191
+ | `Number` | `number` | `count: Number` |
192
+ | `['a', 'b'] as const` | `'a' \| 'b'` | `size: ['sm', 'md', 'lg'] as const` |
193
+
194
+ ### Merge with `mods`
195
+
196
+ Mod props and the `mods` object can be used together. Mod props take precedence:
197
+
198
+ ```jsx
199
+ <Button mods={{ isLoading: false, extra: true }} isLoading>
200
+ // isLoading=true wins (from mod prop), extra=true preserved from mods
201
+ ```
202
+
203
+ ### When to use `modProps` vs `mods`
204
+
205
+ | Use case | Recommendation |
206
+ | -------------------------------------------- | -------------------------------------------------------- |
207
+ | Component has a fixed set of known modifiers | `modProps` — cleaner API, better TypeScript autocomplete |
208
+ | Component needs arbitrary/dynamic modifiers | `mods` — open-ended `Record<string, ModValue>` |
209
+ | Both fixed and dynamic | Combine: `modProps` for known keys, `mods` for ad-hoc |
210
+
211
+ For architecture guidance on when to use modifiers vs `styleProps`, see [Methodology — modProps and mods](methodology.md#modprops-and-mods).
212
+
213
+ ---
214
+
215
+ ## Token Props
216
+
217
+ Use `tokenProps` to expose token keys as direct component props instead of requiring the `tokens` object:
218
+
219
+ ```jsx
220
+ // Before: tokens object
221
+ <ProgressBar tokens={{ $progress: '75%', '#accent': '#purple' }} />
222
+
223
+ // After: token props
224
+ <ProgressBar progress="75%" accentColor="#purple" />
225
+ ```
226
+
227
+ ### Array form
228
+
229
+ List prop names. Names ending in `Color` map to `#` color tokens; everything else maps to `$` custom property tokens:
230
+
231
+ ```jsx
232
+ const ProgressBar = tasty({
233
+ tokenProps: ['progress', 'accentColor'] as const,
234
+ styles: { width: '$progress', fill: '#accent' },
235
+ });
236
+
237
+ <ProgressBar progress="75%" accentColor="#purple" />
238
+ // 'progress' → $progress → --progress
239
+ // 'accentColor' → #accent → --accent-color
240
+ ```
241
+
242
+ ### Object form
243
+
244
+ Map prop names to explicit `$`/`#`-prefixed token keys:
245
+
246
+ ```tsx
247
+ const Card = tasty({
248
+ tokenProps: {
249
+ size: '$card-size',
250
+ color: '#card-accent',
251
+ },
252
+ styles: { padding: '$card-size', fill: '#card-accent' },
253
+ });
254
+
255
+ <Card size="4x" color="#purple" />;
256
+ ```
257
+
258
+ ### Merge with `tokens`
259
+
260
+ Token props and the `tokens` prop can be used together. Token props take precedence over `tokens`, which takes precedence over default `tokens` in `tasty({...})`:
261
+
262
+ ```jsx
263
+ const Bar = tasty({
264
+ tokenProps: ['progress'] as const,
265
+ tokens: { $progress: '0%' }, // default
266
+ });
267
+
268
+ <Bar tokens={{ $progress: '50%' }} progress="90%" />
269
+ // progress="90%" wins (from token prop)
270
+ ```
271
+
272
+ ### When to use `tokenProps` vs `tokens`
273
+
274
+ | Use case | Recommendation |
275
+ | ---------------------------------------------- | ---------------------------------------------------------- |
276
+ | Component has a fixed set of known token keys | `tokenProps` — cleaner API, better TypeScript autocomplete |
277
+ | Component needs arbitrary/dynamic token values | `tokens` — open-ended `Record<string, TokenValue>` |
278
+ | Both fixed and dynamic | Combine: `tokenProps` for known keys, `tokens` for ad-hoc |
279
+
280
+ For architecture guidance, see [Methodology — tokenProps](methodology.md#tokenprops).
281
+
282
+ ---
283
+
284
+ ## Variants
285
+
286
+ Define named style variations. Only CSS for variants actually used at runtime is injected:
287
+
288
+ ```jsx
289
+ const Button = tasty({
290
+ styles: {
291
+ padding: '2x 4x',
292
+ border: true,
293
+ },
294
+ variants: {
295
+ default: { fill: '#blue', color: '#white' },
296
+ danger: { fill: '#red', color: '#white' },
297
+ outline: { fill: '#clear', color: '#blue', border: '1bw solid #blue' },
298
+ },
299
+ });
300
+
301
+ <Button variant="danger">Delete</Button>;
302
+ ```
303
+
304
+ With `variant` omitted, or set to a key `variants` does not define, the `default` variant applies; without a `default` key only the base `styles` apply. `variant` is typed from the variant keys.
305
+
306
+ ### Extending Variants with Base State Maps
307
+
308
+ When base `styles` contain an extend-mode state map (an object **without** a `''` key), it is applied **after** the variant merge. This lets you add or override states across all variants without repeating yourself:
309
+
310
+ ```jsx
311
+ const Badge = tasty({
312
+ styles: {
313
+ padding: '1x 2x',
314
+ border: {
315
+ 'type=primary': '#clear',
316
+ },
317
+ },
318
+ variants: {
319
+ primary: {
320
+ border: { '': '#white.2', pressed: '#primary-text', disabled: '#clear' },
321
+ fill: { '': '#white #primary', hovered: '#white #primary-text' },
322
+ },
323
+ secondary: {
324
+ border: { '': '#primary.15', pressed: '#primary.3' },
325
+ fill: '#primary.10',
326
+ },
327
+ },
328
+ });
329
+
330
+ // Both variants get 'type=primary': '#clear' appended to their border map
331
+ ```
332
+
333
+ Properties that are **not** extend-mode (simple values, state maps with `''`, `null`, `false`, selectors, sub-elements) merge with variants as before — the variant can fully replace them.
334
+
335
+ ---
336
+
337
+ ## Sub-element Styling
338
+
339
+ Sub-elements are inner parts of a compound component, styled via capitalized keys in `styles` and identified by `data-element` attributes in the DOM.
340
+
341
+ > Use the `elements` prop to declare sub-element components. This gives you typed, reusable sub-components (`Card.Title`, `Card.Content`) instead of manually writing `data-element` attributes.
342
+
343
+ ```jsx
344
+ const Card = tasty({
345
+ styles: {
346
+ padding: '4x',
347
+ Title: { preset: 'h3', color: '#primary' },
348
+ Content: { color: '#text' },
349
+ },
350
+ elements: {
351
+ Title: 'h3',
352
+ Content: 'div',
353
+ },
354
+ });
355
+
356
+ <Card>
357
+ <Card.Title>Card Title</Card.Title>
358
+ <Card.Content>Card content</Card.Content>
359
+ </Card>;
360
+ ```
361
+
362
+ Each entry in `elements` can be a tag name string or a config object:
363
+
364
+ ```jsx
365
+ elements: {
366
+ Title: 'h3', // shorthand: tag name only
367
+ Icon: { as: 'span', qa: 'card-icon' }, // full form: tag + QA attribute
368
+ }
369
+ ```
370
+
371
+ The sub-components produced by `elements` support `mods`, `tokens`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component.
372
+
373
+ If you don't need sub-components (e.g., the inner elements are already rendered by a third-party library), you can still style them by key alone — just omit `elements` and apply `data-element` manually:
374
+
375
+ ```jsx
376
+ const Card = tasty({
377
+ styles: {
378
+ padding: '4x',
379
+ Title: { preset: 'h3', color: '#primary' },
380
+ },
381
+ });
382
+
383
+ <Card>
384
+ <div data-element="Title">Card Title</div>
385
+ </Card>;
386
+ ```
387
+
388
+ ### Selector Affix (`$`)
389
+
390
+ The `$` property inside a sub-element's styles controls how its selector attaches to the root selector — combinators, HTML tags, pseudo-elements, the `@` placeholder, and more. For the full reference table and injection rules, see [DSL — Selector Affix](dsl.md#selector-affix-).
391
+
392
+ For the mental model behind sub-elements — how they share root state context and how this differs from BEM — see [Methodology — Component architecture](methodology.md#component-architecture-root--sub-elements).
393
+
394
+ ---
395
+
396
+ ## computeStyles
397
+
398
+ Hook-free, synchronous style computation. Can be used anywhere — including React Server Components, plain functions, and non-React code:
399
+
400
+ ```tsx
401
+ import { computeStyles } from '@tenphi/tasty';
402
+
403
+ const { className } = computeStyles({
404
+ padding: '2x',
405
+ fill: '#surface',
406
+ radius: '1r',
407
+ });
408
+ ```
409
+
410
+ On the client, CSS is injected synchronously into the DOM (idempotent via the injector cache). On the server with an SSR collector (from `runWithCollector()` or `TastyRegistry`), the CSS goes to the collector. With neither a collector nor a `document` — a React Server Component — nothing is injected: the CSS comes back as `css`, and you render it in a `style` tag yourself, as `tasty()` components do. This is the same function that `tasty()` components use internally.
411
+
412
+ ---
413
+
414
+ ## Style Functions
415
+
416
+ All style functions below except `useStyles()` are plain functions, not React hooks, and work in client components, SSR with a `ServerStyleCollector`, and React Server Components. They keep the `use` prefix for backward compatibility.
417
+
418
+ In server-only contexts, components that use only Tasty style functions ship no Tasty styling runtime. Astro without `client:*` directives produces no client JavaScript; server-only Next.js RSC follows the same Tasty architecture, while final output depends on the application deployment. Tasty never forces the `'use client'` boundary — that decision belongs to your component when it needs React interactivity (state, effects, event handlers).
419
+
420
+ ### useStyles
421
+
422
+ Generate a className from a style object. A thin wrapper around `computeStyles()` that also picks up the `TastyRegistry` collector through React context. That makes it a hook: call it inside a component, and not in a Server Component — use `computeStyles()` there.
423
+
424
+ ```tsx
425
+ import { useStyles } from '@tenphi/tasty';
426
+
427
+ function MyComponent() {
428
+ const { className } = useStyles({
429
+ padding: '2x',
430
+ fill: '#surface',
431
+ radius: '1r',
432
+ });
433
+
434
+ return <div className={className}>Styled content</div>;
435
+ }
436
+ ```
437
+
438
+ ### useGlobalStyles
439
+
440
+ Inject global styles for a CSS selector. Accepts an optional third argument with an `id` for update tracking — when the styles change, the previous injection is disposed and the new one is injected:
441
+
442
+ ```tsx
443
+ import { useGlobalStyles } from '@tenphi/tasty';
444
+
445
+ function ThemeStyles() {
446
+ useGlobalStyles('.card', {
447
+ padding: '4x',
448
+ fill: '#surface',
449
+ radius: '1r',
450
+ });
451
+
452
+ return null;
453
+ }
454
+ ```
455
+
456
+ The selector can be a list (`'.uni-checkbox, uni-checkbox'`) — every item gets
457
+ the states and sub-elements, with no `:is()` wrapping needed. Root states
458
+ (`@root(...)`) on a selector that is the root itself (`:root`, `html`) apply to
459
+ that element. Local `@keyframes` are injected with the rules, under the same
460
+ resolved names `tasty()` components use, and `@starting` states emit
461
+ `@starting-style`.
462
+
463
+ A slot — the `id`, or the selector when no `id` is given — holds exactly one
464
+ injection **per `root`**. So:
465
+
466
+ - Changing the styles replaces the previous CSS rather than adding to it.
467
+ - Passing styles that produce no CSS (for example `{}`) clears the slot.
468
+ - The same selector used in two shadow roots keeps a separate injection in each.
469
+ - Two independent call sites that share a selector share a slot, and the last
470
+ render wins. Give them distinct `id`s if they should coexist.
471
+
472
+ ### useRawCSS
473
+
474
+ Inject raw CSS strings. Accepts an optional `id` in the options for update tracking — when the CSS changes for the same id, the previous injection is replaced:
475
+
476
+ ```tsx
477
+ import { useRawCSS } from '@tenphi/tasty';
478
+
479
+ function GlobalReset() {
480
+ useRawCSS(`
481
+ body { margin: 0; padding: 0; }
482
+ `);
483
+
484
+ return null;
485
+ }
486
+ ```
487
+
488
+ An `id` slot holds one injection per `root`. Without an `id` the CSS is deduped
489
+ by content and permanent — there is nothing to replace it with later.
490
+
491
+ It also accepts a factory and deps — `useRawCSS(() => css, [deps], { id })` — and skips the factory while the deps for that `id` are unchanged.
492
+
493
+ ### useKeyframes
494
+
495
+ Inject `@keyframes` rules and return the generated animation name:
496
+
497
+ ```tsx
498
+ import { useKeyframes } from '@tenphi/tasty';
499
+
500
+ function Spinner() {
501
+ const spin = useKeyframes(
502
+ {
503
+ from: { transform: 'rotate(0deg)' },
504
+ to: { transform: 'rotate(360deg)' },
505
+ },
506
+ { name: 'spin' },
507
+ );
508
+
509
+ return <div style={{ animation: `${spin} 1s linear infinite` }} />;
510
+ }
511
+ ```
512
+
513
+ `useKeyframes()` also supports a factory function. Without a `name` the factory runs on every invocation and deduplication is handled internally by content hash; with a `name`, matching deps skip the factory entirely:
514
+
515
+ ```tsx
516
+ function Pulse({ scale }: { scale: number }) {
517
+ const pulse = useKeyframes(
518
+ () => ({
519
+ '0%': { transform: 'scale(1)' },
520
+ '100%': { transform: `scale(${scale})` },
521
+ }),
522
+ [scale],
523
+ { name: 'pulse' },
524
+ );
525
+
526
+ return (
527
+ <div
528
+ style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }}
529
+ />
530
+ );
531
+ }
532
+ ```
533
+
534
+ Passing `name` claims a slot owned by that one call site, per `root` — much like
535
+ `id` in `useGlobalStyles()` and `useRawCSS()`. When the steps change the previous
536
+ `@keyframes` rule is disposed and the name is reused, so the rules don't
537
+ accumulate and the returned name stays stable. Anonymous keyframes are permanent
538
+ and shared by content.
539
+
540
+ ### useProperty
541
+
542
+ Register a CSS `@property` rule so a custom property can animate smoothly:
543
+
544
+ ```tsx
545
+ import { useProperty } from '@tenphi/tasty';
546
+
547
+ function Spinner() {
548
+ useProperty('$rotation', {
549
+ syntax: '<angle>',
550
+ inherits: false,
551
+ initialValue: '0deg',
552
+ });
553
+
554
+ return <div style={{ transform: 'rotate(var(--rotation))' }} />;
555
+ }
556
+ ```
557
+
558
+ `useProperty()` accepts Tasty token syntax for the property name:
559
+
560
+ - `$name` defines `--name`
561
+ - `#name` defines `--name-color` and auto-infers `<color>`
562
+ - `--name` is also supported for existing CSS variables
563
+
564
+ ### useFontFace
565
+
566
+ Inject `@font-face` rules for custom fonts. Permanent — no cleanup on unmount. Deduplicates by content.
567
+
568
+ ```tsx
569
+ import { useFontFace } from '@tenphi/tasty';
570
+
571
+ function App() {
572
+ useFontFace('Brand Sans', {
573
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
574
+ fontWeight: '400 700',
575
+ fontDisplay: 'swap',
576
+ });
577
+
578
+ return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
579
+ }
580
+ ```
581
+
582
+ For multiple weights/styles, pass an array:
583
+
584
+ ```tsx
585
+ useFontFace('Brand Sans', [
586
+ {
587
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
588
+ fontWeight: 400,
589
+ fontDisplay: 'swap',
590
+ },
591
+ {
592
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
593
+ fontWeight: 700,
594
+ fontDisplay: 'swap',
595
+ },
596
+ ]);
597
+ ```
598
+
599
+ Signature:
600
+
601
+ ```ts
602
+ function useFontFace(
603
+ family: string,
604
+ input: FontFaceInput,
605
+ options?: { root?: Document | ShadowRoot },
606
+ ): void;
607
+ ```
608
+
609
+ ### useCounterStyle
610
+
611
+ Inject a `@counter-style` rule and get back the counter style name. Permanent — no cleanup on unmount. Deduplicates by name.
612
+
613
+ ```tsx
614
+ import { useCounterStyle } from '@tenphi/tasty';
615
+
616
+ function EmojiList() {
617
+ const styleName = useCounterStyle(
618
+ {
619
+ system: 'cyclic',
620
+ symbols: '"👍"',
621
+ suffix: '" "',
622
+ },
623
+ { name: 'thumbs' },
624
+ );
625
+
626
+ return (
627
+ <ol style={{ listStyleType: styleName }}>
628
+ <li>First</li>
629
+ <li>Second</li>
630
+ </ol>
631
+ );
632
+ }
633
+ ```
634
+
635
+ Signature:
636
+
637
+ ```ts
638
+ function useCounterStyle(
639
+ descriptors: CounterStyleDescriptors,
640
+ options?: { name?: string; root?: Document | ShadowRoot },
641
+ ): string;
642
+ ```
643
+
644
+ ### useFunction
645
+
646
+ Register a CSS `@function` (custom function). Permanent — no cleanup on unmount. Deduplicates by function name. The function name accepts `$$name` (matching the call site `$$name(...)`), `$name`, or `--name`.
647
+
648
+ ```tsx
649
+ import { tasty, useFunction } from '@tenphi/tasty';
650
+
651
+ const Box = tasty({ styles: { margin: '$$negative(10px) top' } });
652
+
653
+ function Layout() {
654
+ useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
655
+ return <Box />;
656
+ }
657
+ ```
658
+
659
+ Call the function through the Tasty DSL rather than a raw `style` prop. An inline `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never expanded — and under `configure({ polyfills: { functions: true } })` it silently does nothing, because the polyfill rewrites calls at parse time.
660
+
661
+ Inside a `tasty()` component you call functions with the same `$$name(...)` sugar:
662
+
663
+ ```tsx
664
+ const Box = tasty({
665
+ styles: {
666
+ '@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
667
+ margin: '$$negative(10px) top',
668
+ },
669
+ });
670
+ ```
671
+
672
+ Signature:
673
+
674
+ ```ts
675
+ function useFunction(
676
+ name: string,
677
+ definition: FunctionDefinition,
678
+ options?: { root?: Document | ShadowRoot },
679
+ ): void;
680
+ ```
681
+
682
+ See the [Functions section of the DSL reference](dsl.md#functions-function) for the full descriptor shape, token conventions, and value-sugar support. `@function` is an experimental CSS feature — unsupported browsers safely ignore the native rule, or enable the [`polyfills.functions`](configuration.md#polyfills) inline polyfill for full cross-browser support.
683
+
684
+ ### Troubleshooting
685
+
686
+ - Styles are not updating: make sure `configure()` runs before first render, and verify the generated class name or global rule with [Debug Utilities](debug.md).
687
+ - SSR output looks wrong: check the [SSR guide](ssr.md) for collector setup. All style functions discover the SSR collector via `AsyncLocalStorage` or the global getter registered by `TastyRegistry`.
688
+ - Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
689
+ - For dynamic styles that change over the component lifecycle, use the `id` option in `useGlobalStyles()` and `useRawCSS()` to enable update tracking.
690
+ - RSC inline mode: CSS accumulated by standalone style functions (`useGlobalStyles`, `useRawCSS`, etc.) is flushed into inline `<style>` tags by the next `tasty()` component in the render tree. If your page uses only standalone style functions without any `tasty()` component, the CSS will not be emitted. Ensure at least one `tasty()` component is present in each RSC render tree.
691
+
692
+ ---
693
+
694
+ ## Learn more
695
+
696
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
697
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
698
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
699
+ - **[Configuration → TypeScript](configuration.md#typescript)** — How props are typed and how to register your names
700
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
701
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
702
+ - **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
703
+ - **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime