@tenphi/tasty 0.0.0-snapshot.1c5dff6 → 0.0.0-snapshot.1f1c00a

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 (331) hide show
  1. package/README.md +377 -238
  2. package/dist/babel-rZcEwPLM.d.ts +82 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/chunks/collector-D2ARGT2L.js +208 -0
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/collector-w4mBj5gd.d.ts +164 -0
  34. package/dist/config-CZWCzBr6.d.ts +1349 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-G9JuwM9p.d.ts +1920 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +6 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +18 -0
  54. package/dist/ssr/astro-middleware.js +7 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +127 -0
  57. package/dist/ssr/astro.js +221 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +36 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +128 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +46 -0
  66. package/dist/ssr/next.js +60 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +90 -5
  69. package/dist/static/index.js +31 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +4 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-JEY8PVYP.d.ts +1567 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +230 -106
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +80 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +57 -33
  81. package/dist/zero/next.js +93 -59
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +684 -56
  88. package/docs/debug.md +170 -343
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1065 -0
  91. package/docs/getting-started.md +240 -0
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +765 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +683 -0
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +211 -63
  101. package/docs/tasty-static.md +273 -67
  102. package/package.json +182 -58
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -417
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -856
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -451
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -221
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -23
  256. package/dist/styles/scrollbar.js +0 -34
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/selector-transform.js +0 -32
  314. package/dist/utils/selector-transform.js.map +0 -1
  315. package/dist/utils/string.js +0 -8
  316. package/dist/utils/string.js.map +0 -1
  317. package/dist/utils/styles.d.ts +0 -177
  318. package/dist/utils/styles.js +0 -730
  319. package/dist/utils/styles.js.map +0 -1
  320. package/dist/utils/typography.d.ts +0 -36
  321. package/dist/utils/typography.js +0 -53
  322. package/dist/utils/typography.js.map +0 -1
  323. package/dist/utils/warnings.d.ts +0 -16
  324. package/dist/utils/warnings.js +0 -16
  325. package/dist/utils/warnings.js.map +0 -1
  326. package/dist/zero/css-writer.d.ts +0 -45
  327. package/dist/zero/css-writer.js +0 -74
  328. package/dist/zero/css-writer.js.map +0 -1
  329. package/dist/zero/extractor.d.ts +0 -24
  330. package/dist/zero/extractor.js.map +0 -1
  331. package/docs/usage.md +0 -695
@@ -0,0 +1,455 @@
1
+ # Building a Design System
2
+
3
+ This guide shows how to build shared React components whose styles stay predictable as states, variants, themes, and responsive rules accumulate. You will define tokens, state aliases, recipes, primitive APIs, and compound components with sub-elements.
4
+
5
+ It assumes you have already decided to adopt Tasty. The goal is not only to centralize values, but to give your design system one state model and a governed component-facing styling API. For evaluation criteria and incremental rollout, see the [Adoption Guide](adoption.md). For the recommended component architecture, see [Methodology](methodology.md).
6
+
7
+ ---
8
+
9
+ ## Designing your token vocabulary
10
+
11
+ Tokens are the foundation of a design system. In Tasty, tokens are defined via `configure({ tokens })` and referenced in styles with `#name` (colors) or `$name` (values). See [Configuration — Design Tokens](configuration.md#design-tokens) for the API.
12
+
13
+ ### Color tokens
14
+
15
+ Adopt a semantic naming convention that maps intent, not visual appearance. Define tokens via `configure({ tokens })`:
16
+
17
+ ```tsx
18
+ import { configure } from '@tenphi/tasty';
19
+
20
+ configure({
21
+ tokens: {
22
+ // Surfaces
23
+ '#surface': '#fff',
24
+ '#surface-hover': '#f5f5f5',
25
+ '#surface-pressed': '#ebebeb',
26
+
27
+ // Primary action
28
+ '#primary': 'oklch(55% 0.25 265)',
29
+ '#primary-hover': 'oklch(50% 0.25 265)',
30
+ '#primary-pressed': 'oklch(45% 0.25 265)',
31
+ '#on-primary': '#fff',
32
+
33
+ // Semantic
34
+ '#danger': 'oklch(55% 0.22 25)',
35
+ '#danger-hover': 'oklch(50% 0.22 25)',
36
+ '#on-danger': '#fff',
37
+
38
+ // Text
39
+ '#text': '#111',
40
+ '#text-secondary': '#666',
41
+
42
+ // Borders
43
+ '#border': '#e0e0e0',
44
+
45
+ // Unit values
46
+ $gap: '8px',
47
+ $radius: '4px',
48
+ '$border-width': '1px',
49
+ '$outline-width': '2px',
50
+ },
51
+ });
52
+ ```
53
+
54
+ Tokens are injected as CSS custom properties on `:root` when the first style is rendered. They support state maps for theme-aware values:
55
+
56
+ ```tsx
57
+ configure({
58
+ tokens: {
59
+ '#primary': {
60
+ '': 'oklch(55% 0.25 265)',
61
+ '@dark': 'oklch(75% 0.2 265)',
62
+ },
63
+ },
64
+ });
65
+ ```
66
+
67
+ The `#on-*` convention names the text color that sits on top of a fill — `#on-primary` is the text color on a `#primary` background. This makes state maps self-documenting: `fill: '#primary'` and `color: '#on-primary'` clearly belong together.
68
+
69
+ For OKHSL-based palette generation with automatic WCAG contrast solving, see [Glaze](https://github.com/tenphi/glaze).
70
+
71
+ ### Replace tokens for value aliases
72
+
73
+ `configure({ replaceTokens })` replaces tokens with literal values at parse time, baking them into the generated CSS. Use it for value aliases that should be inlined during style generation:
74
+
75
+ ```tsx
76
+ configure({
77
+ replaceTokens: {
78
+ '$card-padding': '4x',
79
+ '$input-height': '5x',
80
+ '$sidebar-width': '280px',
81
+ },
82
+ });
83
+ ```
84
+
85
+ ### Typography presets
86
+
87
+ Pass typography presets directly to `configure()` — they are converted to tokens automatically:
88
+
89
+ ```tsx
90
+ import { configure } from '@tenphi/tasty';
91
+
92
+ configure({
93
+ presets: {
94
+ h1: {
95
+ fontSize: '2rem',
96
+ lineHeight: '1.2',
97
+ letterSpacing: '-0.02em',
98
+ fontWeight: 700,
99
+ },
100
+ t2: {
101
+ fontSize: '0.875rem',
102
+ lineHeight: '1.5',
103
+ letterSpacing: 'normal',
104
+ fontWeight: 400,
105
+ },
106
+ },
107
+ });
108
+ ```
109
+
110
+ Preset values support state maps for responsive or theme-aware typography:
111
+
112
+ ```tsx
113
+ configure({
114
+ presets: {
115
+ t2: {
116
+ fontSize: '0.875rem',
117
+ lineHeight: '1.5',
118
+ fontWeight: { '': 400, '@dark': 300 },
119
+ },
120
+ },
121
+ });
122
+ ```
123
+
124
+ Then use `preset: 'h1'` or `preset: 't2'` in any component's styles.
125
+
126
+ > You can also call `generateTypographyTokens()` manually and spread the result into `tokens` for more control — `presets` is just a shorthand.
127
+
128
+ ### Registering brand fonts
129
+
130
+ Register your design system's custom fonts via `configure({ fontFaces })` so every component can reference them:
131
+
132
+ ```ts
133
+ configure({
134
+ fontFaces: {
135
+ 'Brand Sans': [
136
+ {
137
+ src: 'url("/fonts/brand-regular.woff2") format("woff2")',
138
+ fontWeight: 400,
139
+ fontDisplay: 'swap',
140
+ },
141
+ {
142
+ src: 'url("/fonts/brand-bold.woff2") format("woff2")',
143
+ fontWeight: 700,
144
+ fontDisplay: 'swap',
145
+ },
146
+ ],
147
+ },
148
+ });
149
+ ```
150
+
151
+ See [Font Face](configuration.md#font-face) for the full configuration reference.
152
+
153
+ ---
154
+
155
+ ## Defining state aliases
156
+
157
+ State aliases let you write `@mobile` instead of `@media(w < 768px)` in every component. Define them once in `configure()`:
158
+
159
+ ```tsx
160
+ configure({
161
+ states: {
162
+ '@mobile': '@media(w < 768px)',
163
+ '@tablet': '@media(768px <= w < 1024px)',
164
+ '@desktop': '@media(w >= 1024px)',
165
+ '@dark':
166
+ '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
167
+ '@reduced-motion': '@media(prefers-reduced-motion: reduce)',
168
+ },
169
+ });
170
+ ```
171
+
172
+ Every component can now use these without repeating the query logic:
173
+
174
+ ```tsx
175
+ const Card = tasty({
176
+ styles: {
177
+ padding: { '': '4x', '@mobile': '2x' },
178
+ flow: { '': 'row', '@mobile': 'column' },
179
+ fill: { '': '#surface', '@dark': '#surface-dark' },
180
+ },
181
+ });
182
+ ```
183
+
184
+ Without aliases, the same component would need the full media query expression inlined in every state map — across every property, in every component. Aliases eliminate that duplication.
185
+
186
+ ---
187
+
188
+ ## Creating recipes
189
+
190
+ Recipes are named style bundles for patterns that repeat across components. Define them in `configure()`:
191
+
192
+ ```tsx
193
+ configure({
194
+ recipes: {
195
+ card: {
196
+ padding: '4x',
197
+ fill: '#surface',
198
+ radius: '1r',
199
+ border: true,
200
+ },
201
+ elevated: {
202
+ shadow: '0 2x 4x #shadow',
203
+ },
204
+ 'input-reset': {
205
+ border: 'none',
206
+ outline: 'none',
207
+ fill: '#clear',
208
+ font: true,
209
+ preset: 't3',
210
+ },
211
+ interactive: {
212
+ cursor: { '': 'pointer', disabled: 'not-allowed' },
213
+ opacity: { '': '1', disabled: '.5' },
214
+ transition: 'theme',
215
+ },
216
+ },
217
+ });
218
+ ```
219
+
220
+ Components reference recipes by name. This keeps component definitions lean while ensuring consistency:
221
+
222
+ ```tsx
223
+ const ProfileCard = tasty({
224
+ styles: {
225
+ recipe: 'card elevated',
226
+ color: '#text',
227
+ Title: { preset: 'h3', color: '#primary' },
228
+ },
229
+ elements: { Title: 'h2' },
230
+ });
231
+ ```
232
+
233
+ Use the `/` separator when a recipe should be applied _after_ local styles (post-merge), so recipe states take priority:
234
+
235
+ ```tsx
236
+ const Input = tasty({
237
+ styles: {
238
+ recipe: 'input-reset / interactive',
239
+ padding: '1.5x 2x',
240
+ border: '1bw solid #border',
241
+ },
242
+ });
243
+ ```
244
+
245
+ See [Configuration — Recipes](configuration.md#recipes) for the API and [Style DSL — Recipes](dsl.md#recipes) for composition patterns.
246
+
247
+ ---
248
+
249
+ ## Building primitive components
250
+
251
+ Primitives are the layout and utility components that product engineers compose. They expose a controlled set of style props and have minimal opinions about appearance.
252
+
253
+ ### Layout primitives
254
+
255
+ ```tsx
256
+ import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
257
+
258
+ const Space = tasty({
259
+ as: 'div',
260
+ styles: {
261
+ display: 'flex',
262
+ flow: 'column',
263
+ gap: '1x',
264
+ },
265
+ styleProps: FLOW_STYLES,
266
+ });
267
+
268
+ const Box = tasty({
269
+ as: 'div',
270
+ styles: {
271
+ display: 'block',
272
+ },
273
+ styleProps: [...FLOW_STYLES, ...POSITION_STYLES, 'padding', 'fill', 'radius'],
274
+ });
275
+
276
+ const Grid = tasty({
277
+ as: 'div',
278
+ styles: {
279
+ display: 'grid',
280
+ gap: '1x',
281
+ },
282
+ styleProps: [...FLOW_STYLES, 'gridColumns', 'gridRows', 'gridAreas'],
283
+ });
284
+ ```
285
+
286
+ Product engineers use these to compose layouts without writing CSS:
287
+
288
+ ```tsx
289
+ <Space flow="row" gap="2x" placeItems="center">
290
+ <Title>Dashboard</Title>
291
+ <Button placeSelf="end">Add Item</Button>
292
+ </Space>
293
+
294
+ <Grid gridColumns={{ '': '1fr', '@tablet': '1fr 1fr', '@desktop': '1fr 1fr 1fr' }} gap="3x">
295
+ <Card>...</Card>
296
+ <Card>...</Card>
297
+ <Card>...</Card>
298
+ </Grid>
299
+ ```
300
+
301
+ ### Which styleProps to expose
302
+
303
+ Match the prop set to the component's role:
304
+
305
+ | Component category | Recommended styleProps |
306
+ | ------------------------------------------ | -------------------------------------------------------------- |
307
+ | Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align, justify, padding, fill |
308
+ | Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order |
309
+ | Text elements | `['preset', 'color']` or a custom subset |
310
+ | Compound components | Typically none — styling happens via sub-elements and wrapping |
311
+
312
+ Exposing too many props weakens the design system's constraints. See [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api) for the rationale.
313
+
314
+ ---
315
+
316
+ ## Building compound components
317
+
318
+ Compound components have inner parts — a card has a title, content, and footer; a dialog has a header, body, and actions. Tasty models these as sub-elements.
319
+
320
+ ```tsx
321
+ const Card = tasty({
322
+ styles: {
323
+ recipe: 'card',
324
+ flow: 'column',
325
+ gap: '2x',
326
+
327
+ Title: {
328
+ preset: 'h3',
329
+ color: '#primary',
330
+ },
331
+ Content: {
332
+ preset: 't2',
333
+ color: '#text',
334
+ },
335
+ Footer: {
336
+ display: 'flex',
337
+ flow: 'row',
338
+ gap: '1x',
339
+ justify: 'flex-end',
340
+ padding: '2x top',
341
+ border: '1bw solid #border top',
342
+ },
343
+ },
344
+ elements: {
345
+ Title: 'h2',
346
+ Content: 'div',
347
+ Footer: 'div',
348
+ },
349
+ });
350
+ ```
351
+
352
+ Usage:
353
+
354
+ ```tsx
355
+ <Card>
356
+ <Card.Title>Monthly Revenue</Card.Title>
357
+ <Card.Content>$1.2M — up 12% from last month.</Card.Content>
358
+ <Card.Footer>
359
+ <Button>Details</Button>
360
+ </Card.Footer>
361
+ </Card>
362
+ ```
363
+
364
+ Sub-elements share the root component's state context by default. A `disabled` modifier on `<Card>` affects `Title`, `Content`, and `Footer` styles automatically — no prop drilling. For the full mental model, see [Methodology — Component architecture](methodology.md#component-architecture-root--sub-elements).
365
+
366
+ For sub-element syntax details (selector affix `$`, `@own()`, `elements` config), see [React API — Sub-element Styling](react-api.md#sub-element-styling).
367
+
368
+ ---
369
+
370
+ ## Defining the override contract
371
+
372
+ A design system works best when the rules for customization are explicit. Tasty provides three levels of control:
373
+
374
+ ### What product engineers can do
375
+
376
+ 1. **Use styleProps** — adjust layout, spacing, positioning through the props the component exposes:
377
+
378
+ ```tsx
379
+ <Space flow="row" gap="3x" padding="2x">
380
+ ```
381
+
382
+ 2. **Use modProps** — control component states through typed props instead of `mods`:
383
+
384
+ ```tsx
385
+ <Button isLoading size="large">
386
+ Submit
387
+ </Button>
388
+ ```
389
+
390
+ 3. **Pass tokens** — inject runtime values through the `tokens` prop for per-instance customization:
391
+
392
+ ```tsx
393
+ <ProgressBar tokens={{ $progress: `${percent}%` }} />
394
+ ```
395
+
396
+ 4. **Create styled wrappers** — extend a component's styles with `tasty(Base, { styles })`:
397
+
398
+ ```tsx
399
+ const DangerButton = tasty(Button, {
400
+ styles: {
401
+ fill: { '': '#danger', ':hover': '#danger-hover' },
402
+ color: '#on-danger',
403
+ },
404
+ });
405
+ ```
406
+
407
+ ### What to discourage
408
+
409
+ - **Direct `styles` prop** — bypasses the component's intended API; prefer styled wrappers
410
+ - **`style` prop** — React inline styles that bypass Tasty entirely; reserve for third-party integration only
411
+ - **Overriding internal sub-elements** — if product engineers need to restyle sub-elements, the DS component should expose that through its own API (additional props or variants), not through raw `styles` overrides
412
+
413
+ See [Methodology — styles prop vs style prop](methodology.md#styles-prop-vs-style-prop) and [Methodology — Wrapping and extension](methodology.md#wrapping-and-extension) for the full rationale.
414
+
415
+ ---
416
+
417
+ ## Project structure
418
+
419
+ A recommended structure for a design system built on Tasty:
420
+
421
+ ```
422
+ ds/
423
+ config.ts # configure() — tokens, units, states, recipes
424
+ primitives/
425
+ Space.tsx # Layout: flex container with FLOW_STYLES
426
+ Box.tsx # Generic container
427
+ Grid.tsx # Grid container
428
+ Text.tsx # Text element with preset + color
429
+ components/
430
+ Button.tsx # Interactive component with variants
431
+ Card.tsx # Compound component with sub-elements
432
+ Input.tsx # Form input with recipes
433
+ Dialog.tsx # Overlay compound component
434
+ recipes/
435
+ index.ts # Recipe definitions (imported by config.ts)
436
+ tokens/
437
+ colors.ts # Color token definitions
438
+ typography.ts # Typography presets for configure({ presets })
439
+ spacing.ts # Spacing token definitions
440
+ index.ts # Public API: re-exports components + configure
441
+ ```
442
+
443
+ The key principle: `config.ts` imports tokens and recipes, calls `configure()`, and is imported at the app entry point before any component renders. Components import only from `@tenphi/tasty` — they reference tokens and recipes by name, not by import.
444
+
445
+ ---
446
+
447
+ ## Learn more
448
+
449
+ - **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components
450
+ - **[Getting Started](getting-started.md)** — Installation, first component, tooling setup
451
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
452
+ - **[React API](react-api.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
453
+ - **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers
454
+ - **[Adoption Guide](adoption.md)** — Who should adopt Tasty, incremental phases, what changes for product engineers
455
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties