@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fdb16ea

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