@tenphi/tasty 0.0.0-snapshot.2c5752e → 0.0.0-snapshot.2c5f23e

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 (330) hide show
  1. package/README.md +501 -262
  2. package/dist/babel-types-Dc5zghyE.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-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/chunks/collector-Cb8ah2JF.js +210 -0
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.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-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.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/chunks/debug-D2Pu7Xhy.js +502 -0
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.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-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.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-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/chunks/zero-engine-DcwaCvFs.js +310 -0
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/collector-D2OT6I2G.d.ts +164 -0
  36. package/dist/config-C4ftFxgI.d.ts +1367 -0
  37. package/dist/core/index.d.ts +5 -33
  38. package/dist/core/index.js +9 -26
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DxQNRj50.d.ts +1964 -0
  41. package/dist/index.d.ts +5 -40
  42. package/dist/index.js +11 -33
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-D39qBtox.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 +127 -0
  60. package/dist/ssr/astro.js +221 -0
  61. package/dist/ssr/astro.js.map +1 -0
  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 -0
  65. package/dist/ssr/index.js +10 -0
  66. package/dist/ssr/index.js.map +1 -0
  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 +46 -0
  71. package/dist/ssr/next.js +60 -0
  72. package/dist/ssr/next.js.map +1 -0
  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-CYQIhUg1.d.ts +1569 -0
  80. package/dist/zero/babel.d.ts +56 -91
  81. package/dist/zero/babel.js +256 -123
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +136 -3
  84. package/dist/zero/index.js +24 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +58 -33
  87. package/dist/zero/next.js +89 -59
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +42 -0
  90. package/docs/adoption.md +331 -0
  91. package/docs/ai-agents.md +259 -0
  92. package/docs/comparison.md +449 -0
  93. package/docs/configuration.md +957 -0
  94. package/docs/debug.md +333 -0
  95. package/docs/design-system.md +557 -0
  96. package/docs/dsl.md +1211 -0
  97. package/docs/getting-started.md +297 -0
  98. package/docs/injector.md +635 -0
  99. package/docs/methodology.md +673 -0
  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 +746 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +636 -0
  106. package/docs/styles.md +781 -0
  107. package/docs/tasty-static.md +700 -0
  108. package/package.json +246 -57
  109. package/tasty.config.ts +21 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -70
  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 -260
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -61
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -280
  119. package/dist/config.js +0 -403
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -204
  122. package/dist/debug.js +0 -733
  123. package/dist/debug.js.map +0 -1
  124. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  125. package/dist/hooks/useGlobalStyles.js +0 -56
  126. package/dist/hooks/useGlobalStyles.js.map +0 -1
  127. package/dist/hooks/useKeyframes.d.ts +0 -56
  128. package/dist/hooks/useKeyframes.js +0 -54
  129. package/dist/hooks/useKeyframes.js.map +0 -1
  130. package/dist/hooks/useProperty.d.ts +0 -79
  131. package/dist/hooks/useProperty.js +0 -91
  132. package/dist/hooks/useProperty.js.map +0 -1
  133. package/dist/hooks/useRawCSS.d.ts +0 -53
  134. package/dist/hooks/useRawCSS.js +0 -28
  135. package/dist/hooks/useRawCSS.js.map +0 -1
  136. package/dist/hooks/useStyles.d.ts +0 -40
  137. package/dist/hooks/useStyles.js +0 -169
  138. package/dist/hooks/useStyles.js.map +0 -1
  139. package/dist/injector/index.d.ts +0 -157
  140. package/dist/injector/index.js +0 -154
  141. package/dist/injector/index.js.map +0 -1
  142. package/dist/injector/injector.d.ts +0 -139
  143. package/dist/injector/injector.js +0 -404
  144. package/dist/injector/injector.js.map +0 -1
  145. package/dist/injector/sheet-manager.d.ts +0 -127
  146. package/dist/injector/sheet-manager.js +0 -714
  147. package/dist/injector/sheet-manager.js.map +0 -1
  148. package/dist/injector/types.d.ts +0 -135
  149. package/dist/keyframes/index.js +0 -206
  150. package/dist/keyframes/index.js.map +0 -1
  151. package/dist/parser/classify.js +0 -319
  152. package/dist/parser/classify.js.map +0 -1
  153. package/dist/parser/const.js +0 -33
  154. package/dist/parser/const.js.map +0 -1
  155. package/dist/parser/lru.js +0 -109
  156. package/dist/parser/lru.js.map +0 -1
  157. package/dist/parser/parser.d.ts +0 -25
  158. package/dist/parser/parser.js +0 -116
  159. package/dist/parser/parser.js.map +0 -1
  160. package/dist/parser/tokenizer.js +0 -69
  161. package/dist/parser/tokenizer.js.map +0 -1
  162. package/dist/parser/types.d.ts +0 -51
  163. package/dist/parser/types.js +0 -46
  164. package/dist/parser/types.js.map +0 -1
  165. package/dist/pipeline/conditions.d.ts +0 -134
  166. package/dist/pipeline/conditions.js +0 -400
  167. package/dist/pipeline/conditions.js.map +0 -1
  168. package/dist/pipeline/exclusive.js +0 -231
  169. package/dist/pipeline/exclusive.js.map +0 -1
  170. package/dist/pipeline/index.d.ts +0 -53
  171. package/dist/pipeline/index.js +0 -641
  172. package/dist/pipeline/index.js.map +0 -1
  173. package/dist/pipeline/materialize.js +0 -908
  174. package/dist/pipeline/materialize.js.map +0 -1
  175. package/dist/pipeline/parseStateKey.d.ts +0 -15
  176. package/dist/pipeline/parseStateKey.js +0 -430
  177. package/dist/pipeline/parseStateKey.js.map +0 -1
  178. package/dist/pipeline/simplify.js +0 -557
  179. package/dist/pipeline/simplify.js.map +0 -1
  180. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  181. package/dist/plugins/okhsl-plugin.js +0 -371
  182. package/dist/plugins/okhsl-plugin.js.map +0 -1
  183. package/dist/plugins/types.d.ts +0 -69
  184. package/dist/properties/index.js +0 -158
  185. package/dist/properties/index.js.map +0 -1
  186. package/dist/states/index.d.ts +0 -49
  187. package/dist/states/index.js +0 -416
  188. package/dist/states/index.js.map +0 -1
  189. package/dist/static/tastyStatic.d.ts +0 -46
  190. package/dist/static/tastyStatic.js +0 -31
  191. package/dist/static/tastyStatic.js.map +0 -1
  192. package/dist/static/types.d.ts +0 -49
  193. package/dist/static/types.js +0 -24
  194. package/dist/static/types.js.map +0 -1
  195. package/dist/styles/align.d.ts +0 -15
  196. package/dist/styles/align.js +0 -14
  197. package/dist/styles/align.js.map +0 -1
  198. package/dist/styles/border.d.ts +0 -25
  199. package/dist/styles/border.js +0 -114
  200. package/dist/styles/border.js.map +0 -1
  201. package/dist/styles/color.d.ts +0 -14
  202. package/dist/styles/color.js +0 -23
  203. package/dist/styles/color.js.map +0 -1
  204. package/dist/styles/createStyle.js +0 -77
  205. package/dist/styles/createStyle.js.map +0 -1
  206. package/dist/styles/dimension.js +0 -97
  207. package/dist/styles/dimension.js.map +0 -1
  208. package/dist/styles/display.d.ts +0 -37
  209. package/dist/styles/display.js +0 -67
  210. package/dist/styles/display.js.map +0 -1
  211. package/dist/styles/fade.d.ts +0 -15
  212. package/dist/styles/fade.js +0 -58
  213. package/dist/styles/fade.js.map +0 -1
  214. package/dist/styles/fill.d.ts +0 -44
  215. package/dist/styles/fill.js +0 -51
  216. package/dist/styles/fill.js.map +0 -1
  217. package/dist/styles/flow.d.ts +0 -16
  218. package/dist/styles/flow.js +0 -12
  219. package/dist/styles/flow.js.map +0 -1
  220. package/dist/styles/gap.d.ts +0 -31
  221. package/dist/styles/gap.js +0 -37
  222. package/dist/styles/gap.js.map +0 -1
  223. package/dist/styles/height.d.ts +0 -17
  224. package/dist/styles/height.js +0 -20
  225. package/dist/styles/height.js.map +0 -1
  226. package/dist/styles/index.d.ts +0 -2
  227. package/dist/styles/index.js +0 -9
  228. package/dist/styles/index.js.map +0 -1
  229. package/dist/styles/inset.d.ts +0 -50
  230. package/dist/styles/inset.js +0 -142
  231. package/dist/styles/inset.js.map +0 -1
  232. package/dist/styles/justify.d.ts +0 -15
  233. package/dist/styles/justify.js +0 -14
  234. package/dist/styles/justify.js.map +0 -1
  235. package/dist/styles/list.d.ts +0 -16
  236. package/dist/styles/list.js +0 -98
  237. package/dist/styles/list.js.map +0 -1
  238. package/dist/styles/margin.d.ts +0 -28
  239. package/dist/styles/margin.js +0 -96
  240. package/dist/styles/margin.js.map +0 -1
  241. package/dist/styles/outline.d.ts +0 -29
  242. package/dist/styles/outline.js +0 -65
  243. package/dist/styles/outline.js.map +0 -1
  244. package/dist/styles/padding.d.ts +0 -28
  245. package/dist/styles/padding.js +0 -96
  246. package/dist/styles/padding.js.map +0 -1
  247. package/dist/styles/predefined.d.ts +0 -73
  248. package/dist/styles/predefined.js +0 -241
  249. package/dist/styles/predefined.js.map +0 -1
  250. package/dist/styles/preset.d.ts +0 -47
  251. package/dist/styles/preset.js +0 -126
  252. package/dist/styles/preset.js.map +0 -1
  253. package/dist/styles/radius.d.ts +0 -14
  254. package/dist/styles/radius.js +0 -51
  255. package/dist/styles/radius.js.map +0 -1
  256. package/dist/styles/scrollbar.d.ts +0 -21
  257. package/dist/styles/scrollbar.js +0 -105
  258. package/dist/styles/scrollbar.js.map +0 -1
  259. package/dist/styles/shadow.d.ts +0 -14
  260. package/dist/styles/shadow.js +0 -24
  261. package/dist/styles/shadow.js.map +0 -1
  262. package/dist/styles/styledScrollbar.d.ts +0 -47
  263. package/dist/styles/styledScrollbar.js +0 -38
  264. package/dist/styles/styledScrollbar.js.map +0 -1
  265. package/dist/styles/transition.d.ts +0 -14
  266. package/dist/styles/transition.js +0 -138
  267. package/dist/styles/transition.js.map +0 -1
  268. package/dist/styles/types.d.ts +0 -498
  269. package/dist/styles/width.d.ts +0 -17
  270. package/dist/styles/width.js +0 -20
  271. package/dist/styles/width.js.map +0 -1
  272. package/dist/tasty.d.ts +0 -982
  273. package/dist/tasty.js +0 -191
  274. package/dist/tasty.js.map +0 -1
  275. package/dist/tokens/typography.d.ts +0 -19
  276. package/dist/tokens/typography.js +0 -237
  277. package/dist/tokens/typography.js.map +0 -1
  278. package/dist/types.d.ts +0 -184
  279. package/dist/utils/cache-wrapper.js +0 -26
  280. package/dist/utils/cache-wrapper.js.map +0 -1
  281. package/dist/utils/case-converter.js +0 -8
  282. package/dist/utils/case-converter.js.map +0 -1
  283. package/dist/utils/colors.d.ts +0 -5
  284. package/dist/utils/colors.js +0 -9
  285. package/dist/utils/colors.js.map +0 -1
  286. package/dist/utils/css-types.d.ts +0 -7
  287. package/dist/utils/dotize.d.ts +0 -26
  288. package/dist/utils/dotize.js +0 -122
  289. package/dist/utils/dotize.js.map +0 -1
  290. package/dist/utils/filter-base-props.d.ts +0 -15
  291. package/dist/utils/filter-base-props.js +0 -45
  292. package/dist/utils/filter-base-props.js.map +0 -1
  293. package/dist/utils/get-display-name.d.ts +0 -7
  294. package/dist/utils/get-display-name.js +0 -10
  295. package/dist/utils/get-display-name.js.map +0 -1
  296. package/dist/utils/hsl-to-rgb.js +0 -38
  297. package/dist/utils/hsl-to-rgb.js.map +0 -1
  298. package/dist/utils/is-dev-env.js +0 -19
  299. package/dist/utils/is-dev-env.js.map +0 -1
  300. package/dist/utils/is-valid-element-type.js +0 -15
  301. package/dist/utils/is-valid-element-type.js.map +0 -1
  302. package/dist/utils/merge-styles.js.map +0 -1
  303. package/dist/utils/mod-attrs.d.ts +0 -8
  304. package/dist/utils/mod-attrs.js +0 -21
  305. package/dist/utils/mod-attrs.js.map +0 -1
  306. package/dist/utils/okhsl-to-rgb.js +0 -296
  307. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  308. package/dist/utils/process-tokens.d.ts +0 -31
  309. package/dist/utils/process-tokens.js +0 -171
  310. package/dist/utils/process-tokens.js.map +0 -1
  311. package/dist/utils/resolve-recipes.d.ts +0 -17
  312. package/dist/utils/resolve-recipes.js +0 -147
  313. package/dist/utils/resolve-recipes.js.map +0 -1
  314. package/dist/utils/string.js +0 -8
  315. package/dist/utils/string.js.map +0 -1
  316. package/dist/utils/styles.d.ts +0 -183
  317. package/dist/utils/styles.js +0 -585
  318. package/dist/utils/styles.js.map +0 -1
  319. package/dist/utils/typography.d.ts +0 -36
  320. package/dist/utils/typography.js +0 -53
  321. package/dist/utils/typography.js.map +0 -1
  322. package/dist/utils/warnings.d.ts +0 -16
  323. package/dist/utils/warnings.js +0 -16
  324. package/dist/utils/warnings.js.map +0 -1
  325. package/dist/zero/css-writer.d.ts +0 -45
  326. package/dist/zero/css-writer.js +0 -74
  327. package/dist/zero/css-writer.js.map +0 -1
  328. package/dist/zero/extractor.d.ts +0 -24
  329. package/dist/zero/extractor.js +0 -150
  330. package/dist/zero/extractor.js.map +0 -1
@@ -0,0 +1,746 @@
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: { '': '#primary', hovered: '#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`, `theme`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component. As on the root, `theme` renders as `data-theme`, and an explicit `data-theme` wins over it.
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
+ pseudo-element (`'.card::before'` with `:hover` gives
499
+ `.card::before:where(:hover)`) and `@parent()` on the element before it.
500
+ Attribute and modifier states, which a pseudo-element can't have, are ignored
501
+ with a warning. Local `@keyframes` are injected with the rules,
502
+ under the same resolved names `tasty()` components use, and `@starting` states
503
+ emit `@starting-style`.
504
+
505
+ A slot — the `id`, or the selector when no `id` is given — holds exactly one
506
+ injection **per `root`**. So:
507
+
508
+ - Changing the styles replaces the previous CSS rather than adding to it.
509
+ - Passing styles that produce no CSS (for example `{}`) clears the slot.
510
+ - The same selector used in two shadow roots keeps a separate injection in each.
511
+ - Two independent call sites that share a selector share a slot, and the last
512
+ render wins. Give them distinct `id`s if they should coexist.
513
+
514
+ ### useRawCSS
515
+
516
+ 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:
517
+
518
+ ```tsx
519
+ import { useRawCSS } from '@tenphi/tasty';
520
+
521
+ function GlobalReset() {
522
+ useRawCSS(`
523
+ body { margin: 0; padding: 0; }
524
+ `);
525
+
526
+ return null;
527
+ }
528
+ ```
529
+
530
+ An `id` slot holds one injection per `root`. Without an `id` the CSS is deduped
531
+ by content and permanent — there is nothing to replace it with later.
532
+
533
+ It also accepts a factory and deps — `useRawCSS(() => css, [deps], { id })` — and skips the factory while the deps for that `id` are unchanged.
534
+
535
+ ### useKeyframes
536
+
537
+ Inject `@keyframes` rules and return the generated animation name:
538
+
539
+ ```tsx
540
+ import { useKeyframes } from '@tenphi/tasty';
541
+
542
+ function Spinner() {
543
+ const spin = useKeyframes(
544
+ {
545
+ from: { transform: 'rotate(0deg)' },
546
+ to: { transform: 'rotate(360deg)' },
547
+ },
548
+ { name: 'spin' },
549
+ );
550
+
551
+ return <div style={{ animation: `${spin} 1s linear infinite` }} />;
552
+ }
553
+ ```
554
+
555
+ `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:
556
+
557
+ ```tsx
558
+ function Pulse({ scale }: { scale: number }) {
559
+ const pulse = useKeyframes(
560
+ () => ({
561
+ '0%': { transform: 'scale(1)' },
562
+ '100%': { transform: `scale(${scale})` },
563
+ }),
564
+ [scale],
565
+ { name: 'pulse' },
566
+ );
567
+
568
+ return (
569
+ <div
570
+ style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }}
571
+ />
572
+ );
573
+ }
574
+ ```
575
+
576
+ Passing `name` claims a slot owned by that one call site, per `root` — much like
577
+ `id` in `useGlobalStyles()` and `useRawCSS()`. When the steps change the previous
578
+ `@keyframes` rule is disposed and the name is reused, so the rules don't
579
+ accumulate and the returned name stays stable. Anonymous keyframes are permanent
580
+ and shared by content.
581
+
582
+ ### useProperty
583
+
584
+ Register a CSS `@property` rule so a custom property can animate smoothly:
585
+
586
+ ```tsx
587
+ import { useProperty } from '@tenphi/tasty';
588
+
589
+ function Spinner() {
590
+ useProperty('$rotation', {
591
+ syntax: '<angle>',
592
+ inherits: false,
593
+ initialValue: '0deg',
594
+ });
595
+
596
+ return <div style={{ transform: 'rotate(var(--rotation))' }} />;
597
+ }
598
+ ```
599
+
600
+ `useProperty()` accepts Tasty token syntax for the property name:
601
+
602
+ - `$name` defines `--name`
603
+ - `#name` defines `--name-color` and auto-infers `<color>`
604
+ - `--name` is also supported for existing CSS variables
605
+
606
+ ### useFontFace
607
+
608
+ Inject `@font-face` rules for custom fonts. Permanent — no cleanup on unmount. Deduplicates by content.
609
+
610
+ ```tsx
611
+ import { useFontFace } from '@tenphi/tasty';
612
+
613
+ function App() {
614
+ useFontFace('Brand Sans', {
615
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
616
+ fontWeight: '400 700',
617
+ fontDisplay: 'swap',
618
+ });
619
+
620
+ return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
621
+ }
622
+ ```
623
+
624
+ For multiple weights/styles, pass an array:
625
+
626
+ ```tsx
627
+ useFontFace('Brand Sans', [
628
+ {
629
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
630
+ fontWeight: 400,
631
+ fontDisplay: 'swap',
632
+ },
633
+ {
634
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
635
+ fontWeight: 700,
636
+ fontDisplay: 'swap',
637
+ },
638
+ ]);
639
+ ```
640
+
641
+ Signature:
642
+
643
+ ```ts
644
+ function useFontFace(
645
+ family: string,
646
+ input: FontFaceInput,
647
+ options?: { root?: Document | ShadowRoot },
648
+ ): void;
649
+ ```
650
+
651
+ ### useCounterStyle
652
+
653
+ Inject a `@counter-style` rule and get back the counter style name. Permanent — no cleanup on unmount. Deduplicates by name.
654
+
655
+ ```tsx
656
+ import { useCounterStyle } from '@tenphi/tasty';
657
+
658
+ function EmojiList() {
659
+ const styleName = useCounterStyle(
660
+ {
661
+ system: 'cyclic',
662
+ symbols: '"👍"',
663
+ suffix: '" "',
664
+ },
665
+ { name: 'thumbs' },
666
+ );
667
+
668
+ return (
669
+ <ol style={{ listStyleType: styleName }}>
670
+ <li>First</li>
671
+ <li>Second</li>
672
+ </ol>
673
+ );
674
+ }
675
+ ```
676
+
677
+ Signature:
678
+
679
+ ```ts
680
+ function useCounterStyle(
681
+ descriptors: CounterStyleDescriptors,
682
+ options?: { name?: string; root?: Document | ShadowRoot },
683
+ ): string;
684
+ ```
685
+
686
+ ### useFunction
687
+
688
+ 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`.
689
+
690
+ ```tsx
691
+ import { tasty, useFunction } from '@tenphi/tasty';
692
+
693
+ const Box = tasty({ styles: { margin: '$$negative(10px) top' } });
694
+
695
+ function Layout() {
696
+ useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
697
+ return <Box />;
698
+ }
699
+ ```
700
+
701
+ 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.
702
+
703
+ Inside a `tasty()` component you call functions with the same `$$name(...)` sugar:
704
+
705
+ ```tsx
706
+ const Box = tasty({
707
+ styles: {
708
+ '@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
709
+ margin: '$$negative(10px) top',
710
+ },
711
+ });
712
+ ```
713
+
714
+ Signature:
715
+
716
+ ```ts
717
+ function useFunction(
718
+ name: string,
719
+ definition: FunctionDefinition,
720
+ options?: { root?: Document | ShadowRoot },
721
+ ): void;
722
+ ```
723
+
724
+ 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.
725
+
726
+ ### Troubleshooting
727
+
728
+ - 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).
729
+ - 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`.
730
+ - "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).
731
+ - Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
732
+ - For dynamic styles that change over the component lifecycle, use the `id` option in `useGlobalStyles()` and `useRawCSS()` to enable update tracking.
733
+ - 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.
734
+
735
+ ---
736
+
737
+ ## Learn more
738
+
739
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
740
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
741
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
742
+ - **[Configuration → TypeScript](configuration.md#typescript)** — How props are typed and how to register your names
743
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
744
+ - **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
745
+ - **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
746
+ - **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime