@tenphi/tasty 0.0.0-snapshot.09d653f → 0.0.0-snapshot.0a2809e

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 (356) hide show
  1. package/README.md +449 -407
  2. package/dist/babel-types-docs8f4c.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-DmSCYjYl.js +60 -0
  6. package/dist/chunks/build-config-DmSCYjYl.js.map +1 -0
  7. package/dist/chunks/collector-8w5r-xFl.js +210 -0
  8. package/dist/chunks/collector-8w5r-xFl.js.map +1 -0
  9. package/dist/chunks/config-engine-DjRv6Axa.js +272 -0
  10. package/dist/chunks/config-engine-DjRv6Axa.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-_UidGa56.js +910 -0
  14. package/dist/chunks/css-definitions-_UidGa56.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-B6dZq3uH.js +502 -0
  18. package/dist/chunks/debug-B6dZq3uH.js.map +1 -0
  19. package/dist/chunks/dsl-rgu6XQcD.js +1386 -0
  20. package/dist/chunks/dsl-rgu6XQcD.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-DS1cEAMK.js +689 -0
  24. package/dist/chunks/react-runtime-DS1cEAMK.js.map +1 -0
  25. package/dist/chunks/runtime-engine-DFCZN1nF.js +2432 -0
  26. package/dist/chunks/runtime-engine-DFCZN1nF.js.map +1 -0
  27. package/dist/chunks/runtime-state-C8MzPjBR.js +152 -0
  28. package/dist/chunks/runtime-state-C8MzPjBR.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-DoGrZPBB.js +5576 -0
  32. package/dist/chunks/style-engine-DoGrZPBB.js.map +1 -0
  33. package/dist/chunks/zero-engine-CiVidroC.js +310 -0
  34. package/dist/chunks/zero-engine-CiVidroC.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-DDY7NlZ1.d.ts +1367 -0
  37. package/dist/core/index.d.ts +5 -32
  38. package/dist/core/index.js +9 -26
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DOxyS72p.d.ts +1962 -0
  41. package/dist/index.d.ts +5 -47
  42. package/dist/index.js +11 -33
  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 +206 -50
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -5
  65. package/dist/ssr/index.js +7 -9
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -12
  71. package/dist/ssr/next.js +40 -51
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-DJEM_BOJ.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +27 -109
  81. package/dist/zero/babel.js +215 -146
  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 +16 -5
  87. package/dist/zero/next.js +8 -42
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +42 -0
  90. package/docs/adoption.md +85 -40
  91. package/docs/ai-agents.md +258 -0
  92. package/docs/comparison.md +92 -56
  93. package/docs/configuration.md +781 -66
  94. package/docs/debug.md +171 -343
  95. package/docs/design-system.md +194 -38
  96. package/docs/dsl.md +764 -145
  97. package/docs/getting-started.md +146 -50
  98. package/docs/injector.md +199 -92
  99. package/docs/methodology.md +216 -44
  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 +403 -149
  106. package/docs/styles.md +222 -61
  107. package/docs/tasty-static.md +376 -96
  108. package/package.json +157 -39
  109. package/tasty.config.ts +6 -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 -259
  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 -311
  119. package/dist/config.js +0 -458
  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 -30
  125. package/dist/hooks/useGlobalStyles.js +0 -83
  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 -69
  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 -114
  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 -40
  135. package/dist/hooks/useRawCSS.js.map +0 -1
  136. package/dist/hooks/useStyles.d.ts +0 -45
  137. package/dist/hooks/useStyles.js +0 -248
  138. package/dist/hooks/useStyles.js.map +0 -1
  139. package/dist/injector/index.d.ts +0 -165
  140. package/dist/injector/index.js +0 -162
  141. package/dist/injector/index.js.map +0 -1
  142. package/dist/injector/injector.d.ts +0 -148
  143. package/dist/injector/injector.js +0 -430
  144. package/dist/injector/injector.js.map +0 -1
  145. package/dist/injector/sheet-manager.d.ts +0 -136
  146. package/dist/injector/sheet-manager.js +0 -729
  147. package/dist/injector/sheet-manager.js.map +0 -1
  148. package/dist/injector/types.d.ts +0 -144
  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 -406
  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 -660
  172. package/dist/pipeline/index.js.map +0 -1
  173. package/dist/pipeline/materialize.js +0 -856
  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 -451
  177. package/dist/pipeline/parseStateKey.js.map +0 -1
  178. package/dist/pipeline/simplify.js +0 -516
  179. package/dist/pipeline/simplify.js.map +0 -1
  180. package/dist/pipeline/warnings.js +0 -18
  181. package/dist/pipeline/warnings.js.map +0 -1
  182. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  183. package/dist/plugins/okhsl-plugin.js +0 -371
  184. package/dist/plugins/okhsl-plugin.js.map +0 -1
  185. package/dist/plugins/types.d.ts +0 -76
  186. package/dist/properties/index.js +0 -236
  187. package/dist/properties/index.js.map +0 -1
  188. package/dist/properties/property-type-resolver.d.ts +0 -24
  189. package/dist/properties/property-type-resolver.js +0 -91
  190. package/dist/properties/property-type-resolver.js.map +0 -1
  191. package/dist/ssr/async-storage.d.ts +0 -17
  192. package/dist/ssr/async-storage.js +0 -35
  193. package/dist/ssr/async-storage.js.map +0 -1
  194. package/dist/ssr/collect-auto-properties.js +0 -40
  195. package/dist/ssr/collect-auto-properties.js.map +0 -1
  196. package/dist/ssr/collector.d.ts +0 -85
  197. package/dist/ssr/collector.js +0 -183
  198. package/dist/ssr/collector.js.map +0 -1
  199. package/dist/ssr/context.d.ts +0 -8
  200. package/dist/ssr/context.js +0 -14
  201. package/dist/ssr/context.js.map +0 -1
  202. package/dist/ssr/format-global-rules.js +0 -22
  203. package/dist/ssr/format-global-rules.js.map +0 -1
  204. package/dist/ssr/format-keyframes.js +0 -70
  205. package/dist/ssr/format-keyframes.js.map +0 -1
  206. package/dist/ssr/format-property.js +0 -48
  207. package/dist/ssr/format-property.js.map +0 -1
  208. package/dist/ssr/format-rules.js +0 -70
  209. package/dist/ssr/format-rules.js.map +0 -1
  210. package/dist/ssr/hydrate.d.ts +0 -22
  211. package/dist/ssr/hydrate.js +0 -50
  212. package/dist/ssr/hydrate.js.map +0 -1
  213. package/dist/ssr/ssr-collector-ref.js +0 -12
  214. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  215. package/dist/states/index.d.ts +0 -49
  216. package/dist/states/index.js +0 -416
  217. package/dist/states/index.js.map +0 -1
  218. package/dist/static/tastyStatic.d.ts +0 -46
  219. package/dist/static/tastyStatic.js +0 -31
  220. package/dist/static/tastyStatic.js.map +0 -1
  221. package/dist/static/types.d.ts +0 -49
  222. package/dist/static/types.js +0 -24
  223. package/dist/static/types.js.map +0 -1
  224. package/dist/styles/align.d.ts +0 -15
  225. package/dist/styles/align.js +0 -14
  226. package/dist/styles/align.js.map +0 -1
  227. package/dist/styles/border.d.ts +0 -25
  228. package/dist/styles/border.js +0 -114
  229. package/dist/styles/border.js.map +0 -1
  230. package/dist/styles/color.d.ts +0 -14
  231. package/dist/styles/color.js +0 -23
  232. package/dist/styles/color.js.map +0 -1
  233. package/dist/styles/createStyle.js +0 -77
  234. package/dist/styles/createStyle.js.map +0 -1
  235. package/dist/styles/dimension.js +0 -97
  236. package/dist/styles/dimension.js.map +0 -1
  237. package/dist/styles/display.d.ts +0 -37
  238. package/dist/styles/display.js +0 -67
  239. package/dist/styles/display.js.map +0 -1
  240. package/dist/styles/fade.d.ts +0 -15
  241. package/dist/styles/fade.js +0 -58
  242. package/dist/styles/fade.js.map +0 -1
  243. package/dist/styles/fill.d.ts +0 -42
  244. package/dist/styles/fill.js +0 -52
  245. package/dist/styles/fill.js.map +0 -1
  246. package/dist/styles/flow.d.ts +0 -16
  247. package/dist/styles/flow.js +0 -12
  248. package/dist/styles/flow.js.map +0 -1
  249. package/dist/styles/gap.d.ts +0 -31
  250. package/dist/styles/gap.js +0 -37
  251. package/dist/styles/gap.js.map +0 -1
  252. package/dist/styles/height.d.ts +0 -17
  253. package/dist/styles/height.js +0 -20
  254. package/dist/styles/height.js.map +0 -1
  255. package/dist/styles/index.d.ts +0 -2
  256. package/dist/styles/index.js +0 -9
  257. package/dist/styles/index.js.map +0 -1
  258. package/dist/styles/inset.d.ts +0 -52
  259. package/dist/styles/inset.js +0 -150
  260. package/dist/styles/inset.js.map +0 -1
  261. package/dist/styles/justify.d.ts +0 -15
  262. package/dist/styles/justify.js +0 -14
  263. package/dist/styles/justify.js.map +0 -1
  264. package/dist/styles/list.d.ts +0 -16
  265. package/dist/styles/list.js +0 -98
  266. package/dist/styles/list.js.map +0 -1
  267. package/dist/styles/margin.d.ts +0 -24
  268. package/dist/styles/margin.js +0 -104
  269. package/dist/styles/margin.js.map +0 -1
  270. package/dist/styles/outline.d.ts +0 -29
  271. package/dist/styles/outline.js +0 -65
  272. package/dist/styles/outline.js.map +0 -1
  273. package/dist/styles/padding.d.ts +0 -24
  274. package/dist/styles/padding.js +0 -104
  275. package/dist/styles/padding.js.map +0 -1
  276. package/dist/styles/predefined.d.ts +0 -71
  277. package/dist/styles/predefined.js +0 -238
  278. package/dist/styles/predefined.js.map +0 -1
  279. package/dist/styles/preset.d.ts +0 -47
  280. package/dist/styles/preset.js +0 -126
  281. package/dist/styles/preset.js.map +0 -1
  282. package/dist/styles/radius.d.ts +0 -14
  283. package/dist/styles/radius.js +0 -51
  284. package/dist/styles/radius.js.map +0 -1
  285. package/dist/styles/scrollbar.d.ts +0 -25
  286. package/dist/styles/scrollbar.js +0 -48
  287. package/dist/styles/scrollbar.js.map +0 -1
  288. package/dist/styles/shadow.d.ts +0 -14
  289. package/dist/styles/shadow.js +0 -24
  290. package/dist/styles/shadow.js.map +0 -1
  291. package/dist/styles/transition.d.ts +0 -14
  292. package/dist/styles/transition.js +0 -158
  293. package/dist/styles/transition.js.map +0 -1
  294. package/dist/styles/types.d.ts +0 -508
  295. package/dist/styles/width.d.ts +0 -17
  296. package/dist/styles/width.js +0 -20
  297. package/dist/styles/width.js.map +0 -1
  298. package/dist/tasty.d.ts +0 -981
  299. package/dist/tasty.js +0 -206
  300. package/dist/tasty.js.map +0 -1
  301. package/dist/types.d.ts +0 -184
  302. package/dist/utils/cache-wrapper.js +0 -26
  303. package/dist/utils/cache-wrapper.js.map +0 -1
  304. package/dist/utils/case-converter.js +0 -8
  305. package/dist/utils/case-converter.js.map +0 -1
  306. package/dist/utils/colors.d.ts +0 -5
  307. package/dist/utils/colors.js +0 -9
  308. package/dist/utils/colors.js.map +0 -1
  309. package/dist/utils/css-types.d.ts +0 -7
  310. package/dist/utils/dotize.d.ts +0 -26
  311. package/dist/utils/dotize.js +0 -122
  312. package/dist/utils/dotize.js.map +0 -1
  313. package/dist/utils/filter-base-props.d.ts +0 -15
  314. package/dist/utils/filter-base-props.js +0 -45
  315. package/dist/utils/filter-base-props.js.map +0 -1
  316. package/dist/utils/get-display-name.d.ts +0 -7
  317. package/dist/utils/get-display-name.js +0 -10
  318. package/dist/utils/get-display-name.js.map +0 -1
  319. package/dist/utils/hsl-to-rgb.js +0 -38
  320. package/dist/utils/hsl-to-rgb.js.map +0 -1
  321. package/dist/utils/is-dev-env.js +0 -19
  322. package/dist/utils/is-dev-env.js.map +0 -1
  323. package/dist/utils/is-valid-element-type.js +0 -15
  324. package/dist/utils/is-valid-element-type.js.map +0 -1
  325. package/dist/utils/merge-styles.js.map +0 -1
  326. package/dist/utils/mod-attrs.d.ts +0 -8
  327. package/dist/utils/mod-attrs.js +0 -21
  328. package/dist/utils/mod-attrs.js.map +0 -1
  329. package/dist/utils/okhsl-to-rgb.js +0 -296
  330. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  331. package/dist/utils/process-tokens.d.ts +0 -31
  332. package/dist/utils/process-tokens.js +0 -171
  333. package/dist/utils/process-tokens.js.map +0 -1
  334. package/dist/utils/resolve-recipes.d.ts +0 -17
  335. package/dist/utils/resolve-recipes.js +0 -147
  336. package/dist/utils/resolve-recipes.js.map +0 -1
  337. package/dist/utils/selector-transform.js +0 -32
  338. package/dist/utils/selector-transform.js.map +0 -1
  339. package/dist/utils/string.js +0 -8
  340. package/dist/utils/string.js.map +0 -1
  341. package/dist/utils/styles.d.ts +0 -177
  342. package/dist/utils/styles.js +0 -730
  343. package/dist/utils/styles.js.map +0 -1
  344. package/dist/utils/typography.d.ts +0 -47
  345. package/dist/utils/typography.js +0 -43
  346. package/dist/utils/typography.js.map +0 -1
  347. package/dist/utils/warnings.d.ts +0 -16
  348. package/dist/utils/warnings.js +0 -16
  349. package/dist/utils/warnings.js.map +0 -1
  350. package/dist/zero/css-writer.d.ts +0 -45
  351. package/dist/zero/css-writer.js +0 -74
  352. package/dist/zero/css-writer.js.map +0 -1
  353. package/dist/zero/extractor.d.ts +0 -24
  354. package/dist/zero/extractor.js +0 -215
  355. package/dist/zero/extractor.js.map +0 -1
  356. package/docs/runtime.md +0 -291
package/README.md CHANGED
@@ -1,39 +1,54 @@
1
1
  <p align="center">
2
- <img src="assets/tasty.svg" width="128" height="128" alt="Tasty logo">
2
+ <img src="assets/tasty.svg" width="128" height="128" alt="Tasty logo" />
3
3
  </p>
4
4
 
5
5
  <h1 align="center">Tasty</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>The styling engine built for design systems.</strong><br>
9
- Deterministic CSS generation. State-aware DSL. Zero specificity conflicts. Ever.
8
+ <strong>CSS-in-JS for React design systems.</strong><br />
9
+ Build components whose styles don’t fight.
10
10
  </p>
11
11
 
12
12
  <p align="center">
13
- <a href="https://www.npmjs.com/package/@tenphi/tasty"><img src="https://img.shields.io/npm/v/@tenphi/tasty.svg" alt="npm version"></a>
14
- <a href="https://github.com/tenphi/tasty/actions/workflows/ci.yml"><img src="https://github.com/tenphi/tasty/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
15
- <a href="https://github.com/tenphi/tasty/blob/main/LICENSE"><img src="https://img.shields.io/github/license/tenphi/tasty" alt="license"></a>
13
+ <a href="https://www.npmjs.com/package/@tenphi/tasty"><img src="https://img.shields.io/npm/v/@tenphi/tasty.svg" alt="npm version" /></a>
14
+ <a href="https://github.com/tenphi/tasty/actions/workflows/ci.yml"><img src="https://github.com/tenphi/tasty/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI" /></a>
15
+ <a href="https://github.com/tenphi/tasty/blob/main/LICENSE"><img src="https://img.shields.io/github/license/tenphi/tasty" alt="license" /></a>
16
16
  </p>
17
17
 
18
18
  ---
19
19
 
20
- Most CSS-in-JS libraries emit rules that compete through cascade and specificity. Tasty emits **mutually exclusive CSS selectors** — for any component state combination, exactly one selector matches each property at a time. No cascade conflicts, no specificity wars, no `!important` escapes. Components compose and extend without breaking each other.
20
+ Tasty is a styling engine for teams that build component libraries. You describe hover, disabled, variants, themes, and breakpoints as **state maps**, in a CSS-like language built from your design system's own tokens and conventions. Tasty compiles each map into selectors that never match at the same time, so the result never depends on specificity or source order.
21
21
 
22
- That guarantee unlocks a concise, CSS-like DSL where design tokens, custom units, responsive states, container queries, sub-element styling, and theming all compose without surprises — one coherent system that scales from a single component to an enterprise design system.
22
+ ```tsx
23
+ import { tasty } from '@tenphi/tasty';
24
+
25
+ const Button = tasty({
26
+ as: 'button',
27
+ styles: {
28
+ fill: {
29
+ '': '#primary',
30
+ ':hover': '#primary-hover',
31
+ ':active': '#primary-pressed',
32
+ '[disabled]': '#surface',
33
+ },
34
+ },
35
+ });
36
+ ```
37
+
38
+ Later keys have higher priority. If this button is both hovered and disabled, `[disabled]` wins and the hover rule does not apply. That decision is compiled into the selectors themselves, so you can add states, variants, themes, and overrides without reopening selector logic by hand.
39
+
40
+ - **Ready to try it?** Follow [Getting Started](docs/getting-started.md).
41
+ - **Evaluating fit?** Read [Comparison](docs/comparison.md) and the [Adoption Guide](docs/adoption.md).
42
+ - **Building a component library?** See [Methodology](docs/methodology.md) and [Building a Design System](docs/design-system.md).
23
43
 
24
44
  ## Why Tasty
25
45
 
26
- - **Deterministic at any scale** — Exclusive selector generation eliminates the entire class of cascade/specificity bugs. Every state combination resolves to exactly one CSS rule per property. Refactor freely. See [How It Actually Works](#how-it-actually-works).
27
- - **AI-friendly by design** — Style definitions are declarative, self-contained, and structurally consistent. AI tools can read, understand, and refactor even advanced state bindings as confidently as a human — because there's no hidden cascade logic or implicit ordering to second-guess.
28
- - **DSL that feels like CSS** — Property names you already know (`padding`, `color`, `display`) with syntax sugar that removes boilerplate. Learn the DSL in minutes, not days. See [Style Properties](docs/styles.md).
29
- - **CSS properties as normal component props** — `styleProps` lets you expose selected styles as typed React props. Use `<Button placeSelf="end">` or `<Space flow="row" gap="2x">` without extra wrappers, utility classes, or `styles` overrides. The same props also accept state maps, so responsive values work with the same API. See [CSS properties as props](#css-properties-as-props).
30
- - **Design-system native** — Color tokens (`#primary`), spacing units (`2x`), typography presets (`h1`, `t2`), border radius (`1r`), and recipes are first-class primitives, not afterthoughts. See [Configuration](docs/configuration.md).
31
- - **Near-complete modern CSS coverage** — Media queries, container queries, `@supports`, `:has()`, `@starting-style`, `@property`, `@keyframes`, etc. Some features that don't fit Tasty's component model (such as `@layer` and `!important`) are intentionally omitted, but real-world use cases are covered almost completely.
32
- - **Runtime, zero-runtime, or SSR — your call** — Use `tasty()` for dynamic React components with runtime injection, `tastyStatic()` with the Babel plugin for zero-runtime CSS extraction, or enable SSR with zero-cost client hydration for Next.js, Astro, or any React framework (experimental). Same DSL, same tokens, same output.
33
- - **Only generate what is used** — In runtime mode, Tasty injects CSS on demand for mounted components/variants, so your app avoids shipping style rules for UI states that are never rendered.
34
- - **Runtime performance that holds at scale** — The runtime path is tested against enterprise-scale applications and tuned with multi-level caching, chunk-level style reuse, style garbage collection, and a dedicated injector.
35
- - **Composable and extensible by design** — Extend any component's styles with proper merge semantics, and evolve built-in behavior through configuration and plugins.
36
- - **TypeScript-first** — Full type definitions, module augmentation for custom properties, and autocomplete for tokens, presets, and themes. See [Configuration](docs/configuration.md).
46
+ - **States that can't conflict** — Every state map compiles into mutually exclusive selectors, and the last matching key wins by construction. Adding a state, variant, or override never means re-deriving selector interactions. [How it works →](#how-it-works)
47
+ - **Your design system's language** — Define color tokens, units, state aliases like `@mobile` and `@dark`, typography presets, and recipes once with `configure()`. Components then read like the spec: `padding: '2x'`, `fill: '#surface'`, `preset: 'h3'`. [Design-system integration →](#design-system-integration)
48
+ - **Typed component APIs** — Decide exactly what consumers can change. `styleProps`, `modProps`, `tokenProps`, `variants`, and sub-elements become typed React props and components with full autocomplete. [Component API →](#component-api)
49
+ - **Guardrails in the editor and CI** — An ESLint and oxlint plugin with 40+ rules checks property names, values, tokens, state keys, presets, and recipes against your project's config. TypeScript augmentation autocompletes your own token, preset, and theme names. [Types and linting →](#types-and-linting)
50
+ - **Modern CSS, one model** — Media and container queries, `@supports`, `:has()`, root and parent states, and `@starting-style` are all state keys. `@keyframes`, `@property`, `@font-face`, `@counter-style`, and `@function` are built in. [CSS coverage →](#css-coverage)
51
+ - **Render anywhere** — The same styles work in client React, React Server Components, and streaming SSR (Next.js, Astro). Render only on the server to ship no styling runtime at all, or extract CSS at build time with `tastyStatic()`. [Rendering modes →](#rendering-modes)
37
52
 
38
53
  ## Installation
39
54
 
@@ -41,9 +56,13 @@ That guarantee unlocks a concise, CSS-like DSL where design tokens, custom units
41
56
  pnpm add @tenphi/tasty
42
57
  ```
43
58
 
59
+ Requires Node.js 20+ and React 18+ (a peer dependency of the React entry points). `npm add @tenphi/tasty` and `yarn add @tenphi/tasty` work the same way.
60
+
44
61
  ## Quick Start
45
62
 
46
- ### Create a styled component
63
+ ### 1. Write a component
64
+
65
+ Plain CSS values work as-is, so a first component looks like CSS you already know:
47
66
 
48
67
  ```tsx
49
68
  import { tasty } from '@tenphi/tasty';
@@ -52,158 +71,154 @@ const Card = tasty({
52
71
  as: 'div',
53
72
  styles: {
54
73
  display: 'flex',
55
- flow: 'column',
56
- padding: '4x',
57
- gap: '2x',
58
- fill: '#surface',
59
- border: '#border bottom',
60
- radius: '1r',
74
+ flow: 'column', // flex-flow
75
+ padding: '24px',
76
+ gap: '12px',
77
+ fill: 'white', // background-color
78
+ color: '#222',
79
+ border: '1px solid #ddd',
80
+ radius: '12px', // border-radius
61
81
  },
62
82
  });
63
83
 
64
- // Just a React component
65
- <Card>Hello World</Card>
84
+ <Card>Hello World</Card>;
66
85
  ```
67
86
 
68
- Every value maps to CSS you'd recognize — but with tokens and units that keep your design system consistent by default.
87
+ ### 2. Bring in your design system
69
88
 
70
- ### Add state-driven styles
89
+ Call `configure()` once, before your app renders, to define the vocabulary every component shares:
90
+
91
+ ```tsx
92
+ // tasty.setup.ts — import it at the top of your entry point
93
+ import { configure } from '@tenphi/tasty';
94
+
95
+ configure({
96
+ tokens: {
97
+ '#surface': { '': '#fff', '@dark': '#1c1c1e' },
98
+ '#text': { '': '#222', '@dark': '#f2f2f7' },
99
+ '#border': '#ddd',
100
+ },
101
+ units: { x: '8px', r: '12px' }, // spacing step and radius
102
+ states: {
103
+ '@mobile': '@media(w < 768px)',
104
+ '@dark':
105
+ '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
106
+ },
107
+ });
108
+ ```
109
+
110
+ The same card, written in that vocabulary:
111
+
112
+ ```tsx
113
+ const Card = tasty({
114
+ styles: {
115
+ display: 'flex',
116
+ flow: 'column',
117
+ padding: { '': '3x', '@mobile': '2x' }, // 24px, 16px on mobile
118
+ gap: '1.5x', // 12px
119
+ fill: '#surface', // var(--surface-color)
120
+ color: '#text',
121
+ border: true, // 1bw solid #border
122
+ radius: '1r', // 12px
123
+ },
124
+ });
125
+ ```
126
+
127
+ The component never mentions dark mode, yet it follows the `@dark` tokens. Change a token or a unit once and every component follows.
128
+
129
+ ### 3. Add states and a typed API
71
130
 
72
131
  ```tsx
73
132
  const Button = tasty({
74
133
  as: 'button',
134
+ modProps: { isLoading: Boolean, size: ['sm', 'md', 'lg'] as const },
75
135
  styles: {
76
- padding: '1.5x 3x',
136
+ padding: { '': '1.5x 3x', 'size=sm': '1x 2x', 'size=lg': '2x 4x' },
137
+ radius: '1r',
77
138
  fill: {
78
139
  '': '#primary',
79
140
  ':hover': '#primary-hover',
80
141
  ':active': '#primary-pressed',
81
- '[disabled]': '#surface',
82
- },
83
- color: {
84
- '': '#on-primary',
85
- '[disabled]': '#text.40',
86
- },
87
- cursor: {
88
- '': 'pointer',
89
- '[disabled]': 'not-allowed',
142
+ disabled: '#surface',
90
143
  },
144
+ color: { '': '#on-primary', disabled: '#text.40' },
145
+ cursor: { '': 'pointer', isLoading: 'wait', disabled: 'not-allowed' },
91
146
  transition: 'theme',
92
147
  },
93
148
  });
149
+
150
+ <Button size="lg" isLoading>
151
+ Save
152
+ </Button>;
153
+ // renders <button data-is-loading data-size="lg" class="…">
94
154
  ```
95
155
 
96
- State keys support pseudo-classes first (`:hover`, `:active`), then modifiers (`theme=danger`), attributes (`[disabled]`), media/container queries, root states, and more. Tasty compiles them into exclusive selectors automatically.
156
+ `size` is typed as `'sm' | 'md' | 'lg'`. Mod props become `data-*` attributes, which state keys like `size=lg` and `isLoading` select. `disabled` tracks the native `disabled` prop, `#text.40` is the text color at 40% opacity, and `transition: 'theme'` is a named group that transitions color, background, border, shadow, outline, and opacity together.
97
157
 
98
- ### Extend any component
158
+ ### 4. Extend a component
99
159
 
100
160
  ```tsx
101
- import { Button } from 'my-ui-lib';
102
-
103
161
  const DangerButton = tasty(Button, {
104
162
  styles: {
105
163
  fill: {
106
164
  '': '#danger',
107
165
  ':hover': '#danger-hover',
166
+ ':active': '#danger-pressed',
167
+ disabled: '@inherit', // keep the parent's disabled branch
108
168
  },
109
169
  },
110
170
  });
111
171
  ```
112
172
 
113
- Child styles merge with parent styles intelligently — state maps can extend or replace parent states per-property.
114
-
115
- ### Configure once, use everywhere
116
-
117
- ```tsx
118
- import { configure } from '@tenphi/tasty';
119
-
120
- configure({
121
- states: {
122
- '@mobile': '@media(w < 768px)',
123
- '@tablet': '@media(w < 1024px)',
124
- '@dark': '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
125
- },
126
- recipes: {
127
- card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
128
- },
129
- });
130
- ```
131
-
132
- Predefined states turn complex selector logic into single tokens. Use `@mobile` instead of writing media query expressions in every component.
173
+ A state map with a `''` key replaces the parent's map; a map without one extends it. `@inherit` pulls a single branch from the parent, `null` removes one, and `false` blocks it entirely. See [Extending vs. replacing state maps](docs/dsl.md#extending-vs-replacing-state-maps). An extension can also declare its own `styleProps`, `modProps`, `tokenProps`, `variants`, and `elements`, and it keeps the base's sub-elements.
133
174
 
134
- ### CSS properties as props
175
+ [Getting Started](docs/getting-started.md) continues from here with setup, linting, editor tooling, and choosing a rendering mode.
135
176
 
136
- With `styleProps`, a component can expose the styles you choose as normal typed props. That means you can adjust layout, spacing, alignment, or positioning right where the component is used, instead of introducing wrapper elements or reaching for a separate styling API.
177
+ ## How It Works
137
178
 
138
- This is especially good for prototyping and fast UI iteration: you can shape interfaces quickly, while still staying inside a typed, design-system-aware component API that scales to production.
179
+ The cascade resolves conflicts by specificity, then by source order. Take two rules for a button's background:
139
180
 
140
- ```tsx
141
- import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
142
-
143
- const Space = tasty({
144
- styles: {
145
- display: 'flex',
146
- flow: 'column',
147
- gap: '1x',
148
- },
149
- styleProps: FLOW_STYLES,
150
- });
151
-
152
- const Button = tasty({
153
- as: 'button',
154
- styles: {
155
- padding: '1.5x 3x',
156
- fill: '#primary',
157
- color: '#primary-text',
158
- radius: true,
159
- },
160
- styleProps: POSITION_STYLES,
161
- });
181
+ ```css
182
+ .btn:hover {
183
+ background: dodgerblue;
184
+ }
185
+ .btn[disabled] {
186
+ background: gray;
187
+ }
162
188
  ```
163
189
 
164
- Now you can compose layout and tweak component positioning directly in JSX:
190
+ Both selectors have specificity `(0, 2, 0)`. When the button is hovered **and** disabled, both match and the later rule wins. Swap the two rules and a hovered disabled button silently turns blue. The logic is correct; only the order is wrong, which is why this class of bug survives code review.
165
191
 
166
- ```tsx
167
- <Space flow="row" gap="2x" placeItems="center">
168
- <Title>Dashboard</Title>
169
- <Button placeSelf="end">Add Item</Button>
170
- </Space>
171
- ```
172
-
173
- The same props also support state maps, so responsive values use the exact same API:
192
+ Tasty removes the competition. For the same intent:
174
193
 
175
194
  ```tsx
176
- <Space
177
- flow={{ '': 'column', '@tablet': 'row' }}
178
- gap={{ '': '2x', '@tablet': '4x' }}
179
- >
180
- <Sidebar />
181
- <Content />
182
- </Space>
195
+ fill: {
196
+ '': '#primary',
197
+ ':hover': '#primary-hover',
198
+ '[disabled]': '#surface',
199
+ }
183
200
  ```
184
201
 
185
- Layout components can expose flow props. Buttons can expose positioning props. Each component can offer only the style props that make sense for its role, while still keeping tokens, custom units, and state maps fully typed. This works in runtime `tasty()` components, not in `tastyStatic()`.
186
-
187
- ## How It Actually Works
188
-
189
- This is the core idea that makes everything else possible.
190
-
191
- Traditional CSS has two structural problems.
192
-
193
- First, the **cascade** resolves conflicts by specificity and source order: when multiple selectors match, the one with the highest specificity wins, or — if specificity is equal — the last one in source order wins. That makes styles inherently fragile. Reordering imports, adding a media query, or composing components from different libraries can silently break styling.
194
-
195
- A small example makes this tangible. Two rules for a button's background:
202
+ it generates:
196
203
 
197
204
  ```css
198
- .btn:hover { background: dodgerblue; }
199
- .btn[disabled] { background: gray; }
205
+ .t0.t0:where(:not([disabled]):not(:hover)) {
206
+ background-color: var(--primary-color);
207
+ }
208
+ .t0.t0:where(:not([disabled]):hover) {
209
+ background-color: var(--primary-hover-color);
210
+ }
211
+ .t0.t0:where([disabled]) {
212
+ background-color: var(--surface-color);
213
+ }
200
214
  ```
201
215
 
202
- Both selectors have specificity `(0, 1, 1)`. When the button is hovered **and** disabled, both match — and the last rule in source order wins. Swap the two lines and a hovered disabled button silently turns blue instead of gray. This class of bug is invisible in code review because the logic is correct; only the ordering is wrong.
216
+ Each branch is guarded by the negation of every higher-priority branch, so exactly one rule matches any element. Reorder the rules, split them across stylesheets, or extend the component: the outcome stays the same. Because the logic stays in CSS rather than JavaScript, the browser handles layout, painting, and transitions natively.
203
217
 
204
- Second, **authoring selectors that capture real-world state logic is fundamentally hard.** A single state like "dark mode" may depend on a root attribute, an OS preference, or both — each branch needing its own selector, proper negation of competing branches, and correct `@media` nesting. The example below shows the CSS you'd write by hand for just *one* property with *one* state. Scale that across dozens of properties, then add breakpoints and container queries, and the selector logic quickly becomes unmanageable.
218
+ <details>
219
+ <summary><strong>A harder case: dark mode from a root attribute or the OS preference</strong></summary>
205
220
 
206
- Tasty solves both problems at once: **every state mapping compiles into mutually exclusive selectors.**
221
+ Say `@dark` means "the root has `data-schema="dark"`, or no schema is set and the OS prefers dark":
207
222
 
208
223
  ```tsx
209
224
  const Text = tasty({
@@ -212,409 +227,429 @@ const Text = tasty({
212
227
  '': '#text',
213
228
  '@dark': '#text-on-dark',
214
229
  },
215
- padding: {
216
- '': '4x',
217
- '@mobile': '2x',
218
- },
219
230
  },
220
231
  });
221
232
  ```
222
233
 
223
- If `@dark` expands to `@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))`, try writing the CSS by hand. A first attempt might look like this:
234
+ A first attempt by hand:
224
235
 
225
236
  ```css
226
- /* First attempt — the @media branch is too broad */
227
- .t0 { color: var(--text-color); }
228
- :root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
229
- @media (prefers-color-scheme: dark) {
230
- .t0 { color: var(--text-on-dark-color); }
237
+ .t0 {
238
+ color: var(--text-color);
239
+ }
240
+ :root[data-schema='dark'] .t0 {
241
+ color: var(--text-on-dark-color);
231
242
  }
232
- ```
233
-
234
- The `@media` branch fires even when `data-schema="light"` is explicitly set. Fix that:
235
-
236
- ```css
237
- /* Second attempt — @media is scoped, but the default is still too broad */
238
- .t0 { color: var(--text-color); }
239
- :root[data-schema="dark"] .t0 { color: var(--text-on-dark-color); }
240
243
  @media (prefers-color-scheme: dark) {
241
- :root:not([data-schema]) .t0 { color: var(--text-on-dark-color); }
244
+ .t0 {
245
+ color: var(--text-on-dark-color);
246
+ }
242
247
  }
243
248
  ```
244
249
 
245
- Better — but the bare `.t0` default still matches unconditionally. It matches in dark mode, it matches when `data-schema="dark"` is set, and it can beat the attribute selector by source order if another rule re-declares it later. There is no selector that says "apply this default only when none of the dark branches win."
246
-
247
- This is just *one* property with *one* state, and getting it right already takes multiple iterations. The correct selectors require negating every other branch — which is exactly what Tasty generates automatically:
248
-
249
- Tasty generates the correct version automatically:
250
+ The `@media` branch fires even when `data-schema="light"` is set explicitly. Scoping it to `:root:not([data-schema])` fixes that, but the bare `.t0` default still matches unconditionally, and it can beat the attribute selector by source order if another rule re-declares it later. No single selector says "apply the default only when none of the dark branches win". The correct version negates every other branch, which is what Tasty generates:
250
251
 
251
252
  ```css
252
- /* Branch 1: Explicit dark schema */
253
- :root[data-schema="dark"] .t0.t0 {
253
+ /* Explicit dark schema */
254
+ :where(:root[data-schema='dark']) .t0.t0 {
254
255
  color: var(--text-on-dark-color);
255
256
  }
256
257
 
257
- /* Branch 2: No schema attribute + OS prefers dark */
258
+ /* No schema attribute, OS prefers dark */
258
259
  @media (prefers-color-scheme: dark) {
259
- :root:not([data-schema]) .t0.t0 {
260
+ :where(:root:not([data-schema])) .t0.t0 {
260
261
  color: var(--text-on-dark-color);
261
262
  }
262
263
  }
263
264
 
264
- /* Default: no schema + OS does not prefer dark */
265
+ /* Default: OS prefers light, schema is not dark */
265
266
  @media (not (prefers-color-scheme: dark)) {
266
- :root:not([data-schema="dark"]) .t0.t0 {
267
+ :where(:root:not([data-schema='dark'])) .t0.t0 {
267
268
  color: var(--text-color);
268
269
  }
269
270
  }
270
271
 
271
- /* Default: schema is set but not dark (any OS preference) */
272
- :root:not([data-schema="dark"])[data-schema] .t0.t0 {
273
- color: var(--text-color);
272
+ /* Default: OS prefers dark, but a non-dark schema is set */
273
+ @media (prefers-color-scheme: dark) {
274
+ :where(:root:not([data-schema='dark'])[data-schema]) .t0.t0 {
275
+ color: var(--text-color);
276
+ }
274
277
  }
275
278
  ```
276
279
 
277
- Every rule is guarded by the negation of higher-priority rules. No two rules can match at the same time. No specificity arithmetic. No source-order dependence. Components compose and extend without collisions.
280
+ That is one property with one state. Multiply it by dozens of properties, breakpoints, and container queries, and hand-written selectors stop being maintainable.
278
281
 
279
- By absorbing selector complexity, Tasty makes advanced CSS patterns practical again — nested container queries, multi-condition `@supports` gates, and combined root-state/media branches. You stay in pure CSS instead of relying on JavaScript workarounds, so the browser can optimize layout, painting, and transitions natively. Tasty doesn't limit CSS; it unlocks its full potential by removing the complexity that held teams back.
282
+ </details>
280
283
 
281
- [Try it in the Tasty Playground →](https://cube-ui-kit.vercel.app/?path=/story/getting-started-tasty-playground--playground)
284
+ For the full compiler model (parsing state keys, building exclusive conditions, merging by value, materializing selectors and at-rules), see the [Style rendering pipeline](docs/pipeline.md). [Try it in the playground →](https://tasty.style/playground)
282
285
 
283
- ## Capabilities
286
+ ## Design-System Integration
284
287
 
285
- ### Design Tokens and Custom Units
288
+ `configure()` is where a design system's vocabulary lives. Everything defined there is available to every component, and the same names feed the linter and TypeScript.
286
289
 
287
- Tokens are first-class. Colors use `#name` syntax. Spacing, radius, and border width use multiplier units tied to CSS custom properties:
288
-
289
- ```tsx
290
- fill: '#surface', // → var(--surface-color)
291
- color: '#text.80', // → 80% opacity text token
292
- padding: '2x', // → calc(var(--gap) * 2)
293
- radius: '1r', // → var(--radius)
294
- border: '1bw solid #border',
295
- ```
290
+ | Define | With `configure({ … })` | Use in styles |
291
+ | ---------------------------- | ------------------------------------------------------- | -------------------------------------------------------- |
292
+ | Color tokens | `tokens: { '#surface': '#fff' }` | `fill: '#surface'`, `color: '#text.60'` |
293
+ | Value tokens | `tokens: { '$sidebar-width': '280px' }` | `width: '$sidebar-width'` |
294
+ | Units | `units: { x: '8px', r: '6px' }` | `padding: '2x'`, `radius: '1r'` |
295
+ | State aliases | `states: { '@mobile': '@media(w < 768px)' }` | `gap: { '': '2x', '@mobile': '1x' }` |
296
+ | Typography presets | `presets: { h1: { fontSize: '2rem', … } }` | `preset: 'h1'` |
297
+ | Recipes | `recipes: { card: { padding: '4x', … } }` | `recipe: 'card'` |
298
+ | Global at-rules | `keyframes`, `properties`, `fontFaces`, `counterStyles` | `animation: 'fade-in 200ms'` |
299
+ | Functions, handlers, plugins | `functions`, `handlers`, `propHandlers`, `plugins` | `$$name(...)`, new style properties, new component props |
296
300
 
297
- | Unit | Maps to | Example |
298
- |------|---------|---------|
299
- | `x` | `--gap` multiplier | `2x` → `calc(var(--gap) * 2)` |
300
- | `r` | `--radius` multiplier | `1r` → `var(--radius)` |
301
- | `bw` | `--border-width` multiplier | `1bw` → `var(--border-width)` |
302
- | `ow` | `--outline-width` multiplier | `1ow` → `var(--outline-width)` |
303
- | `cr` | `--card-radius` multiplier | `1cr` → `var(--card-radius)` |
301
+ Tokens accept state maps, so a theme is just more branches: `'#surface': { '': '#fff', '@dark': '#1c1c1e' }`. To generate whole light, dark, and high-contrast palettes with contrast solving, use [Glaze](#glaze).
304
302
 
305
- Define your own units via `configure({ units: { ... } })`.
303
+ ### Built-in units
306
304
 
307
- ### State System
305
+ | Unit | Default | Example |
306
+ | ---- | ------------------- | ------------------------ |
307
+ | `x` | `8px` spacing step | `2x` → `16px` |
308
+ | `r` | `6px` radius | `1r` → `6px` |
309
+ | `cr` | `10px` card radius | `1cr` → `10px` |
310
+ | `bw` | `1px` border width | `2bw` → `2px` |
311
+ | `ow` | `3px` outline width | `1ow` → `3px` |
312
+ | `sf` | stable fraction | `1sf` → `minmax(0, 1fr)` |
308
313
 
309
- Every style property accepts a state mapping object. Keys can be combined with boolean logic:
314
+ Units compile to plain values. Override them with `configure({ units })`. When the scale has to change at runtime, point a unit at a custom property and define it as a token: `units: { x: 'var(--gap)' }` with `tokens: { $gap: '8px' }` makes `2x` compile to `calc(2 * var(--gap))`. Parentheses become `calc()`: `width: '(100% - 4x)'`.
310
315
 
311
- | State type | Syntax | CSS output |
312
- |------------|--------|------------|
313
- | Data attribute (boolean modifier) | `disabled` | `[data-disabled]` |
314
- | Data attribute (value modifier) | `theme=danger` | `[data-theme="danger"]` |
315
- | Pseudo-class | `:hover` | `:hover` |
316
- | Attribute selector | `[role="tab"]` | `[role="tab"]` |
317
- | Class selector (supported) | `.is-active` | `.is-active` |
318
- | Media query | `@media(w < 768px)` | `@media (width < 768px)` |
319
- | Container query | `@(panel, w >= 300px)` | `@container panel (width >= 300px)` |
320
- | Root state | `@root(theme=dark)` | `:root[data-theme="dark"]` |
321
- | Parent state | `@parent(theme=danger)` | `:is([data-theme="danger"] *)` |
322
- | Feature query | `@supports(display: grid)` | `@supports (display: grid)` |
323
- | Entry animation | `@starting` | `@starting-style` |
316
+ ### Recipes
324
317
 
325
- Combine with `&` (AND), `|` (OR), `!` (NOT):
318
+ Recipes are reusable style bundles, state maps included:
326
319
 
327
320
  ```tsx
328
- fill: {
329
- '': '#surface',
330
- 'theme=danger & :hover': '#danger-hover',
331
- '[aria-selected="true"]': '#accent-subtle',
332
- }
321
+ configure({
322
+ recipes: {
323
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
324
+ elevated: { shadow: '0 1x 3x #shadow' },
325
+ },
326
+ });
327
+
328
+ const Panel = tasty({ styles: { recipe: 'card elevated', gap: '2x' } });
333
329
  ```
334
330
 
335
- ### Sub-Element Styling
331
+ Local styles merge over recipes with the same extend/replace rules as component extension. Recipes listed after `/` apply after local styles, and `none` skips base recipes. See [Style DSL — Recipes](docs/dsl.md#recipes).
332
+
333
+ For token vocabularies, state aliases, layout primitives, and override contracts, see [Building a Design System](docs/design-system.md). To add your own style properties, units, functions, or component props, see [Plugins & Extension Points](docs/plugins.md).
336
334
 
337
- Style inner elements from the parent component definition. No extra components, no CSS leakage:
335
+ ## Component API
336
+
337
+ A Tasty component's public API is something you design. Instead of handing consumers an open `styles` escape hatch, expose the knobs they need as typed props.
338
+
339
+ ### Style props
340
+
341
+ `styleProps` turns selected style properties into props. They accept state maps, so responsive values use the same syntax:
338
342
 
339
343
  ```tsx
340
- const Card = tasty({
341
- styles: {
342
- padding: '4x',
343
- Title: { preset: 'h3', color: '#primary' },
344
- Content: { color: '#text', preset: 't2' },
345
- },
346
- elements: { Title: 'h2', Content: 'div' },
344
+ import { tasty, FLOW_STYLES } from '@tenphi/tasty';
345
+
346
+ const Space = tasty({
347
+ styles: { display: 'flex', flow: 'column', gap: '1x' },
348
+ styleProps: FLOW_STYLES,
347
349
  });
348
350
 
349
- <Card>
350
- <Card.Title>Heading</Card.Title>
351
- <Card.Content>Body text</Card.Content>
352
- </Card>
351
+ <Space flow="row" gap={{ '': '2x', '@mobile': '1x' }} />;
353
352
  ```
354
353
 
355
- Sub-elements use `data-element` attributes — no extra class names, no naming conventions.
354
+ ### Mod props
356
355
 
357
- By default, sub-elements participate in the same state context as the root component. That means mappings like `:hover`, `theme=danger`, `[role="button"]`, and other keys are evaluated as one unified block, which keeps styling logic predictable across the whole markup tree.
356
+ `modProps` exposes modifiers as typed props (`<Button isLoading size="lg">`, as in the [Quick Start](#3-add-states-and-a-typed-api)). Use `Boolean`, `String`, `Number`, or a `const` array of allowed values.
358
357
 
359
- Use `@own(...)` when a sub-element should react to its own state instead of the root state context.
358
+ ### Token props
360
359
 
361
- Class selectors are also supported, but modifiers/pseudo-classes are usually the better default in design-system code.
360
+ `tokenProps` handles values that change often, such as progress, user-picked colors, or measured sizes. They set custom properties inline, so the class name and the CSS stay the same while the value changes:
362
361
 
363
- Use the sub-element selector `$` when you need precise descendant targeting to avoid leakage in deeply nested component trees.
362
+ ```tsx
363
+ const Progress = tasty({
364
+ tokenProps: ['progress', 'accentColor'] as const,
365
+ styles: { width: '$progress', fill: '#accent' },
366
+ });
367
+
368
+ <Progress progress="75%" accentColor="#purple" />;
369
+ // style="--progress:75%;--accent-color:var(--purple-color)"
370
+ ```
364
371
 
365
372
  ### Variants
366
373
 
367
- Variants are designed to keep single-component CSS lean. Instead of generating dozens of static button classes up front, define all versions once and let runtime usage decide what CSS is actually emitted.
374
+ Variants are named style sets. `variant` is typed from their keys, `default` (or the variant named by the `variant` option) applies when no `variant` is passed, and only the variants actually rendered emit CSS:
368
375
 
369
376
  ```tsx
370
- const Button = tasty({
371
- styles: { padding: '2x 4x', radius: '1r' },
377
+ const Badge = tasty({
378
+ styles: { padding: '.5x 1x', radius: '1r' },
372
379
  variants: {
373
- default: { fill: '#primary', color: '#on-primary' },
380
+ default: { fill: '#surface', color: '#text' },
374
381
  danger: { fill: '#danger', color: '#on-danger' },
375
- outline: { fill: 'transparent', border: '1bw solid #primary' },
376
382
  },
377
383
  });
378
384
 
379
- <Button variant="danger">Delete</Button>
385
+ <Badge variant="danger">Failed</Badge>;
380
386
  ```
381
387
 
382
- ### Recipes
388
+ ### Sub-elements
383
389
 
384
- Recipes are predefined style sets that work like composable styling classes for Tasty. They can be pre-applied or post-applied to current styles, which lets you add reusable state logic while still allowing local style overrides.
390
+ Compound components style their inner parts from one definition. `elements` produces typed sub-components:
385
391
 
386
392
  ```tsx
387
- configure({
388
- recipes: {
389
- card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
390
- elevated: { shadow: '0 2x 4x #shadow' },
391
- },
392
- });
393
-
394
- const ProfileCard = tasty({
393
+ const Card = tasty({
395
394
  styles: {
396
- recipe: 'card elevated',
397
- color: '#text',
395
+ padding: '4x',
396
+ Title: { preset: 'h3', color: { '': '#text', ':hover': '#primary' } },
397
+ Content: { color: '#text' },
398
398
  },
399
+ elements: { Title: 'h3', Content: 'div' },
399
400
  });
401
+
402
+ <Card>
403
+ <Card.Title>Revenue</Card.Title>
404
+ <Card.Content>Up 12% this week</Card.Content>
405
+ </Card>;
400
406
  ```
401
407
 
402
- Use `/` to post-apply recipes after local styles when you need recipe states/styles to win the final merge order. Use `none` to skip base recipes: `recipe: 'none / disabled'`.
408
+ Sub-elements share the root's state context: `:hover` inside `Title` means "when the card is hovered". Use `@own(...)` when a part should react to its own state, and the `$` selector affix for precise descendant targeting.
403
409
 
404
- ### Auto-Inferred `@property`
410
+ All of these are covered in [React API](docs/react-api.md). For guidance on what to expose and when, see [Methodology](docs/methodology.md).
405
411
 
406
- CSS custom properties do not animate smoothly by default because the browser does not know how to interpolate their values. The [`@property`](https://developer.mozilla.org/en-US/docs/Web/CSS/@property) at-rule fixes that by declaring a property's syntax, such as `<number>` or `<color>`.
412
+ ## Types and Linting
407
413
 
408
- In Tasty, you usually do not need to declare `@property` manually. When a custom property is assigned a concrete value, Tasty infers the syntax and registers the matching `@property` for you:
414
+ ### TypeScript
409
415
 
410
- ```tsx
411
- const Pulse = tasty({
412
- styles: {
413
- animation: 'pulse 2s infinite',
414
- transform: 'scale($pulse-scale)',
415
- '@keyframes': {
416
- pulse: {
417
- '0%, 100%': { '$pulse-scale': 1 },
418
- '50%': { '$pulse-scale': 1.05 },
419
- },
420
- },
421
- },
422
- });
416
+ Component props are typed from their definitions: `modProps` value lists become unions, `variant` is typed from the variant keys, style props are typed like the styles they expose, and sub-elements are typed components. Register your design system's names to get autocomplete inside style values too:
417
+
418
+ ```ts
419
+ // tasty.d.ts
420
+ import '@tenphi/tasty';
421
+
422
+ declare module '@tenphi/tasty' {
423
+ // '#surface', '#primary.50' in fill, color, and other color props
424
+ interface TastyNamedColors {
425
+ surface: true;
426
+ primary: true;
427
+ }
428
+ // preset: 'h1'
429
+ interface TastyPresetNames {
430
+ h1: true;
431
+ t2: true;
432
+ }
433
+ // <Button theme="danger" />
434
+ interface TastyThemeNames {
435
+ danger: true;
436
+ }
437
+ }
423
438
  ```
424
439
 
425
- Here, `$pulse-scale: 1` is inferred as `<number>`, so Tasty injects `@property --pulse-scale` automatically before using it in the animation. Numeric types (`<number>`, `<length>`, `<percentage>`, `<angle>`, `<time>`) are inferred from values; `<color>` is inferred from the `#name` token convention.
440
+ `StylesInterface`, `TastyCustomProps`, and `TastyBaseStylePropNames` type the style properties, component props, and base style props your plugins add. See [Configuration → TypeScript](docs/configuration.md#typescript).
426
441
 
427
- If you prefer full manual control, disable auto-inference globally with `configure({ autoPropertyTypes: false })`.
442
+ ### ESLint and oxlint
428
443
 
429
- ### Explicit `@properties`
444
+ [`@tenphi/eslint-plugin-tasty`](https://github.com/tenphi/eslint-plugin-tasty) validates style objects and JSX style props at lint time:
430
445
 
431
- Declare `@properties` yourself only when you need to override the defaults, for example to set `inherits: false` or provide a custom `initialValue`:
446
+ ```bash
447
+ pnpm add -D @tenphi/eslint-plugin-tasty
448
+ ```
432
449
 
433
- ```tsx
434
- '@properties': {
435
- '$pulse-scale': { syntax: '<number>', inherits: false, initialValue: 1 },
436
- },
450
+ ```js
451
+ // eslint.config.js
452
+ import tasty from '@tenphi/eslint-plugin-tasty';
453
+
454
+ export default [tasty.configs.recommended]; // or tasty.configs.strict
437
455
  ```
438
456
 
439
- ### React Hooks
457
+ A `tasty.config.ts` at the project root tells the plugin what your design system defines:
440
458
 
441
- For cases where you don't need a full component:
459
+ ```ts
460
+ // tasty.config.ts
461
+ export default {
462
+ tokens: ['#surface', '#text', '#primary', '$sidebar-width'],
463
+ states: ['@mobile', '@dark'],
464
+ presets: ['h1', 'h2', 't1', 't2'],
465
+ recipes: ['card', 'elevated'],
466
+ importSources: ['@my-org/ui'], // modules that re-export tasty()
467
+ };
468
+ ```
442
469
 
443
- ```tsx
444
- import { useStyles, useGlobalStyles, useRawCSS } from '@tenphi/tasty';
470
+ With that in place, `recommended` catches:
445
471
 
446
- function App() {
447
- const { className } = useStyles({ padding: '2x', fill: '#surface' });
448
- useGlobalStyles('body', { margin: '0' });
449
- useRawCSS('@font-face { font-family: "Custom"; src: url(...); }');
472
+ - Typos in property names (checked against the full CSS property set) and malformed values
473
+ - Unknown color tokens, units, presets, and recipes (plus `$` tokens and state aliases in `strict`)
474
+ - Invalid state keys, missing `''` defaults, nested state maps, and `!important`
475
+ - Raw colors and pixel lengths where tokens belong, and non-idiomatic syntax such as `calc(...)` or `display: 'none'`, some with autofixes
476
+ - `style`, `className`, and instance `styles` on Tasty components, in favor of their typed API
477
+ - Bad values in JSX style props, such as `<Box fill="red" gap="17px" />`
450
478
 
451
- return <main className={className}>...</main>;
452
- }
453
- ```
479
+ The same rule sets run under oxlint. See the [plugin README](https://github.com/tenphi/eslint-plugin-tasty) for every rule and option.
454
480
 
455
- ### Zero-Runtime Mode
481
+ ## CSS Coverage
456
482
 
457
- Extract all CSS at build time. Zero JavaScript overhead in production:
483
+ Every style property accepts a state map, and every kind of condition is a state key:
458
484
 
459
- ```tsx
460
- import { tastyStatic } from '@tenphi/tasty/static';
485
+ | State type | Syntax | CSS output |
486
+ | ---------------- | -------------------------- | ----------------------------------- |
487
+ | Boolean modifier | `loading` | `[data-loading]` |
488
+ | Value modifier | `theme=danger` | `[data-theme="danger"]` |
489
+ | Pseudo-class | `:hover` | `:hover` |
490
+ | Attribute | `[aria-selected="true"]` | `[aria-selected="true"]` |
491
+ | Class | `.is-active` | `.is-active` |
492
+ | Media query | `@media(w < 768px)` | `@media (width < 768px)` |
493
+ | Container query | `@(panel, w >= 300px)` | `@container panel (width >= 300px)` |
494
+ | Root state | `@root(schema=dark)` | `:root[data-schema="dark"]` |
495
+ | Parent state | `@parent(theme=danger)` | `:is([data-theme="danger"] *)` |
496
+ | Structural | `:has(> Icon)` | `:has(> [data-element="Icon"])` |
497
+ | Feature query | `@supports(display: grid)` | `@supports (display: grid)` |
498
+ | Entry animation | `@starting` | `@starting-style` |
461
499
 
462
- const card = tastyStatic({
463
- padding: '4x',
464
- fill: '#surface',
465
- radius: '1r',
466
- color: { '': '#text', '@dark': '#text-on-dark' },
467
- });
500
+ Combine them with `&` (and), `|` (or), `!` (not), and `^` (xor): `'theme=danger & :hover'`. The `_` key sets a fallback floor for queries a browser may evaluate as unknown. See [Style DSL](docs/dsl.md).
468
501
 
469
- // card is a CSS class name string
470
- <div className={card}>Static styles, zero runtime</div>
502
+ At-rules live next to the styles that use them:
503
+
504
+ ```tsx
505
+ const Spinner = tasty({
506
+ styles: {
507
+ '@keyframes': { spin: { to: { transform: 'rotate(360deg)' } } },
508
+ animation: 'spin 1s linear infinite',
509
+ },
510
+ });
471
511
  ```
472
512
 
473
- Configure the Babel plugin:
513
+ - **`@keyframes`**: inline, as above, or global via `configure({ keyframes })`.
514
+ - **`@property`**: inferred automatically when a custom property gets a concrete value, so custom properties can transition and animate with no boilerplate. Declare one explicitly to change `inherits` or the initial value.
515
+ - **`@font-face`** and **`@counter-style`**: in styles, in `configure()`, or with the matching style function.
516
+ - **`@function`**: define parameterized CSS functions as `$$name` and call them anywhere a value is accepted. An opt-in polyfill inlines the calls for browsers that do not support it yet.
474
517
 
475
- ```js
476
- module.exports = {
477
- plugins: [
478
- ['@tenphi/tasty/babel-plugin', {
479
- output: 'public/tasty.css',
480
- config: {
481
- states: { '@dark': '@root(theme=dark)' },
482
- },
483
- }],
484
- ],
485
- };
486
- ```
518
+ Tasty also ships its own style properties (`fill`, `flow`, `radius`, `preset`, `fade`, `scrollbar`, `hide`, and more), documented in [Style Properties](docs/styles.md). `@layer` and `!important` are intentionally left out: they would bring back the priority fights that state maps remove.
487
519
 
488
- ### `tasty` vs `tastyStatic`
520
+ ### Style functions
489
521
 
490
- | | `tasty` (runtime) | `tastyStatic` (zero-runtime) |
491
- |---|---|---|
492
- | **Output** | React component | CSS class name |
493
- | **CSS injection** | Runtime `<style>` tags | Build-time extraction |
494
- | **Runtime cost** | Style generation on mount | None |
495
- | **Generated CSS scope** | Only styles/variants used at runtime | All extracted static styles at build time |
496
- | **Dynamic values** | Fully supported | Via CSS custom properties |
497
- | **Sub-elements** | Built-in (`<C.Title>`) | Manual (`data-element`) |
498
- | **Variants** | Built-in (`variants` option) | Separate static styles |
499
- | **Framework** | React | Any (requires Babel) |
500
- | **Best for** | Interactive apps, design systems | Static sites, SSG, landing pages |
522
+ When you don't need a component, call the style functions directly: `useStyles` for a class name, `useGlobalStyles` for selector-scoped global CSS, `useRawCSS` for raw rules, plus `useKeyframes`, `useProperty`, `useFontFace`, `useCounterStyle`, and `useFunction`. All of them work in React Server Components. Apart from `useStyles`, which reads React context on the client, they are plain functions despite the `use` prefix, so they also work outside React; `computeStyles` is the hook-free equivalent of `useStyles`. See [React API — Style Functions](docs/react-api.md#style-functions).
501
523
 
502
- Both share the same DSL, tokens, units, state mappings, and recipes.
524
+ ## Rendering Modes
503
525
 
504
- ### Runtime Performance
526
+ The DSL, tokens, units, state maps, and recipes are the same everywhere. What changes is where CSS is generated:
505
527
 
506
- If you choose the runtime approach, performance is usually a non-issue in practice:
528
+ | Approach | Authoring API | CSS is generated | Tasty runtime in the browser | Best for |
529
+ | ------------------------- | ------------------------------------------- | ----------------------------------- | ---------------------------- | ---------------------------------------------------------------- |
530
+ | **Server-only React** | `tasty()` plus `@tenphi/tasty/ssr/*` | During server or static rendering | None | Astro without islands, server-only RSC, SSG |
531
+ | **Hydrated React** | `tasty()` plus `@tenphi/tasty/ssr/*` | During SSR, then on demand in React | Only in hydrated components | Interactive React apps, Next.js client components, Astro islands |
532
+ | **Build-time extraction** | `tastyStatic()` from `@tenphi/tasty/static` | During the build | None in file mode | Non-React frameworks, CSS needed before rendering |
507
533
 
508
- - CSS is generated and injected only when styles are actually used.
509
- - Multi-level caching avoids repeated parsing and style recomputation.
510
- - Styles are split into reusable chunks and applied as multiple class names, so matching chunks can be reused across components instead of re-injected.
511
- - Style normalization guarantees equivalent style input resolves to the same chunks, improving deduplication hit rates.
512
- - A style garbage collector removes unused styles/chunks over time.
513
- - A dedicated style injector minimizes DOM/style-tag overhead.
514
- - This approach is validated in enterprise-scale apps where runtime styling overhead is not noticeable in normal UI flows.
534
+ - **`tasty()` renders on the server.** Components are hook-free and render as React Server Components by default. Rendered only on the server, they keep the full React API (`styleProps`, sub-elements, variants) and ship no styling runtime. Astro's `tastyIntegration({ islands: false })` is the verified zero-JavaScript setup; server-only Next.js RSC follows the same architecture. Without an integration, each element inlines its own CSS, and configured tokens, global styles, and Tasty's default `@property` set are not emitted (Tasty warns in development), so use one for anything that relies on `configure()` or on those defaults.
535
+ - **SSR integrations** add CSS batching, cross-tree deduplication, FOUC prevention, and client cache hydration for apps that also render on the client: `TastyRegistry` from `@tenphi/tasty/ssr/next` (plus `withTastyNext()` from `@tenphi/tasty/ssr/next-config` for a shared global stylesheet), `tastyIntegration()` from `@tenphi/tasty/ssr/astro`, and a core API for other React SSR setups. Streaming is supported.
536
+ - **`tastyStatic()`** returns class names and extracts CSS during the build through a Babel plugin, with no React dependency. File mode ships no runtime; inject mode ships a tiny CSS injector.
515
537
 
516
- ### Server-Side Rendering (Experimental)
538
+ See [Server-Side Rendering](docs/ssr.md), [Build-Time Extraction](docs/tasty-static.md), and [Choosing a rendering mode](docs/getting-started.md#choosing-a-rendering-mode).
517
539
 
518
- SSR with zero-cost client hydration. Existing `tasty()` components work unchanged — SSR is opt-in and requires no per-component modifications. Supports Next.js (App Router with streaming), Astro (middleware + islands), and any React-based framework via the core API. Requires React 19+.
540
+ ## Tooling
519
541
 
520
- **Next.js setup:**
542
+ ### ESLint plugin
521
543
 
522
- ```tsx
523
- // app/tasty-registry.tsx
524
- 'use client';
544
+ Covered in [Types and Linting](#eslint-and-oxlint): 40+ rules for ESLint 9+ and oxlint, configured from `tasty.config.ts`.
525
545
 
526
- import { TastyRegistry } from '@tenphi/tasty/ssr/next';
546
+ ### VS Code extension
527
547
 
528
- export default function TastyStyleRegistry({
529
- children,
530
- }: {
531
- children: React.ReactNode;
532
- }) {
533
- return <TastyRegistry>{children}</TastyRegistry>;
534
- }
548
+ [Tasty for VS Code](https://github.com/tenphi/tasty-vscode-extension) highlights color tokens, units, state keys, presets, and style properties inside `tasty()`, `tastyStatic()`, `styles` objects, and style functions, and adds snippets for components, state maps, and `configure()`. Install the `.vsix` from the [latest release](https://github.com/tenphi/tasty-vscode-extension/releases/latest).
549
+
550
+ <p align="center">
551
+ <img src="assets/tasty-vscode-highlight.png" width="512" alt="Tasty VS Code syntax highlighting example" />
552
+ </p>
553
+
554
+ ### Glaze
555
+
556
+ [`@tenphi/glaze`](https://github.com/tenphi/glaze) generates light, dark, and high-contrast themes from one hue in the OKHST color space, solves WCAG and APCA contrast, and exports Tasty tokens directly (as well as CSS, DTCG, and Tailwind):
557
+
558
+ ```ts
559
+ import { glaze } from '@tenphi/glaze';
560
+ import { configure } from '@tenphi/tasty';
561
+
562
+ const theme = glaze(280, 80); // hue, saturation
563
+ theme.colors({
564
+ surface: { tone: 97, saturation: 0.15 },
565
+ text: { base: 'surface', tone: '-1', contrast: 'AA' },
566
+ });
567
+
568
+ configure({ tokens: theme.tasty() }); // #surface and #text, light and dark
535
569
  ```
536
570
 
537
- ```tsx
538
- // app/layout.tsx
539
- import TastyStyleRegistry from './tasty-registry';
540
-
541
- export default function RootLayout({
542
- children,
543
- }: {
544
- children: React.ReactNode;
545
- }) {
546
- return (
547
- <html>
548
- <body>
549
- <TastyStyleRegistry>{children}</TastyStyleRegistry>
550
- </body>
551
- </html>
552
- );
553
- }
571
+ ### Debugging
572
+
573
+ `tastyDebug` inspects what Tasty injected, straight from the browser console:
574
+
575
+ ```ts
576
+ import { tastyDebug } from '@tenphi/tasty';
577
+
578
+ tastyDebug.install(); // exposes window.tastyDebug
579
+ tastyDebug.inspect('.my-button'); // classes, chunks, and the CSS that applies
554
580
  ```
555
581
 
556
- See the [full SSR guide](docs/ssr.md) for Astro integration, streaming SSR, generic framework usage, and the complete API reference.
582
+ See [Debug Utilities](docs/debug.md).
557
583
 
558
- ## Entry Points
584
+ ### AI coding agents
559
585
 
560
- | Import | Description | Platform |
561
- |--------|-------------|----------|
562
- | `@tenphi/tasty` | Runtime style engine (`tasty`, hooks, `configure`) | Browser |
563
- | `@tenphi/tasty/static` | Zero-runtime static styles (`tastyStatic`) | Browser |
564
- | `@tenphi/tasty/core` | Lower-level internals (config, parser, pipeline, injector, style handlers) for tooling and advanced use | Browser / Node |
565
- | `@tenphi/tasty/babel-plugin` | Babel plugin for zero-runtime CSS extraction | Node |
566
- | `@tenphi/tasty/zero` | Programmatic extraction API | Node |
567
- | `@tenphi/tasty/next` | Next.js integration wrapper | Node |
568
- | `@tenphi/tasty/ssr` | Core SSR API (collector, context, hydration) | Node |
569
- | `@tenphi/tasty/ssr/next` | Next.js App Router SSR integration | Node |
570
- | `@tenphi/tasty/ssr/astro` | Astro middleware + auto-hydration | Node / Browser |
586
+ Style definitions are declarative and fully typed, so agents can read and write them reliably. [Style Rules for AI Agents](docs/ai-agents.md) is a one-page brief to add to an agent's context.
571
587
 
572
- ## Ecosystem
588
+ ## Performance
573
589
 
574
- Tasty is the core of a production-ready styling platform. These companion tools complete the picture:
590
+ ### Bundle size
575
591
 
576
- ### [ESLint Plugin](https://github.com/tenphi/eslint-plugin-tasty)
592
+ Measured with [size-limit](https://github.com/ai/size-limit): minified and brotli-compressed, including all dependencies.
577
593
 
578
- `@tenphi/eslint-plugin-tasty` — 27 lint rules that validate style property names, value syntax, token existence, state keys, and enforce best practices. Catch typos and invalid styles at lint time, not at runtime.
594
+ | Entry point | Size |
595
+ | ------------------------------------------------- | -------- |
596
+ | `@tenphi/tasty`, importing `tasty` | 52.26 kB |
597
+ | `@tenphi/tasty`, everything | 58.9 kB |
598
+ | `@tenphi/tasty/core`, everything (no SSR) | 55.2 kB |
599
+ | `@tenphi/tasty/static` (build-time authoring API) | 920 B |
600
+ | `@tenphi/tasty/ssr/client` | 277 B |
601
+ | `@tenphi/tasty/ssr/astro-client` | 283 B |
602
+ | `@tenphi/tasty/zero` (Node, build time) | 38.87 kB |
603
+ | `@tenphi/tasty/babel-plugin` (Node, build time) | 43.05 kB |
579
604
 
580
- ```bash
581
- pnpm add -D @tenphi/eslint-plugin-tasty
582
- ```
605
+ Run `pnpm size` to reproduce; numbers shift slightly between releases.
583
606
 
584
- ```js
585
- import tasty from '@tenphi/eslint-plugin-tasty';
586
- export default [tasty.configs.recommended];
587
- ```
607
+ ### Runtime
588
608
 
589
- ### [Glaze](https://github.com/tenphi/glaze)
609
+ When styles are generated in the browser:
590
610
 
591
- `@tenphi/glaze` — OKHSL-based color theme generator with automatic WCAG contrast solving. Generate light, dark, and high-contrast palettes from a single hue, and export them directly as Tasty color tokens.
611
+ - CSS is generated and injected only for styles that are actually rendered.
612
+ - Styles are split into chunks and normalized, so equivalent styles resolve to the same classes and are reused across components instead of re-injected.
613
+ - Multi-level caching avoids re-parsing and recomputation.
614
+ - Unused styles can be garbage-collected over time with `configure({ gc })`, or on demand with `gc()` and `cleanup()`.
615
+ - Optional [batched injection](docs/configuration.md#batched-injection) groups stylesheet writes before layout reads.
616
+ - The approach runs in enterprise-scale apps where runtime styling overhead is not noticeable in normal UI flows.
592
617
 
593
- ```tsx
594
- import { glaze } from '@tenphi/glaze';
618
+ Reproducible benchmarks cover the core pipeline, the React overhead of an empty `tasty({})` wrapper, cold generation and injection against equivalent precompiled CSS, steady-state interactions, and page-load cold start. See [Runtime Benchmarks](docs/runtime-benchmarks.md) for methodology and results.
595
619
 
596
- const theme = glaze(280, 80);
597
- theme.colors({
598
- surface: { lightness: 97 },
599
- text: { base: 'surface', lightness: '-52', contrast: 'AAA' },
600
- });
620
+ ## Browser Support
601
621
 
602
- const tokens = theme.tasty(); // Ready-to-use Tasty tokens
603
- ```
622
+ Exclusive selectors rely on `:is()`, `:where()`, and level-4 `:not()` with selector lists: Chrome and Edge 88+, Firefox 84+, Safari 14+. Internet Explorer is not supported.
604
623
 
605
- ### [VS Code Extension](https://github.com/tenphi/tasty-vscode-extension)
624
+ The defaults that style handlers read, such as the `#border` color and the `$transition` duration, are registered with `@property` (Chrome and Edge 85+, Firefox 128+, Safari 16.4+). For older engines, define those tokens yourself; see [Default properties](docs/dsl.md#default-properties).
606
625
 
607
- Syntax highlighting for Tasty styles in TypeScript, TSX, JavaScript, and JSX. Highlights color tokens, custom units, state keys, presets, and style properties inside `tasty()`, `tastyStatic()`, and related APIs.
626
+ ## Entry Points
608
627
 
609
- <p align="center">
610
- <img src="assets/tasty-vscode-highlight.png" width="512" alt="Tasty VS Code syntax highlighting example">
611
- </p>
628
+ | Import | Description | Platform |
629
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------- | -------------- |
630
+ | `@tenphi/tasty` | React style engine (`tasty`, style functions, `configure`) | Browser / Node |
631
+ | `@tenphi/tasty/core` | Lower-level internals (config, parser, pipeline, injector, style handlers) for tooling and advanced use | Browser / Node |
632
+ | `@tenphi/tasty/static` | Build-time extraction authoring API (`tastyStatic`) | Build time |
633
+ | `@tenphi/tasty/static/inject` | Runtime helper the Babel plugin rewrites `tastyStatic` imports to in inject mode | Browser |
634
+ | `@tenphi/tasty/babel-plugin` | Babel plugin for build-time CSS extraction | Node |
635
+ | `@tenphi/tasty/zero` | Programmatic extraction API | Node |
636
+ | `@tenphi/tasty/zero/next` | Next.js wrapper for build-time extraction | Node |
637
+ | `@tenphi/tasty/ssr` | Core SSR API (collector, context, hydration) | Node |
638
+ | `@tenphi/tasty/ssr/next` | Next.js App Router SSR integration (`TastyRegistry`) | Node |
639
+ | `@tenphi/tasty/ssr/next-config` | Next.js config wrapper for a shared global stylesheet (`withTastyNext`) | Node |
640
+ | `@tenphi/tasty/ssr/astro` | Astro integration and middleware | Node |
641
+ | `@tenphi/tasty/ssr/client` | Browser-safe SSR hydration for any framework (`hydrateTastyClasses`) | Browser |
642
+ | `@tenphi/tasty/ssr/astro-client` | Astro client-side cache hydration | Browser |
612
643
 
613
644
  ## Built with Tasty
614
645
 
615
646
  ### [tasty.style](https://tasty.style) ([source](https://github.com/tenphi/tasty.style))
616
647
 
617
- The official Tasty documentation and landing page — itself built entirely with Tasty. A showcase for zero-runtime styling via `tastyStatic`, SSR with Next.js, and OKHSL color theming with Glaze.
648
+ The official Tasty documentation and landing page — itself built entirely with `tasty()`. A showcase for server-rendered Tasty with Next.js and OKHST color theming with Glaze.
649
+
650
+ ### [Cookbook](https://cookbook.tenphi.me) ([source](https://github.com/tenphi/cookbook))
651
+
652
+ `@tenphi/cookbook` builds a static Astro documentation site from your repository or a published npm package. Brand colors, semantic palettes, fonts, typography, and individual component parts are configured through Tasty and Glaze, so the docs match your product.
618
653
 
619
654
  ### [Cube Cloud](https://cube.dev/)
620
655
 
@@ -630,36 +665,43 @@ Open-source React UI kit built on Tasty + React Aria. 100+ production components
630
665
 
631
666
  ## Documentation
632
667
 
633
- ### Start here
668
+ The [Docs Hub](docs/README.md) routes you by role, rendering mode, and task.
669
+
670
+ **Start here**
634
671
 
635
- - **[Getting Started](docs/getting-started.md)** — Installation, first component, configuration, ESLint plugin setup, editor tooling, and rendering mode decision tree
636
- - **[Methodology](docs/methodology.md)** — The recommended patterns for structuring Tasty components: root + sub-elements, styleProps, tokens, styles vs style, wrapping and extension
672
+ - [Getting Started](docs/getting-started.md) — Install, first component, shared configuration, ESLint, editor tooling, and choosing a rendering mode
673
+ - [Methodology](docs/methodology.md) — The recommended component model: root + sub-elements, `styleProps`, tokens, `styles` vs `style`, wrapping and extension
637
674
 
638
- ### Guides
675
+ **Guides**
639
676
 
640
- - **[Building a Design System](docs/design-system.md)** — Practical guide to building a DS layer: token vocabulary, state aliases, recipes, primitives, compound components, override contracts
641
- - **[Adoption Guide](docs/adoption.md)** — Where Tasty sits in the stack, who should adopt it, what you define yourself, and how to introduce it incrementally into an existing design system
677
+ - [Building a Design System](docs/design-system.md) — Token vocabulary, state aliases, recipes, primitives, compound components, and override contracts
678
+ - [Adoption Guide](docs/adoption.md) — Where Tasty fits, who should adopt it, and how to introduce it incrementally
679
+ - [Comparison](docs/comparison.md) — Tasty next to Tailwind, Panda CSS, vanilla-extract, StyleX, Stitches, and Emotion
642
680
 
643
- ### Reference
681
+ **Reference**
644
682
 
645
- - **[Style DSL](docs/dsl.md)** — The Tasty style language: state maps, tokens, units, color syntax, extending semantics, recipes, keyframes, and @property
646
- - **[Runtime API](docs/runtime.md)** — React-specific API: `tasty()` factory, component props, variants, sub-elements, and hooks
647
- - **[Configuration](docs/configuration.md)** — Global configuration: tokens, recipes, custom units, style handlers, and TypeScript extensions
648
- - **[Style Properties](docs/styles.md)** — Complete reference for all enhanced style properties: syntax, values, modifiers, and recommendations
683
+ - [Style DSL](docs/dsl.md) — State maps, tokens, units, colors, extending semantics, recipes, and at-rules
684
+ - [Style Properties](docs/styles.md) — Every enhanced style property: syntax, values, and modifiers
685
+ - [React API](docs/react-api.md) — `tasty()`, component props, variants, sub-elements, and style functions
686
+ - [Configuration](docs/configuration.md) — Everything `configure()` accepts
687
+ - [Plugins & Extension Points](docs/plugins.md) — Custom style handlers, props middleware, and typing your extension
688
+ - [Style Rules for AI Agents](docs/ai-agents.md) — A condensed brief for writing correct styles
649
689
 
650
- ### Rendering modes
690
+ **Rendering modes**
651
691
 
652
- - **[Zero Runtime (tastyStatic)](docs/tasty-static.md)** — Build-time static styling: Babel plugin setup, Next.js integration, and static style patterns
653
- - **[Server-Side Rendering](docs/ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks: streaming support, cache hydration, and troubleshooting
692
+ - [Server-Side Rendering](docs/ssr.md) — Next.js, Astro, and generic React SSR: streaming, cache hydration, and troubleshooting
693
+ - [Build-Time Extraction (`tastyStatic`)](docs/tasty-static.md) — Babel plugin setup, Next.js integration, and static style patterns
654
694
 
655
- ### Internals
695
+ **Internals**
656
696
 
657
- - **[Style Injector](docs/injector.md)** — Internal CSS injection engine: `inject()`, `injectGlobal()`, `injectRawCSS()`, `keyframes()`, deduplication, reference counting, cleanup, SSR support, and Shadow DOM
658
- - **[Debug Utilities](docs/debug.md)** — Runtime CSS inspection via `tastyDebug`: CSS extraction, element inspection, cache metrics, chunk breakdown, and performance monitoring
697
+ - [Style rendering pipeline](docs/pipeline.md) — How state maps become mutually exclusive CSS rules
698
+ - [Style Injector](docs/injector.md) — Deduplication, reference counting, cleanup, SSR, and Shadow DOM
699
+ - [Debug Utilities](docs/debug.md) — Inspecting CSS, elements, caches, and chunks at runtime
700
+ - [Runtime Benchmarks](docs/runtime-benchmarks.md) — Methodology and results
659
701
 
660
- ### Context
702
+ **Upgrading**
661
703
 
662
- - **[Comparison](docs/comparison.md)** — How Tasty compares to Tailwind, Panda CSS, vanilla-extract, StyleX, Stitches, and Emotion: positioning, trade-offs, and when each tool fits best
704
+ - [Migration Guide (v2 → v3)](docs/migration-v3.md) — Every breaking change in 3.0, with a search-and-replace cheat sheet
663
705
 
664
706
  ## License
665
707