@tenphi/tasty 0.0.0-snapshot.05c1c22

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 (314) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +629 -0
  3. package/dist/_virtual/_rolldown/runtime.js +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +77 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +258 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +1 -0
  11. package/dist/chunks/renderChunk.d.ts +1 -0
  12. package/dist/chunks/renderChunk.js +59 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +366 -0
  15. package/dist/config.js +503 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/core/index.d.ts +33 -0
  18. package/dist/core/index.js +26 -0
  19. package/dist/counter-style/index.js +51 -0
  20. package/dist/counter-style/index.js.map +1 -0
  21. package/dist/debug.d.ts +89 -0
  22. package/dist/debug.js +453 -0
  23. package/dist/debug.js.map +1 -0
  24. package/dist/font-face/index.js +63 -0
  25. package/dist/font-face/index.js.map +1 -0
  26. package/dist/hooks/index.d.ts +7 -0
  27. package/dist/hooks/resolve-ssr-collector.js +14 -0
  28. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  29. package/dist/hooks/useCounterStyle.d.ts +50 -0
  30. package/dist/hooks/useCounterStyle.js +46 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +43 -0
  33. package/dist/hooks/useFontFace.js +70 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +30 -0
  36. package/dist/hooks/useGlobalStyles.js +78 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +64 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +109 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +35 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +45 -0
  48. package/dist/hooks/useStyles.js +237 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +50 -0
  51. package/dist/index.js +35 -0
  52. package/dist/injector/index.d.ts +183 -0
  53. package/dist/injector/index.js +179 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +166 -0
  56. package/dist/injector/injector.js +464 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/sheet-manager.d.ts +136 -0
  59. package/dist/injector/sheet-manager.js +733 -0
  60. package/dist/injector/sheet-manager.js.map +1 -0
  61. package/dist/injector/types.d.ts +204 -0
  62. package/dist/keyframes/index.js +206 -0
  63. package/dist/keyframes/index.js.map +1 -0
  64. package/dist/parser/classify.js +319 -0
  65. package/dist/parser/classify.js.map +1 -0
  66. package/dist/parser/const.js +49 -0
  67. package/dist/parser/const.js.map +1 -0
  68. package/dist/parser/lru.js +109 -0
  69. package/dist/parser/lru.js.map +1 -0
  70. package/dist/parser/parser.d.ts +25 -0
  71. package/dist/parser/parser.js +115 -0
  72. package/dist/parser/parser.js.map +1 -0
  73. package/dist/parser/tokenizer.js +69 -0
  74. package/dist/parser/tokenizer.js.map +1 -0
  75. package/dist/parser/types.d.ts +51 -0
  76. package/dist/parser/types.js +46 -0
  77. package/dist/parser/types.js.map +1 -0
  78. package/dist/pipeline/conditions.d.ts +134 -0
  79. package/dist/pipeline/conditions.js +406 -0
  80. package/dist/pipeline/conditions.js.map +1 -0
  81. package/dist/pipeline/exclusive.js +230 -0
  82. package/dist/pipeline/exclusive.js.map +1 -0
  83. package/dist/pipeline/index.d.ts +55 -0
  84. package/dist/pipeline/index.js +708 -0
  85. package/dist/pipeline/index.js.map +1 -0
  86. package/dist/pipeline/materialize.js +1103 -0
  87. package/dist/pipeline/materialize.js.map +1 -0
  88. package/dist/pipeline/parseStateKey.d.ts +15 -0
  89. package/dist/pipeline/parseStateKey.js +446 -0
  90. package/dist/pipeline/parseStateKey.js.map +1 -0
  91. package/dist/pipeline/simplify.js +515 -0
  92. package/dist/pipeline/simplify.js.map +1 -0
  93. package/dist/pipeline/warnings.js +18 -0
  94. package/dist/pipeline/warnings.js.map +1 -0
  95. package/dist/plugins/index.d.ts +2 -0
  96. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  97. package/dist/plugins/okhsl-plugin.js +97 -0
  98. package/dist/plugins/okhsl-plugin.js.map +1 -0
  99. package/dist/plugins/types.d.ts +76 -0
  100. package/dist/properties/index.js +222 -0
  101. package/dist/properties/index.js.map +1 -0
  102. package/dist/properties/property-type-resolver.d.ts +24 -0
  103. package/dist/properties/property-type-resolver.js +90 -0
  104. package/dist/properties/property-type-resolver.js.map +1 -0
  105. package/dist/ssr/astro.d.ts +29 -0
  106. package/dist/ssr/astro.js +64 -0
  107. package/dist/ssr/astro.js.map +1 -0
  108. package/dist/ssr/async-storage.d.ts +17 -0
  109. package/dist/ssr/async-storage.js +34 -0
  110. package/dist/ssr/async-storage.js.map +1 -0
  111. package/dist/ssr/collect-auto-properties.js +39 -0
  112. package/dist/ssr/collect-auto-properties.js.map +1 -0
  113. package/dist/ssr/collector.d.ts +102 -0
  114. package/dist/ssr/collector.js +226 -0
  115. package/dist/ssr/collector.js.map +1 -0
  116. package/dist/ssr/context.d.ts +8 -0
  117. package/dist/ssr/context.js +13 -0
  118. package/dist/ssr/context.js.map +1 -0
  119. package/dist/ssr/format-global-rules.js +22 -0
  120. package/dist/ssr/format-global-rules.js.map +1 -0
  121. package/dist/ssr/format-keyframes.js +69 -0
  122. package/dist/ssr/format-keyframes.js.map +1 -0
  123. package/dist/ssr/format-property.js +49 -0
  124. package/dist/ssr/format-property.js.map +1 -0
  125. package/dist/ssr/format-rules.js +73 -0
  126. package/dist/ssr/format-rules.js.map +1 -0
  127. package/dist/ssr/hydrate.d.ts +22 -0
  128. package/dist/ssr/hydrate.js +49 -0
  129. package/dist/ssr/hydrate.js.map +1 -0
  130. package/dist/ssr/index.d.ts +5 -0
  131. package/dist/ssr/index.js +11 -0
  132. package/dist/ssr/index.js.map +1 -0
  133. package/dist/ssr/next.d.ts +45 -0
  134. package/dist/ssr/next.js +69 -0
  135. package/dist/ssr/next.js.map +1 -0
  136. package/dist/ssr/ssr-collector-ref.js +12 -0
  137. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  138. package/dist/states/index.d.ts +49 -0
  139. package/dist/states/index.js +170 -0
  140. package/dist/states/index.js.map +1 -0
  141. package/dist/static/index.d.ts +5 -0
  142. package/dist/static/index.js +4 -0
  143. package/dist/static/inject.d.ts +5 -0
  144. package/dist/static/inject.js +17 -0
  145. package/dist/static/inject.js.map +1 -0
  146. package/dist/static/tastyStatic.d.ts +46 -0
  147. package/dist/static/tastyStatic.js +30 -0
  148. package/dist/static/tastyStatic.js.map +1 -0
  149. package/dist/static/types.d.ts +49 -0
  150. package/dist/static/types.js +24 -0
  151. package/dist/static/types.js.map +1 -0
  152. package/dist/styles/align.d.ts +15 -0
  153. package/dist/styles/align.js +14 -0
  154. package/dist/styles/align.js.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +113 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/color.d.ts +14 -0
  159. package/dist/styles/color.js +26 -0
  160. package/dist/styles/color.js.map +1 -0
  161. package/dist/styles/createStyle.js +79 -0
  162. package/dist/styles/createStyle.js.map +1 -0
  163. package/dist/styles/dimension.js +96 -0
  164. package/dist/styles/dimension.js.map +1 -0
  165. package/dist/styles/display.d.ts +37 -0
  166. package/dist/styles/display.js +66 -0
  167. package/dist/styles/display.js.map +1 -0
  168. package/dist/styles/fade.d.ts +15 -0
  169. package/dist/styles/fade.js +57 -0
  170. package/dist/styles/fade.js.map +1 -0
  171. package/dist/styles/fill.d.ts +42 -0
  172. package/dist/styles/fill.js +51 -0
  173. package/dist/styles/fill.js.map +1 -0
  174. package/dist/styles/flow.d.ts +16 -0
  175. package/dist/styles/flow.js +12 -0
  176. package/dist/styles/flow.js.map +1 -0
  177. package/dist/styles/gap.d.ts +31 -0
  178. package/dist/styles/gap.js +36 -0
  179. package/dist/styles/gap.js.map +1 -0
  180. package/dist/styles/height.d.ts +17 -0
  181. package/dist/styles/height.js +19 -0
  182. package/dist/styles/height.js.map +1 -0
  183. package/dist/styles/index.d.ts +1 -0
  184. package/dist/styles/index.js +8 -0
  185. package/dist/styles/index.js.map +1 -0
  186. package/dist/styles/inset.d.ts +52 -0
  187. package/dist/styles/inset.js +149 -0
  188. package/dist/styles/inset.js.map +1 -0
  189. package/dist/styles/justify.d.ts +15 -0
  190. package/dist/styles/justify.js +14 -0
  191. package/dist/styles/justify.js.map +1 -0
  192. package/dist/styles/list.d.ts +16 -0
  193. package/dist/styles/list.js +98 -0
  194. package/dist/styles/list.js.map +1 -0
  195. package/dist/styles/margin.d.ts +24 -0
  196. package/dist/styles/margin.js +103 -0
  197. package/dist/styles/margin.js.map +1 -0
  198. package/dist/styles/outline.d.ts +29 -0
  199. package/dist/styles/outline.js +64 -0
  200. package/dist/styles/outline.js.map +1 -0
  201. package/dist/styles/padding.d.ts +24 -0
  202. package/dist/styles/padding.js +103 -0
  203. package/dist/styles/padding.js.map +1 -0
  204. package/dist/styles/predefined.d.ts +71 -0
  205. package/dist/styles/predefined.js +237 -0
  206. package/dist/styles/predefined.js.map +1 -0
  207. package/dist/styles/preset.d.ts +52 -0
  208. package/dist/styles/preset.js +126 -0
  209. package/dist/styles/preset.js.map +1 -0
  210. package/dist/styles/radius.d.ts +12 -0
  211. package/dist/styles/radius.js +71 -0
  212. package/dist/styles/radius.js.map +1 -0
  213. package/dist/styles/scrollbar.d.ts +25 -0
  214. package/dist/styles/scrollbar.js +46 -0
  215. package/dist/styles/scrollbar.js.map +1 -0
  216. package/dist/styles/shadow.d.ts +14 -0
  217. package/dist/styles/shadow.js +23 -0
  218. package/dist/styles/shadow.js.map +1 -0
  219. package/dist/styles/transition.d.ts +14 -0
  220. package/dist/styles/transition.js +157 -0
  221. package/dist/styles/transition.js.map +1 -0
  222. package/dist/styles/types.d.ts +549 -0
  223. package/dist/styles/width.d.ts +17 -0
  224. package/dist/styles/width.js +19 -0
  225. package/dist/styles/width.js.map +1 -0
  226. package/dist/tasty.d.ts +119 -0
  227. package/dist/tasty.js +231 -0
  228. package/dist/tasty.js.map +1 -0
  229. package/dist/types.d.ts +184 -0
  230. package/dist/utils/cache-wrapper.js +21 -0
  231. package/dist/utils/cache-wrapper.js.map +1 -0
  232. package/dist/utils/case-converter.js +8 -0
  233. package/dist/utils/case-converter.js.map +1 -0
  234. package/dist/utils/color-math.d.ts +46 -0
  235. package/dist/utils/color-math.js +749 -0
  236. package/dist/utils/color-math.js.map +1 -0
  237. package/dist/utils/color-space.d.ts +5 -0
  238. package/dist/utils/color-space.js +228 -0
  239. package/dist/utils/color-space.js.map +1 -0
  240. package/dist/utils/colors.d.ts +5 -0
  241. package/dist/utils/colors.js +10 -0
  242. package/dist/utils/colors.js.map +1 -0
  243. package/dist/utils/css-types.d.ts +7 -0
  244. package/dist/utils/dotize.d.ts +26 -0
  245. package/dist/utils/dotize.js +122 -0
  246. package/dist/utils/dotize.js.map +1 -0
  247. package/dist/utils/filter-base-props.d.ts +15 -0
  248. package/dist/utils/filter-base-props.js +45 -0
  249. package/dist/utils/filter-base-props.js.map +1 -0
  250. package/dist/utils/get-display-name.d.ts +7 -0
  251. package/dist/utils/get-display-name.js +10 -0
  252. package/dist/utils/get-display-name.js.map +1 -0
  253. package/dist/utils/has-keys.js +13 -0
  254. package/dist/utils/has-keys.js.map +1 -0
  255. package/dist/utils/is-dev-env.js +19 -0
  256. package/dist/utils/is-dev-env.js.map +1 -0
  257. package/dist/utils/is-valid-element-type.js +15 -0
  258. package/dist/utils/is-valid-element-type.js.map +1 -0
  259. package/dist/utils/merge-styles.d.ts +7 -0
  260. package/dist/utils/merge-styles.js +145 -0
  261. package/dist/utils/merge-styles.js.map +1 -0
  262. package/dist/utils/mod-attrs.d.ts +6 -0
  263. package/dist/utils/mod-attrs.js +20 -0
  264. package/dist/utils/mod-attrs.js.map +1 -0
  265. package/dist/utils/process-tokens.d.ts +21 -0
  266. package/dist/utils/process-tokens.js +90 -0
  267. package/dist/utils/process-tokens.js.map +1 -0
  268. package/dist/utils/resolve-recipes.d.ts +17 -0
  269. package/dist/utils/resolve-recipes.js +146 -0
  270. package/dist/utils/resolve-recipes.js.map +1 -0
  271. package/dist/utils/selector-transform.js +32 -0
  272. package/dist/utils/selector-transform.js.map +1 -0
  273. package/dist/utils/string.js +8 -0
  274. package/dist/utils/string.js.map +1 -0
  275. package/dist/utils/styles.d.ts +99 -0
  276. package/dist/utils/styles.js +220 -0
  277. package/dist/utils/styles.js.map +1 -0
  278. package/dist/utils/typography.d.ts +47 -0
  279. package/dist/utils/typography.js +51 -0
  280. package/dist/utils/typography.js.map +1 -0
  281. package/dist/utils/warnings.d.ts +16 -0
  282. package/dist/utils/warnings.js +16 -0
  283. package/dist/utils/warnings.js.map +1 -0
  284. package/dist/zero/babel.d.ts +182 -0
  285. package/dist/zero/babel.js +438 -0
  286. package/dist/zero/babel.js.map +1 -0
  287. package/dist/zero/css-writer.d.ts +45 -0
  288. package/dist/zero/css-writer.js +73 -0
  289. package/dist/zero/css-writer.js.map +1 -0
  290. package/dist/zero/extractor.d.ts +24 -0
  291. package/dist/zero/extractor.js +266 -0
  292. package/dist/zero/extractor.js.map +1 -0
  293. package/dist/zero/index.d.ts +3 -0
  294. package/dist/zero/index.js +3 -0
  295. package/dist/zero/next.d.ts +86 -0
  296. package/dist/zero/next.js +143 -0
  297. package/dist/zero/next.js.map +1 -0
  298. package/docs/PIPELINE.md +519 -0
  299. package/docs/README.md +31 -0
  300. package/docs/adoption.md +296 -0
  301. package/docs/comparison.md +420 -0
  302. package/docs/configuration.md +326 -0
  303. package/docs/debug.md +318 -0
  304. package/docs/design-system.md +424 -0
  305. package/docs/dsl.md +673 -0
  306. package/docs/getting-started.md +217 -0
  307. package/docs/injector.md +528 -0
  308. package/docs/methodology.md +567 -0
  309. package/docs/runtime.md +485 -0
  310. package/docs/ssr.md +384 -0
  311. package/docs/styles.md +582 -0
  312. package/docs/tasty-static.md +520 -0
  313. package/package.json +215 -0
  314. package/tasty.config.ts +14 -0
@@ -0,0 +1,424 @@
1
+ # Building a Design System
2
+
3
+ This guide walks through building a design-system styling layer on top of Tasty — defining tokens, state aliases, recipes, primitive components, and compound components with sub-elements.
4
+
5
+ It assumes you have already decided to adopt Tasty. The goal is not just to centralize tokens, but to define a styling language whose component states resolve deterministically across variants, responsive rules, and sub-elements. For evaluation criteria, audience fit, and incremental adoption phases, see the [Adoption Guide](adoption.md). For the recommended component patterns and mental model, 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
+ Use `generateTypographyTokens()` to create typography tokens from your own presets, then pass them to `configure({ tokens })`:
88
+
89
+ ```tsx
90
+ import { configure, generateTypographyTokens } from '@tenphi/tasty';
91
+
92
+ const typographyTokens = generateTypographyTokens({
93
+ h1: { fontSize: '2rem', lineHeight: '1.2', letterSpacing: '-0.02em', fontWeight: 700 },
94
+ t2: { fontSize: '0.875rem', lineHeight: '1.5', letterSpacing: 'normal', fontWeight: 400 },
95
+ });
96
+
97
+ configure({
98
+ tokens: {
99
+ ...typographyTokens,
100
+ },
101
+ });
102
+ ```
103
+
104
+ Then use `preset: 'h1'` or `preset: 't2'` in any component's styles.
105
+
106
+ ### Registering brand fonts
107
+
108
+ Register your design system's custom fonts via `configure({ fontFace })` so every component can reference them:
109
+
110
+ ```ts
111
+ configure({
112
+ fontFace: {
113
+ 'Brand Sans': [
114
+ { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
115
+ { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
116
+ ],
117
+ },
118
+ });
119
+ ```
120
+
121
+ See [Font Face](configuration.md#font-face) for the full configuration reference.
122
+
123
+ ---
124
+
125
+ ## Defining state aliases
126
+
127
+ State aliases let you write `@mobile` instead of `@media(w < 768px)` in every component. Define them once in `configure()`:
128
+
129
+ ```tsx
130
+ configure({
131
+ states: {
132
+ '@mobile': '@media(w < 768px)',
133
+ '@tablet': '@media(768px <= w < 1024px)',
134
+ '@desktop': '@media(w >= 1024px)',
135
+ '@dark': '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
136
+ '@reduced-motion': '@media(prefers-reduced-motion: reduce)',
137
+ },
138
+ });
139
+ ```
140
+
141
+ Every component can now use these without repeating the query logic:
142
+
143
+ ```tsx
144
+ const Card = tasty({
145
+ styles: {
146
+ padding: { '': '4x', '@mobile': '2x' },
147
+ flow: { '': 'row', '@mobile': 'column' },
148
+ fill: { '': '#surface', '@dark': '#surface-dark' },
149
+ },
150
+ });
151
+ ```
152
+
153
+ 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.
154
+
155
+ ---
156
+
157
+ ## Creating recipes
158
+
159
+ Recipes are named style bundles for patterns that repeat across components. Define them in `configure()`:
160
+
161
+ ```tsx
162
+ configure({
163
+ recipes: {
164
+ card: {
165
+ padding: '4x',
166
+ fill: '#surface',
167
+ radius: '1r',
168
+ border: true,
169
+ },
170
+ elevated: {
171
+ shadow: '0 2x 4x #shadow',
172
+ },
173
+ 'input-reset': {
174
+ border: 'none',
175
+ outline: 'none',
176
+ fill: 'transparent',
177
+ font: true,
178
+ preset: 't3',
179
+ },
180
+ interactive: {
181
+ cursor: { '': 'pointer', disabled: 'not-allowed' },
182
+ opacity: { '': '1', disabled: '.5' },
183
+ transition: 'theme',
184
+ },
185
+ },
186
+ });
187
+ ```
188
+
189
+ Components reference recipes by name. This keeps component definitions lean while ensuring consistency:
190
+
191
+ ```tsx
192
+ const ProfileCard = tasty({
193
+ styles: {
194
+ recipe: 'card elevated',
195
+ color: '#text',
196
+ Title: { preset: 'h3', color: '#primary' },
197
+ },
198
+ elements: { Title: 'h2' },
199
+ });
200
+ ```
201
+
202
+ Use the `/` separator when a recipe should be applied *after* local styles (post-merge), so recipe states take priority:
203
+
204
+ ```tsx
205
+ const Input = tasty({
206
+ styles: {
207
+ recipe: 'input-reset / interactive',
208
+ padding: '1.5x 2x',
209
+ border: '1bw solid #border',
210
+ },
211
+ });
212
+ ```
213
+
214
+ See [Configuration — Recipes](configuration.md#recipes) for the API and [Style DSL — Recipes](dsl.md#recipes) for composition patterns.
215
+
216
+ ---
217
+
218
+ ## Building primitive components
219
+
220
+ 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.
221
+
222
+ ### Layout primitives
223
+
224
+ ```tsx
225
+ import { tasty, FLOW_STYLES, POSITION_STYLES } from '@tenphi/tasty';
226
+
227
+ const Space = tasty({
228
+ as: 'div',
229
+ styles: {
230
+ display: 'flex',
231
+ flow: 'column',
232
+ gap: '1x',
233
+ },
234
+ styleProps: FLOW_STYLES,
235
+ });
236
+
237
+ const Box = tasty({
238
+ as: 'div',
239
+ styles: {
240
+ display: 'block',
241
+ },
242
+ styleProps: [...FLOW_STYLES, ...POSITION_STYLES, 'padding', 'fill', 'radius'],
243
+ });
244
+
245
+ const Grid = tasty({
246
+ as: 'div',
247
+ styles: {
248
+ display: 'grid',
249
+ gap: '1x',
250
+ },
251
+ styleProps: [...FLOW_STYLES, 'gridColumns', 'gridRows', 'gridAreas'],
252
+ });
253
+ ```
254
+
255
+ Product engineers use these to compose layouts without writing CSS:
256
+
257
+ ```tsx
258
+ <Space flow="row" gap="2x" placeItems="center">
259
+ <Title>Dashboard</Title>
260
+ <Button placeSelf="end">Add Item</Button>
261
+ </Space>
262
+
263
+ <Grid gridColumns={{ '': '1fr', '@tablet': '1fr 1fr', '@desktop': '1fr 1fr 1fr' }} gap="3x">
264
+ <Card>...</Card>
265
+ <Card>...</Card>
266
+ <Card>...</Card>
267
+ </Grid>
268
+ ```
269
+
270
+ ### Which styleProps to expose
271
+
272
+ Match the prop set to the component's role:
273
+
274
+ | Component category | Recommended styleProps |
275
+ |--------------------|----------------------|
276
+ | Layout containers (`Space`, `Box`, `Grid`) | `FLOW_STYLES` — flow, gap, align, justify, padding, fill |
277
+ | Positioned elements (`Button`, `Badge`) | `POSITION_STYLES` — placeSelf, gridArea, order |
278
+ | Text elements | `['preset', 'color']` or a custom subset |
279
+ | Compound components | Typically none — styling happens via sub-elements and wrapping |
280
+
281
+ 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.
282
+
283
+ ---
284
+
285
+ ## Building compound components
286
+
287
+ 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.
288
+
289
+ ```tsx
290
+ const Card = tasty({
291
+ styles: {
292
+ recipe: 'card',
293
+ flow: 'column',
294
+ gap: '2x',
295
+
296
+ Title: {
297
+ preset: 'h3',
298
+ color: '#primary',
299
+ },
300
+ Content: {
301
+ preset: 't2',
302
+ color: '#text',
303
+ },
304
+ Footer: {
305
+ display: 'flex',
306
+ flow: 'row',
307
+ gap: '1x',
308
+ justify: 'flex-end',
309
+ padding: '2x top',
310
+ border: '1bw solid #border top',
311
+ },
312
+ },
313
+ elements: {
314
+ Title: 'h2',
315
+ Content: 'div',
316
+ Footer: 'div',
317
+ },
318
+ });
319
+ ```
320
+
321
+ Usage:
322
+
323
+ ```tsx
324
+ <Card>
325
+ <Card.Title>Monthly Revenue</Card.Title>
326
+ <Card.Content>
327
+ $1.2M — up 12% from last month.
328
+ </Card.Content>
329
+ <Card.Footer>
330
+ <Button>Details</Button>
331
+ </Card.Footer>
332
+ </Card>
333
+ ```
334
+
335
+ 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).
336
+
337
+ For sub-element syntax details (selector affix `$`, `@own()`, `elements` config), see [Runtime API — Sub-element Styling](runtime.md#sub-element-styling).
338
+
339
+ ---
340
+
341
+ ## Defining the override contract
342
+
343
+ A design system works best when the rules for customization are explicit. Tasty provides three levels of control:
344
+
345
+ ### What product engineers can do
346
+
347
+ 1. **Use styleProps** — adjust layout, spacing, positioning through the props the component exposes:
348
+
349
+ ```tsx
350
+ <Space flow="row" gap="3x" padding="2x">
351
+ ```
352
+
353
+ 2. **Use modProps** — control component states through typed props instead of `mods`:
354
+
355
+ ```tsx
356
+ <Button isLoading size="large">Submit</Button>
357
+ ```
358
+
359
+ 3. **Pass tokens** — inject runtime values through the `tokens` prop for per-instance customization:
360
+
361
+ ```tsx
362
+ <ProgressBar tokens={{ '$progress': `${percent}%` }} />
363
+ ```
364
+
365
+ 4. **Create styled wrappers** — extend a component's styles with `tasty(Base, { styles })`:
366
+
367
+ ```tsx
368
+ const DangerButton = tasty(Button, {
369
+ styles: {
370
+ fill: { '': '#danger', ':hover': '#danger-hover' },
371
+ color: '#on-danger',
372
+ },
373
+ });
374
+ ```
375
+
376
+ ### What to discourage
377
+
378
+ - **Direct `styles` prop** — bypasses the component's intended API; prefer styled wrappers
379
+ - **`style` prop** — React inline styles that bypass Tasty entirely; reserve for third-party integration only
380
+ - **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
381
+
382
+ 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.
383
+
384
+ ---
385
+
386
+ ## Project structure
387
+
388
+ A recommended structure for a design system built on Tasty:
389
+
390
+ ```
391
+ ds/
392
+ config.ts # configure() — tokens, units, states, recipes
393
+ primitives/
394
+ Space.tsx # Layout: flex container with FLOW_STYLES
395
+ Box.tsx # Generic container
396
+ Grid.tsx # Grid container
397
+ Text.tsx # Text element with preset + color
398
+ components/
399
+ Button.tsx # Interactive component with variants
400
+ Card.tsx # Compound component with sub-elements
401
+ Input.tsx # Form input with recipes
402
+ Dialog.tsx # Overlay compound component
403
+ recipes/
404
+ index.ts # Recipe definitions (imported by config.ts)
405
+ tokens/
406
+ colors.ts # Color token definitions
407
+ typography.ts # Typography presets via generateTypographyTokens()
408
+ spacing.ts # Spacing token definitions
409
+ index.ts # Public API: re-exports components + configure
410
+ ```
411
+
412
+ 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.
413
+
414
+ ---
415
+
416
+ ## Learn more
417
+
418
+ - **[Methodology](methodology.md)** — The recommended patterns for structuring Tasty components
419
+ - **[Getting Started](getting-started.md)** — Installation, first component, tooling setup
420
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
421
+ - **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, hooks
422
+ - **[Configuration](configuration.md)** — Full `configure()` API: tokens, recipes, custom units, style handlers
423
+ - **[Adoption Guide](adoption.md)** — Who should adopt Tasty, incremental phases, what changes for product engineers
424
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties