@tenphi/tasty 0.0.0-snapshot.ef967bb → 0.0.0-snapshot.effc80a

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 (385) hide show
  1. package/README.md +441 -362
  2. package/dist/babel-types-BKDTT4--.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-DHL8W6vf.js +60 -0
  6. package/dist/chunks/build-config-DHL8W6vf.js.map +1 -0
  7. package/dist/chunks/collector-P1lIDioe.js +210 -0
  8. package/dist/chunks/collector-P1lIDioe.js.map +1 -0
  9. package/dist/chunks/config-engine-HlsfjR7T.js +272 -0
  10. package/dist/chunks/config-engine-HlsfjR7T.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-BE12wEJB.js +910 -0
  14. package/dist/chunks/css-definitions-BE12wEJB.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-CWZkJJ7A.js} +196 -147
  18. package/dist/chunks/debug-CWZkJJ7A.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.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-BwKuG_3d.js +689 -0
  24. package/dist/chunks/react-runtime-BwKuG_3d.js.map +1 -0
  25. package/dist/chunks/runtime-engine-D2N-eiPD.js +2432 -0
  26. package/dist/chunks/runtime-engine-D2N-eiPD.js.map +1 -0
  27. package/dist/chunks/runtime-state-BJoTY_DP.js +152 -0
  28. package/dist/chunks/runtime-state-BJoTY_DP.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +60 -56
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-CJoK33le.js +5521 -0
  32. package/dist/chunks/style-engine-CJoK33le.js.map +1 -0
  33. package/dist/chunks/zero-engine-BCqhSuwo.js +310 -0
  34. package/dist/chunks/zero-engine-BCqhSuwo.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-CcxqSZI2.d.ts +1368 -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--GdqCPlp.d.ts +1962 -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-DSkVc6CD.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 +205 -48
  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 +6 -7
  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 +32 -47
  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 -3
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/static/inject.js.map +1 -1
  78. package/dist/types-DJEM_BOJ.d.ts +1567 -0
  79. package/dist/zero/babel.d.ts +5 -120
  80. package/dist/zero/babel.js +123 -146
  81. package/dist/zero/babel.js.map +1 -1
  82. package/dist/zero/index.d.ts +135 -3
  83. package/dist/zero/index.js +24 -3
  84. package/dist/zero/index.js.map +1 -0
  85. package/dist/zero/next.d.ts +4 -5
  86. package/dist/zero/next.js +3 -38
  87. package/dist/zero/next.js.map +1 -1
  88. package/docs/README.md +23 -12
  89. package/docs/adoption.md +72 -37
  90. package/docs/ai-agents.md +257 -0
  91. package/docs/comparison.md +83 -54
  92. package/docs/configuration.md +710 -81
  93. package/docs/debug.md +39 -24
  94. package/docs/design-system.md +174 -41
  95. package/docs/dsl.md +667 -195
  96. package/docs/getting-started.md +132 -52
  97. package/docs/injector.md +197 -90
  98. package/docs/methodology.md +107 -50
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +768 -0
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +744 -0
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +402 -150
  105. package/docs/styles.md +182 -47
  106. package/docs/tasty-static.md +284 -118
  107. package/package.json +148 -35
  108. package/tasty.config.ts +6 -0
  109. package/dist/_virtual/_rolldown/runtime.js +0 -7
  110. package/dist/chunks/cacheKey.d.ts +0 -1
  111. package/dist/chunks/cacheKey.js +0 -77
  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 -258
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/index.d.ts +0 -1
  117. package/dist/chunks/renderChunk.d.ts +0 -1
  118. package/dist/chunks/renderChunk.js +0 -59
  119. package/dist/chunks/renderChunk.js.map +0 -1
  120. package/dist/compute-styles.d.ts +0 -31
  121. package/dist/compute-styles.js +0 -356
  122. package/dist/compute-styles.js.map +0 -1
  123. package/dist/config.d.ts +0 -372
  124. package/dist/config.js +0 -507
  125. package/dist/config.js.map +0 -1
  126. package/dist/counter-style/index.js +0 -51
  127. package/dist/counter-style/index.js.map +0 -1
  128. package/dist/debug.d.ts +0 -89
  129. package/dist/debug.js.map +0 -1
  130. package/dist/font-face/index.js +0 -63
  131. package/dist/font-face/index.js.map +0 -1
  132. package/dist/hooks/index.d.ts +0 -7
  133. package/dist/hooks/resolve-ssr-collector.js +0 -14
  134. package/dist/hooks/resolve-ssr-collector.js.map +0 -1
  135. package/dist/hooks/useCounterStyle.d.ts +0 -50
  136. package/dist/hooks/useCounterStyle.js +0 -46
  137. package/dist/hooks/useCounterStyle.js.map +0 -1
  138. package/dist/hooks/useFontFace.d.ts +0 -43
  139. package/dist/hooks/useFontFace.js +0 -70
  140. package/dist/hooks/useFontFace.js.map +0 -1
  141. package/dist/hooks/useGlobalStyles.d.ts +0 -30
  142. package/dist/hooks/useGlobalStyles.js +0 -78
  143. package/dist/hooks/useGlobalStyles.js.map +0 -1
  144. package/dist/hooks/useKeyframes.d.ts +0 -56
  145. package/dist/hooks/useKeyframes.js +0 -64
  146. package/dist/hooks/useKeyframes.js.map +0 -1
  147. package/dist/hooks/useProperty.d.ts +0 -79
  148. package/dist/hooks/useProperty.js +0 -109
  149. package/dist/hooks/useProperty.js.map +0 -1
  150. package/dist/hooks/useRawCSS.d.ts +0 -53
  151. package/dist/hooks/useRawCSS.js +0 -35
  152. package/dist/hooks/useRawCSS.js.map +0 -1
  153. package/dist/hooks/useStyles.d.ts +0 -40
  154. package/dist/hooks/useStyles.js +0 -31
  155. package/dist/hooks/useStyles.js.map +0 -1
  156. package/dist/injector/index.d.ts +0 -166
  157. package/dist/injector/index.js +0 -166
  158. package/dist/injector/index.js.map +0 -1
  159. package/dist/injector/injector.d.ts +0 -166
  160. package/dist/injector/injector.js +0 -464
  161. package/dist/injector/injector.js.map +0 -1
  162. package/dist/injector/sheet-manager.d.ts +0 -136
  163. package/dist/injector/sheet-manager.js +0 -733
  164. package/dist/injector/sheet-manager.js.map +0 -1
  165. package/dist/injector/types.d.ts +0 -204
  166. package/dist/keyframes/index.js +0 -206
  167. package/dist/keyframes/index.js.map +0 -1
  168. package/dist/parser/classify.js +0 -319
  169. package/dist/parser/classify.js.map +0 -1
  170. package/dist/parser/const.js +0 -60
  171. package/dist/parser/const.js.map +0 -1
  172. package/dist/parser/lru.js +0 -109
  173. package/dist/parser/lru.js.map +0 -1
  174. package/dist/parser/parser.d.ts +0 -25
  175. package/dist/parser/parser.js +0 -115
  176. package/dist/parser/parser.js.map +0 -1
  177. package/dist/parser/tokenizer.js +0 -69
  178. package/dist/parser/tokenizer.js.map +0 -1
  179. package/dist/parser/types.d.ts +0 -51
  180. package/dist/parser/types.js +0 -46
  181. package/dist/parser/types.js.map +0 -1
  182. package/dist/pipeline/conditions.d.ts +0 -134
  183. package/dist/pipeline/conditions.js +0 -406
  184. package/dist/pipeline/conditions.js.map +0 -1
  185. package/dist/pipeline/exclusive.js +0 -230
  186. package/dist/pipeline/exclusive.js.map +0 -1
  187. package/dist/pipeline/index.d.ts +0 -55
  188. package/dist/pipeline/index.js +0 -708
  189. package/dist/pipeline/index.js.map +0 -1
  190. package/dist/pipeline/materialize.js +0 -1103
  191. package/dist/pipeline/materialize.js.map +0 -1
  192. package/dist/pipeline/parseStateKey.d.ts +0 -15
  193. package/dist/pipeline/parseStateKey.js +0 -446
  194. package/dist/pipeline/parseStateKey.js.map +0 -1
  195. package/dist/pipeline/simplify.js +0 -515
  196. package/dist/pipeline/simplify.js.map +0 -1
  197. package/dist/pipeline/warnings.js +0 -18
  198. package/dist/pipeline/warnings.js.map +0 -1
  199. package/dist/plugins/index.d.ts +0 -2
  200. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  201. package/dist/plugins/okhsl-plugin.js +0 -97
  202. package/dist/plugins/okhsl-plugin.js.map +0 -1
  203. package/dist/plugins/types.d.ts +0 -76
  204. package/dist/properties/index.js +0 -222
  205. package/dist/properties/index.js.map +0 -1
  206. package/dist/properties/property-type-resolver.d.ts +0 -24
  207. package/dist/properties/property-type-resolver.js +0 -90
  208. package/dist/properties/property-type-resolver.js.map +0 -1
  209. package/dist/ssr/async-storage.d.ts +0 -17
  210. package/dist/ssr/async-storage.js +0 -34
  211. package/dist/ssr/async-storage.js.map +0 -1
  212. package/dist/ssr/collect-auto-properties.js +0 -39
  213. package/dist/ssr/collect-auto-properties.js.map +0 -1
  214. package/dist/ssr/collector.d.ts +0 -102
  215. package/dist/ssr/collector.js +0 -219
  216. package/dist/ssr/collector.js.map +0 -1
  217. package/dist/ssr/context.d.ts +0 -8
  218. package/dist/ssr/context.js +0 -13
  219. package/dist/ssr/context.js.map +0 -1
  220. package/dist/ssr/format-global-rules.js +0 -22
  221. package/dist/ssr/format-global-rules.js.map +0 -1
  222. package/dist/ssr/format-keyframes.js +0 -69
  223. package/dist/ssr/format-keyframes.js.map +0 -1
  224. package/dist/ssr/format-property.js +0 -49
  225. package/dist/ssr/format-property.js.map +0 -1
  226. package/dist/ssr/format-rules.js +0 -73
  227. package/dist/ssr/format-rules.js.map +0 -1
  228. package/dist/ssr/hydrate.d.ts +0 -22
  229. package/dist/ssr/hydrate.js +0 -49
  230. package/dist/ssr/hydrate.js.map +0 -1
  231. package/dist/ssr/ssr-collector-ref.js +0 -12
  232. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  233. package/dist/states/index.d.ts +0 -49
  234. package/dist/states/index.js +0 -170
  235. package/dist/states/index.js.map +0 -1
  236. package/dist/static/tastyStatic.d.ts +0 -46
  237. package/dist/static/tastyStatic.js +0 -30
  238. package/dist/static/tastyStatic.js.map +0 -1
  239. package/dist/static/types.d.ts +0 -49
  240. package/dist/static/types.js +0 -24
  241. package/dist/static/types.js.map +0 -1
  242. package/dist/styles/border.d.ts +0 -25
  243. package/dist/styles/border.js +0 -120
  244. package/dist/styles/border.js.map +0 -1
  245. package/dist/styles/color.d.ts +0 -14
  246. package/dist/styles/color.js +0 -26
  247. package/dist/styles/color.js.map +0 -1
  248. package/dist/styles/const.js +0 -17
  249. package/dist/styles/const.js.map +0 -1
  250. package/dist/styles/createStyle.js +0 -79
  251. package/dist/styles/createStyle.js.map +0 -1
  252. package/dist/styles/dimension.js +0 -109
  253. package/dist/styles/dimension.js.map +0 -1
  254. package/dist/styles/directional.js +0 -133
  255. package/dist/styles/directional.js.map +0 -1
  256. package/dist/styles/display.d.ts +0 -30
  257. package/dist/styles/display.js +0 -73
  258. package/dist/styles/display.js.map +0 -1
  259. package/dist/styles/fade.d.ts +0 -15
  260. package/dist/styles/fade.js +0 -62
  261. package/dist/styles/fade.js.map +0 -1
  262. package/dist/styles/fill.d.ts +0 -42
  263. package/dist/styles/fill.js +0 -51
  264. package/dist/styles/fill.js.map +0 -1
  265. package/dist/styles/flow.d.ts +0 -16
  266. package/dist/styles/flow.js +0 -12
  267. package/dist/styles/flow.js.map +0 -1
  268. package/dist/styles/gap.d.ts +0 -31
  269. package/dist/styles/gap.js +0 -38
  270. package/dist/styles/gap.js.map +0 -1
  271. package/dist/styles/height.d.ts +0 -17
  272. package/dist/styles/height.js +0 -19
  273. package/dist/styles/height.js.map +0 -1
  274. package/dist/styles/index.d.ts +0 -1
  275. package/dist/styles/index.js +0 -8
  276. package/dist/styles/index.js.map +0 -1
  277. package/dist/styles/inset.d.ts +0 -24
  278. package/dist/styles/inset.js +0 -34
  279. package/dist/styles/inset.js.map +0 -1
  280. package/dist/styles/list.d.ts +0 -16
  281. package/dist/styles/list.js +0 -100
  282. package/dist/styles/list.js.map +0 -1
  283. package/dist/styles/margin.d.ts +0 -24
  284. package/dist/styles/margin.js +0 -32
  285. package/dist/styles/margin.js.map +0 -1
  286. package/dist/styles/outline.d.ts +0 -29
  287. package/dist/styles/outline.js +0 -55
  288. package/dist/styles/outline.js.map +0 -1
  289. package/dist/styles/padding.d.ts +0 -24
  290. package/dist/styles/padding.js +0 -32
  291. package/dist/styles/padding.js.map +0 -1
  292. package/dist/styles/placement.d.ts +0 -37
  293. package/dist/styles/placement.js +0 -74
  294. package/dist/styles/placement.js.map +0 -1
  295. package/dist/styles/predefined.d.ts +0 -71
  296. package/dist/styles/predefined.js +0 -237
  297. package/dist/styles/predefined.js.map +0 -1
  298. package/dist/styles/preset.d.ts +0 -52
  299. package/dist/styles/preset.js +0 -127
  300. package/dist/styles/preset.js.map +0 -1
  301. package/dist/styles/radius.d.ts +0 -12
  302. package/dist/styles/radius.js +0 -83
  303. package/dist/styles/radius.js.map +0 -1
  304. package/dist/styles/scrollMargin.d.ts +0 -24
  305. package/dist/styles/scrollMargin.js +0 -32
  306. package/dist/styles/scrollMargin.js.map +0 -1
  307. package/dist/styles/scrollbar.d.ts +0 -25
  308. package/dist/styles/scrollbar.js +0 -51
  309. package/dist/styles/scrollbar.js.map +0 -1
  310. package/dist/styles/shadow.d.ts +0 -14
  311. package/dist/styles/shadow.js +0 -25
  312. package/dist/styles/shadow.js.map +0 -1
  313. package/dist/styles/shared.js +0 -17
  314. package/dist/styles/shared.js.map +0 -1
  315. package/dist/styles/transition.d.ts +0 -14
  316. package/dist/styles/transition.js +0 -159
  317. package/dist/styles/transition.js.map +0 -1
  318. package/dist/styles/types.d.ts +0 -564
  319. package/dist/styles/width.d.ts +0 -17
  320. package/dist/styles/width.js +0 -19
  321. package/dist/styles/width.js.map +0 -1
  322. package/dist/tasty.d.ts +0 -134
  323. package/dist/tasty.js +0 -240
  324. package/dist/tasty.js.map +0 -1
  325. package/dist/types.d.ts +0 -184
  326. package/dist/utils/cache-wrapper.js +0 -21
  327. package/dist/utils/cache-wrapper.js.map +0 -1
  328. package/dist/utils/case-converter.js +0 -8
  329. package/dist/utils/case-converter.js.map +0 -1
  330. package/dist/utils/color-math.d.ts +0 -46
  331. package/dist/utils/color-math.js +0 -749
  332. package/dist/utils/color-math.js.map +0 -1
  333. package/dist/utils/color-space.d.ts +0 -5
  334. package/dist/utils/color-space.js +0 -228
  335. package/dist/utils/color-space.js.map +0 -1
  336. package/dist/utils/colors.d.ts +0 -5
  337. package/dist/utils/colors.js +0 -10
  338. package/dist/utils/colors.js.map +0 -1
  339. package/dist/utils/css-types.d.ts +0 -7
  340. package/dist/utils/dotize.d.ts +0 -26
  341. package/dist/utils/dotize.js +0 -122
  342. package/dist/utils/dotize.js.map +0 -1
  343. package/dist/utils/filter-base-props.d.ts +0 -15
  344. package/dist/utils/filter-base-props.js +0 -45
  345. package/dist/utils/filter-base-props.js.map +0 -1
  346. package/dist/utils/get-display-name.d.ts +0 -7
  347. package/dist/utils/get-display-name.js +0 -10
  348. package/dist/utils/get-display-name.js.map +0 -1
  349. package/dist/utils/has-keys.js +0 -13
  350. package/dist/utils/has-keys.js.map +0 -1
  351. package/dist/utils/is-dev-env.js +0 -19
  352. package/dist/utils/is-dev-env.js.map +0 -1
  353. package/dist/utils/is-valid-element-type.js +0 -15
  354. package/dist/utils/is-valid-element-type.js.map +0 -1
  355. package/dist/utils/merge-styles.js.map +0 -1
  356. package/dist/utils/mod-attrs.d.ts +0 -6
  357. package/dist/utils/mod-attrs.js +0 -20
  358. package/dist/utils/mod-attrs.js.map +0 -1
  359. package/dist/utils/process-tokens.d.ts +0 -17
  360. package/dist/utils/process-tokens.js +0 -83
  361. package/dist/utils/process-tokens.js.map +0 -1
  362. package/dist/utils/resolve-recipes.d.ts +0 -17
  363. package/dist/utils/resolve-recipes.js +0 -146
  364. package/dist/utils/resolve-recipes.js.map +0 -1
  365. package/dist/utils/selector-transform.js +0 -32
  366. package/dist/utils/selector-transform.js.map +0 -1
  367. package/dist/utils/string.js +0 -8
  368. package/dist/utils/string.js.map +0 -1
  369. package/dist/utils/styles.d.ts +0 -99
  370. package/dist/utils/styles.js +0 -220
  371. package/dist/utils/styles.js.map +0 -1
  372. package/dist/utils/typography.d.ts +0 -47
  373. package/dist/utils/typography.js +0 -51
  374. package/dist/utils/typography.js.map +0 -1
  375. package/dist/utils/warnings.d.ts +0 -16
  376. package/dist/utils/warnings.js +0 -16
  377. package/dist/utils/warnings.js.map +0 -1
  378. package/dist/zero/css-writer.d.ts +0 -45
  379. package/dist/zero/css-writer.js +0 -73
  380. package/dist/zero/css-writer.js.map +0 -1
  381. package/dist/zero/extractor.d.ts +0 -24
  382. package/dist/zero/extractor.js +0 -266
  383. package/dist/zero/extractor.js.map +0 -1
  384. package/docs/PIPELINE.md +0 -519
  385. package/docs/runtime.md +0 -572
@@ -0,0 +1,744 @@
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 — `tasty()` components, `computeStyles()`, `useStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, `useCounterStyle()`, and `useFunction()` — works in React Server Components with no `'use client'` directive. All of them except `useStyles()` are hook-free. `useStyles()` reads the `TastyRegistry` collector from React context on the client, so it is a real hook there; 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 takes the same component options as `tasty({ … })`:
48
+
49
+ ```jsx
50
+ const ActionCard = tasty(Card, {
51
+ styles: { fill: { '': '#surface', isRaised: '#surface-raised' } },
52
+ styleProps: ['gap'] as const, // gap="2x" becomes a style
53
+ modProps: ['isRaised'] as const, // isRaised becomes a mod (data-is-raised)
54
+ tokenProps: ['accentColor'] as const, // accentColor sets the #accent token
55
+ variants: {
56
+ plain: { border: 0 },
57
+ framed: { border: '2bw #accent' },
58
+ },
59
+ variant: 'framed', // applied when no variant prop is passed
60
+ elements: { Footer: 'footer' },
61
+ });
62
+
63
+ <ActionCard gap="2x" isRaised accentColor="#purple">
64
+ <ActionCard.Title>Kept from Card</ActionCard.Title>
65
+ <ActionCard.Footer>Added here</ActionCard.Footer>
66
+ </ActionCard>;
67
+ ```
68
+
69
+ The extension turns its own `styleProps`, `modProps`, and `tokenProps` into the `styles`, `mods`, and `tokens` it passes to the base, which renders them as usual: mods as `data-*` attributes, tokens as inline custom properties. Its `variants` merge over its `styles`, and the `variant` prop is still forwarded, so it selects the base's own variants too and accepts either set's names. Both sets share that one prop, so a name only one of them defines leaves the other at its fallback: if `Card` had an `accent` variant, `variant="accent"` would apply it together with `framed`, and `variant="plain"` would leave `Card` on its default. For two independent choices, give one of them its own prop, such as a `modProps` value list. `elements` adds sub-components, and the base's are kept: `ActionCard.Title` is `Card.Title`. The returned component is typed with all of these props and sub-components.
70
+
71
+ `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`:
72
+
73
+ ```jsx
74
+ import NextLink from 'next/link';
75
+
76
+ const Link = tasty({
77
+ as: NextLink,
78
+ styles: {
79
+ color: { '': '#accent-text', ':hover': '#text' },
80
+ textDecoration: 'underline',
81
+ },
82
+ styleProps: ['padding'],
83
+ });
84
+
85
+ const Span = tasty({
86
+ as: 'span',
87
+ styles: { preset: 'strong' },
88
+ });
89
+
90
+ <Link href="/blog" padding="1x">
91
+ Blog
92
+ </Link>;
93
+ ```
94
+
95
+ 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.
96
+
97
+ 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.
98
+
99
+ ---
100
+
101
+ ## Style Props
102
+
103
+ Use `styleProps` to expose style properties as direct component props:
104
+
105
+ ```jsx
106
+ const FlexibleBox = tasty({
107
+ as: 'div',
108
+ styles: {
109
+ display: 'flex',
110
+ padding: '2x',
111
+ },
112
+ styleProps: ['gap', 'align', 'placeContent', 'fill'],
113
+ });
114
+
115
+ <FlexibleBox gap="2x" align="center" fill="#surface">
116
+ Content
117
+ </FlexibleBox>;
118
+ ```
119
+
120
+ Style props accept state maps, so responsive values work through the same API:
121
+
122
+ ```jsx
123
+ <FlexibleBox
124
+ gap={{ '': '2x', '@tablet': '4x' }}
125
+ fill={{ '': '#surface', '@dark': '#surface-dark' }}
126
+ >
127
+ ```
128
+
129
+ 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).
130
+
131
+ ### Always-available style props
132
+
133
+ 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).
134
+
135
+ ---
136
+
137
+ ## `Element`
138
+
139
+ `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`.
140
+
141
+ ```jsx
142
+ import { Element } from '@tenphi/tasty';
143
+
144
+ <Element as="section" display="grid" preset="t2" styles={{ padding: '4x' }}>
145
+ Content
146
+ </Element>;
147
+ ```
148
+
149
+ > 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'`.
150
+
151
+ ---
152
+
153
+ ## Mod Props
154
+
155
+ Use `modProps` to expose modifier keys as direct component props instead of requiring the `mods` object:
156
+
157
+ ```jsx
158
+ // Before: mods object
159
+ <Button mods={{ isLoading: true, size: 'large' }}>Submit</Button>
160
+
161
+ // After: mod props
162
+ <Button isLoading size="large">Submit</Button>
163
+ ```
164
+
165
+ ### Array form
166
+
167
+ List modifier key names. Types default to `ModValue` (`boolean | string | number | undefined | null`):
168
+
169
+ ```jsx
170
+ const Button = tasty({
171
+ as: 'button',
172
+ modProps: ['isLoading', 'isSelected'] as const,
173
+ styles: {
174
+ fill: { '': '#surface', isLoading: '#surface.5' },
175
+ border: { '': '1bw solid #outline', isSelected: '2bw solid #primary' },
176
+ },
177
+ });
178
+
179
+ <Button isLoading isSelected>Submit</Button>
180
+ // Renders: <button data-is-loading="" data-is-selected="">Submit</button>
181
+ ```
182
+
183
+ ### Object form (typed)
184
+
185
+ Map modifier names to type descriptors for precise TypeScript types:
186
+
187
+ ```tsx
188
+ const Button = tasty({
189
+ as: 'button',
190
+ modProps: {
191
+ isLoading: Boolean, // isLoading?: boolean
192
+ isSelected: Boolean, // isSelected?: boolean
193
+ size: ['small', 'medium', 'large'] as const, // size?: 'small' | 'medium' | 'large'
194
+ },
195
+ styles: {
196
+ padding: { '': '2x 4x', 'size=small': '1x 2x', 'size=large': '3x 6x' },
197
+ fill: { '': '#surface', isLoading: '#surface.5' },
198
+ },
199
+ });
200
+
201
+ <Button isLoading size="large">
202
+ Submit
203
+ </Button>;
204
+ // Renders: <button data-is-loading="" data-size="large">Submit</button>
205
+ ```
206
+
207
+ Available type descriptors:
208
+
209
+ | Descriptor | TypeScript type | Example |
210
+ | --------------------- | --------------- | ----------------------------------- |
211
+ | `Boolean` | `boolean` | `isLoading: Boolean` |
212
+ | `String` | `string` | `label: String` |
213
+ | `Number` | `number` | `count: Number` |
214
+ | `['a', 'b'] as const` | `'a' \| 'b'` | `size: ['sm', 'md', 'lg'] as const` |
215
+
216
+ ### Merge with `mods`
217
+
218
+ Mod props and the `mods` object can be used together. Mod props take precedence:
219
+
220
+ ```jsx
221
+ <Button mods={{ isLoading: false, extra: true }} isLoading>
222
+ // isLoading=true wins (from mod prop), extra=true preserved from mods
223
+ ```
224
+
225
+ ### When to use `modProps` vs `mods`
226
+
227
+ | Use case | Recommendation |
228
+ | -------------------------------------------- | -------------------------------------------------------- |
229
+ | Component has a fixed set of known modifiers | `modProps` — cleaner API, better TypeScript autocomplete |
230
+ | Component needs arbitrary/dynamic modifiers | `mods` — open-ended `Record<string, ModValue>` |
231
+ | Both fixed and dynamic | Combine: `modProps` for known keys, `mods` for ad-hoc |
232
+
233
+ For architecture guidance on when to use modifiers vs `styleProps`, see [Methodology — modProps and mods](methodology.md#modprops-and-mods).
234
+
235
+ ---
236
+
237
+ ## Token Props
238
+
239
+ Use `tokenProps` to expose token keys as direct component props instead of requiring the `tokens` object:
240
+
241
+ ```jsx
242
+ // Before: tokens object
243
+ <ProgressBar tokens={{ $progress: '75%', '#accent': '#purple' }} />
244
+
245
+ // After: token props
246
+ <ProgressBar progress="75%" accentColor="#purple" />
247
+ ```
248
+
249
+ ### Array form
250
+
251
+ List prop names. Names ending in `Color` map to `#` color tokens; everything else maps to `$` custom property tokens:
252
+
253
+ ```jsx
254
+ const ProgressBar = tasty({
255
+ tokenProps: ['progress', 'accentColor'] as const,
256
+ styles: { width: '$progress', fill: '#accent' },
257
+ });
258
+
259
+ <ProgressBar progress="75%" accentColor="#purple" />
260
+ // 'progress' → $progress → --progress
261
+ // 'accentColor' → #accent → --accent-color
262
+ ```
263
+
264
+ ### Object form
265
+
266
+ Map prop names to explicit `$`/`#`-prefixed token keys:
267
+
268
+ ```tsx
269
+ const Card = tasty({
270
+ tokenProps: {
271
+ size: '$card-size',
272
+ color: '#card-accent',
273
+ },
274
+ styles: { padding: '$card-size', fill: '#card-accent' },
275
+ });
276
+
277
+ <Card size="4x" color="#purple" />;
278
+ ```
279
+
280
+ ### Merge with `tokens`
281
+
282
+ Token props and the `tokens` prop can be used together. Token props take precedence over `tokens`, which takes precedence over default `tokens` in `tasty({...})`:
283
+
284
+ ```jsx
285
+ const Bar = tasty({
286
+ tokenProps: ['progress'] as const,
287
+ tokens: { $progress: '0%' }, // default
288
+ });
289
+
290
+ <Bar tokens={{ $progress: '50%' }} progress="90%" />
291
+ // progress="90%" wins (from token prop)
292
+ ```
293
+
294
+ ### When to use `tokenProps` vs `tokens`
295
+
296
+ | Use case | Recommendation |
297
+ | ---------------------------------------------- | ---------------------------------------------------------- |
298
+ | Component has a fixed set of known token keys | `tokenProps` — cleaner API, better TypeScript autocomplete |
299
+ | Component needs arbitrary/dynamic token values | `tokens` — open-ended `Record<string, TokenValue>` |
300
+ | Both fixed and dynamic | Combine: `tokenProps` for known keys, `tokens` for ad-hoc |
301
+
302
+ For architecture guidance, see [Methodology — tokenProps](methodology.md#tokenprops).
303
+
304
+ ---
305
+
306
+ ## Variants
307
+
308
+ Define named style variations. Only CSS for variants actually used at runtime is injected:
309
+
310
+ ```jsx
311
+ const Button = tasty({
312
+ styles: {
313
+ padding: '2x 4x',
314
+ border: true,
315
+ },
316
+ variants: {
317
+ default: { fill: '#blue', color: '#white' },
318
+ danger: { fill: '#red', color: '#white' },
319
+ outline: { fill: '#clear', color: '#blue', border: '1bw solid #blue' },
320
+ },
321
+ });
322
+
323
+ <Button variant="danger">Delete</Button>;
324
+ ```
325
+
326
+ 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.
327
+
328
+ To fall back to another variant instead, name it in the `variant` option:
329
+
330
+ ```jsx
331
+ const Button = tasty({
332
+ styles: { padding: '2x 4x' },
333
+ variants: {
334
+ primary: { fill: '#blue', color: '#white' },
335
+ danger: { fill: '#red', color: '#white' },
336
+ },
337
+ variant: 'primary',
338
+ });
339
+
340
+ <Button>Save</Button>; // primary
341
+ <Button variant="danger">Delete</Button>;
342
+ ```
343
+
344
+ ### Extending Variants with Base State Maps
345
+
346
+ 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:
347
+
348
+ ```jsx
349
+ const Badge = tasty({
350
+ styles: {
351
+ padding: '1x 2x',
352
+ border: {
353
+ 'type=primary': '#clear',
354
+ },
355
+ },
356
+ variants: {
357
+ primary: {
358
+ border: { '': '#white.2', pressed: '#primary-text', disabled: '#clear' },
359
+ fill: { '': '#white #primary', hovered: '#white #primary-text' },
360
+ },
361
+ secondary: {
362
+ border: { '': '#primary.15', pressed: '#primary.3' },
363
+ fill: '#primary.10',
364
+ },
365
+ },
366
+ });
367
+
368
+ // Both variants get 'type=primary': '#clear' appended to their border map
369
+ ```
370
+
371
+ 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.
372
+
373
+ ---
374
+
375
+ ## Sub-element Styling
376
+
377
+ Sub-elements are inner parts of a compound component, styled via capitalized keys in `styles` and identified by `data-element` attributes in the DOM.
378
+
379
+ > 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.
380
+
381
+ ```jsx
382
+ const Card = tasty({
383
+ styles: {
384
+ padding: '4x',
385
+ Title: { preset: 'h3', color: '#primary' },
386
+ Content: { color: '#text' },
387
+ },
388
+ elements: {
389
+ Title: 'h3',
390
+ Content: 'div',
391
+ },
392
+ });
393
+
394
+ <Card>
395
+ <Card.Title>Card Title</Card.Title>
396
+ <Card.Content>Card content</Card.Content>
397
+ </Card>;
398
+ ```
399
+
400
+ Each entry in `elements` can be a tag name string or a config object:
401
+
402
+ ```jsx
403
+ elements: {
404
+ Title: 'h3', // shorthand: tag name only
405
+ Icon: { as: 'span', qa: 'card-icon' }, // full form: tag + QA attribute
406
+ }
407
+ ```
408
+
409
+ The sub-components produced by `elements` support `mods`, `tokens`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component.
410
+
411
+ 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:
412
+
413
+ ```jsx
414
+ const Card = tasty({
415
+ styles: {
416
+ padding: '4x',
417
+ Title: { preset: 'h3', color: '#primary' },
418
+ },
419
+ });
420
+
421
+ <Card>
422
+ <div data-element="Title">Card Title</div>
423
+ </Card>;
424
+ ```
425
+
426
+ ### Selector Affix (`$`)
427
+
428
+ 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-).
429
+
430
+ 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).
431
+
432
+ ---
433
+
434
+ ## computeStyles
435
+
436
+ Hook-free, synchronous style computation. Can be used anywhere — including React Server Components, plain functions, and non-React code:
437
+
438
+ ```tsx
439
+ import { computeStyles } from '@tenphi/tasty';
440
+
441
+ const { className } = computeStyles({
442
+ padding: '2x',
443
+ fill: '#surface',
444
+ radius: '1r',
445
+ });
446
+ ```
447
+
448
+ 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.
449
+
450
+ ---
451
+
452
+ ## Style Functions
453
+
454
+ All style functions below work in client components, SSR with a `ServerStyleCollector`, and React Server Components. All except `useStyles()` are plain functions, not React hooks; they keep the `use` prefix for backward compatibility.
455
+
456
+ 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).
457
+
458
+ ### useStyles
459
+
460
+ 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 on the client: call it inside a component, and use `computeStyles()` outside React. It also works in a Server Component, where it skips the context lookup; like the other style functions there, it cannot emit CSS itself, so the next `tasty()` element in the tree emits it.
461
+
462
+ ```tsx
463
+ import { useStyles } from '@tenphi/tasty';
464
+
465
+ function MyComponent() {
466
+ const { className } = useStyles({
467
+ padding: '2x',
468
+ fill: '#surface',
469
+ radius: '1r',
470
+ });
471
+
472
+ return <div className={className}>Styled content</div>;
473
+ }
474
+ ```
475
+
476
+ ### useGlobalStyles
477
+
478
+ 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:
479
+
480
+ ```tsx
481
+ import { useGlobalStyles } from '@tenphi/tasty';
482
+
483
+ function ThemeStyles() {
484
+ useGlobalStyles('.card', {
485
+ padding: '4x',
486
+ fill: '#surface',
487
+ radius: '1r',
488
+ });
489
+
490
+ return null;
491
+ }
492
+ ```
493
+
494
+ The selector can be a list (`'.uni-checkbox, uni-checkbox'`) — every item gets
495
+ the states and sub-elements, with no `:is()` wrapping needed. Root states
496
+ (`@root(...)`) on a selector that is the root itself (`:root`, `html`) apply to
497
+ that element. A selector that ends in a pseudo-element takes its states on the
498
+ originating element: `'.card::before'` with a `:hover` state gives
499
+ `.card:where(:hover)::before`. Local `@keyframes` are injected with the rules,
500
+ under the same resolved names `tasty()` components use, and `@starting` states
501
+ emit `@starting-style`.
502
+
503
+ A slot — the `id`, or the selector when no `id` is given — holds exactly one
504
+ injection **per `root`**. So:
505
+
506
+ - Changing the styles replaces the previous CSS rather than adding to it.
507
+ - Passing styles that produce no CSS (for example `{}`) clears the slot.
508
+ - The same selector used in two shadow roots keeps a separate injection in each.
509
+ - Two independent call sites that share a selector share a slot, and the last
510
+ render wins. Give them distinct `id`s if they should coexist.
511
+
512
+ ### useRawCSS
513
+
514
+ 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:
515
+
516
+ ```tsx
517
+ import { useRawCSS } from '@tenphi/tasty';
518
+
519
+ function GlobalReset() {
520
+ useRawCSS(`
521
+ body { margin: 0; padding: 0; }
522
+ `);
523
+
524
+ return null;
525
+ }
526
+ ```
527
+
528
+ An `id` slot holds one injection per `root`. Without an `id` the CSS is deduped
529
+ by content and permanent — there is nothing to replace it with later.
530
+
531
+ It also accepts a factory and deps — `useRawCSS(() => css, [deps], { id })` — and skips the factory while the deps for that `id` are unchanged.
532
+
533
+ ### useKeyframes
534
+
535
+ Inject `@keyframes` rules and return the generated animation name:
536
+
537
+ ```tsx
538
+ import { useKeyframes } from '@tenphi/tasty';
539
+
540
+ function Spinner() {
541
+ const spin = useKeyframes(
542
+ {
543
+ from: { transform: 'rotate(0deg)' },
544
+ to: { transform: 'rotate(360deg)' },
545
+ },
546
+ { name: 'spin' },
547
+ );
548
+
549
+ return <div style={{ animation: `${spin} 1s linear infinite` }} />;
550
+ }
551
+ ```
552
+
553
+ `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:
554
+
555
+ ```tsx
556
+ function Pulse({ scale }: { scale: number }) {
557
+ const pulse = useKeyframes(
558
+ () => ({
559
+ '0%': { transform: 'scale(1)' },
560
+ '100%': { transform: `scale(${scale})` },
561
+ }),
562
+ [scale],
563
+ { name: 'pulse' },
564
+ );
565
+
566
+ return (
567
+ <div
568
+ style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }}
569
+ />
570
+ );
571
+ }
572
+ ```
573
+
574
+ Passing `name` claims a slot owned by that one call site, per `root` — much like
575
+ `id` in `useGlobalStyles()` and `useRawCSS()`. When the steps change the previous
576
+ `@keyframes` rule is disposed and the name is reused, so the rules don't
577
+ accumulate and the returned name stays stable. Anonymous keyframes are permanent
578
+ and shared by content.
579
+
580
+ ### useProperty
581
+
582
+ Register a CSS `@property` rule so a custom property can animate smoothly:
583
+
584
+ ```tsx
585
+ import { useProperty } from '@tenphi/tasty';
586
+
587
+ function Spinner() {
588
+ useProperty('$rotation', {
589
+ syntax: '<angle>',
590
+ inherits: false,
591
+ initialValue: '0deg',
592
+ });
593
+
594
+ return <div style={{ transform: 'rotate(var(--rotation))' }} />;
595
+ }
596
+ ```
597
+
598
+ `useProperty()` accepts Tasty token syntax for the property name:
599
+
600
+ - `$name` defines `--name`
601
+ - `#name` defines `--name-color` and auto-infers `<color>`
602
+ - `--name` is also supported for existing CSS variables
603
+
604
+ ### useFontFace
605
+
606
+ Inject `@font-face` rules for custom fonts. Permanent — no cleanup on unmount. Deduplicates by content.
607
+
608
+ ```tsx
609
+ import { useFontFace } from '@tenphi/tasty';
610
+
611
+ function App() {
612
+ useFontFace('Brand Sans', {
613
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
614
+ fontWeight: '400 700',
615
+ fontDisplay: 'swap',
616
+ });
617
+
618
+ return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
619
+ }
620
+ ```
621
+
622
+ For multiple weights/styles, pass an array:
623
+
624
+ ```tsx
625
+ useFontFace('Brand Sans', [
626
+ {
627
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
628
+ fontWeight: 400,
629
+ fontDisplay: 'swap',
630
+ },
631
+ {
632
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
633
+ fontWeight: 700,
634
+ fontDisplay: 'swap',
635
+ },
636
+ ]);
637
+ ```
638
+
639
+ Signature:
640
+
641
+ ```ts
642
+ function useFontFace(
643
+ family: string,
644
+ input: FontFaceInput,
645
+ options?: { root?: Document | ShadowRoot },
646
+ ): void;
647
+ ```
648
+
649
+ ### useCounterStyle
650
+
651
+ Inject a `@counter-style` rule and get back the counter style name. Permanent — no cleanup on unmount. Deduplicates by name.
652
+
653
+ ```tsx
654
+ import { useCounterStyle } from '@tenphi/tasty';
655
+
656
+ function EmojiList() {
657
+ const styleName = useCounterStyle(
658
+ {
659
+ system: 'cyclic',
660
+ symbols: '"👍"',
661
+ suffix: '" "',
662
+ },
663
+ { name: 'thumbs' },
664
+ );
665
+
666
+ return (
667
+ <ol style={{ listStyleType: styleName }}>
668
+ <li>First</li>
669
+ <li>Second</li>
670
+ </ol>
671
+ );
672
+ }
673
+ ```
674
+
675
+ Signature:
676
+
677
+ ```ts
678
+ function useCounterStyle(
679
+ descriptors: CounterStyleDescriptors,
680
+ options?: { name?: string; root?: Document | ShadowRoot },
681
+ ): string;
682
+ ```
683
+
684
+ ### useFunction
685
+
686
+ 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`.
687
+
688
+ ```tsx
689
+ import { tasty, useFunction } from '@tenphi/tasty';
690
+
691
+ const Box = tasty({ styles: { margin: '$$negative(10px) top' } });
692
+
693
+ function Layout() {
694
+ useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
695
+ return <Box />;
696
+ }
697
+ ```
698
+
699
+ 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.
700
+
701
+ Inside a `tasty()` component you call functions with the same `$$name(...)` sugar:
702
+
703
+ ```tsx
704
+ const Box = tasty({
705
+ styles: {
706
+ '@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
707
+ margin: '$$negative(10px) top',
708
+ },
709
+ });
710
+ ```
711
+
712
+ Signature:
713
+
714
+ ```ts
715
+ function useFunction(
716
+ name: string,
717
+ definition: FunctionDefinition,
718
+ options?: { root?: Document | ShadowRoot },
719
+ ): void;
720
+ ```
721
+
722
+ 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.
723
+
724
+ ### Troubleshooting
725
+
726
+ - 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).
727
+ - 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`.
728
+ - "Server rendering without a style collector" in development: the server render has no request scope, so each `tasty()` element inlines its own CSS and configured globals are not emitted. Add `tastyIntegration()` (Astro), `TastyRegistry` (Next.js), or `runWithCollector()` — see the [SSR guide](ssr.md).
729
+ - Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
730
+ - For dynamic styles that change over the component lifecycle, use the `id` option in `useGlobalStyles()` and `useRawCSS()` to enable update tracking.
731
+ - RSC inline mode: CSS accumulated by standalone style functions (`useStyles`, `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.
732
+
733
+ ---
734
+
735
+ ## Learn more
736
+
737
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
738
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
739
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
740
+ - **[Configuration → TypeScript](configuration.md#typescript)** — How props are typed and how to register your names
741
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
742
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
743
+ - **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
744
+ - **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime