@tenphi/tasty 0.0.0-snapshot.d9aaeb7 → 0.0.0-snapshot.d9fa8e8

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 (133) hide show
  1. package/README.md +440 -372
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/{collector-WUJKpM4q.js → chunks/collector-Cb8ah2JF.js} +79 -99
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
  10. package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-B4aWBkH3.js +910 -0
  14. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-D2Pu7Xhy.js +502 -0
  18. package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
  19. package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
  20. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DHiopXCu.js +691 -0
  24. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  25. package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
  26. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  27. package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
  28. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  29. package/dist/{merge-styles-B57eQpFZ.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-DnkV_4Jg.js +5602 -0
  32. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  33. package/dist/{css-writer-BaR8ywQm.js → chunks/zero-engine-DcwaCvFs.js} +104 -123
  34. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  35. package/dist/collector-D2OT6I2G.d.ts +164 -0
  36. package/dist/config-C4ftFxgI.d.ts +1367 -0
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DxQNRj50.d.ts +1964 -0
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -732
  43. package/dist/{merge-styles-CtDJMhpJ.d.ts → merge-styles-D39qBtox.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  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 +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +40 -10
  60. package/dist/ssr/astro.js +163 -91
  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 +5 -32
  65. package/dist/ssr/index.js +6 -6
  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 +9 -9
  71. package/dist/ssr/next.js +29 -44
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +8 -9
  74. package/dist/static/index.js +4 -22
  75. package/dist/static/index.js.map +1 -1
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/static/inject.js.map +1 -1
  78. package/dist/{index-dUtwpOux.d.ts → types-CYQIhUg1.d.ts} +691 -388
  79. package/dist/zero/babel.d.ts +12 -20
  80. package/dist/zero/babel.js +101 -152
  81. package/dist/zero/babel.js.map +1 -1
  82. package/dist/zero/index.d.ts +76 -7
  83. package/dist/zero/index.js +25 -2
  84. package/dist/zero/index.js.map +1 -0
  85. package/dist/zero/next.d.ts +4 -5
  86. package/dist/zero/next.js +3 -38
  87. package/dist/zero/next.js.map +1 -1
  88. package/docs/README.md +20 -9
  89. package/docs/adoption.md +69 -36
  90. package/docs/ai-agents.md +259 -0
  91. package/docs/comparison.md +77 -47
  92. package/docs/configuration.md +648 -85
  93. package/docs/debug.md +28 -15
  94. package/docs/design-system.md +154 -33
  95. package/docs/dsl.md +715 -194
  96. package/docs/getting-started.md +130 -50
  97. package/docs/injector.md +160 -69
  98. package/docs/methodology.md +106 -49
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +141 -46
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +236 -47
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +310 -116
  105. package/docs/styles.md +234 -49
  106. package/docs/tasty-static.md +298 -130
  107. package/package.json +146 -41
  108. package/tasty.config.ts +5 -0
  109. package/dist/async-storage-B7_o6FKt.js +0 -44
  110. package/dist/async-storage-B7_o6FKt.js.map +0 -1
  111. package/dist/collector-LuU1vZ68.d.ts +0 -98
  112. package/dist/collector-WUJKpM4q.js.map +0 -1
  113. package/dist/config-raGoEeGs.js +0 -10227
  114. package/dist/config-raGoEeGs.js.map +0 -1
  115. package/dist/config-vuCRkBWX.d.ts +0 -884
  116. package/dist/context-CkSg-kDT.js +0 -24
  117. package/dist/context-CkSg-kDT.js.map +0 -1
  118. package/dist/core-CrPLif0D.js +0 -1592
  119. package/dist/core-CrPLif0D.js.map +0 -1
  120. package/dist/css-writer-BaR8ywQm.js.map +0 -1
  121. package/dist/format-global-rules-Dbc_1tc3.js +0 -22
  122. package/dist/format-global-rules-Dbc_1tc3.js.map +0 -1
  123. package/dist/format-rules-B_Cuw1ZS.js +0 -143
  124. package/dist/format-rules-B_Cuw1ZS.js.map +0 -1
  125. package/dist/hydrate-DmVyww8Y.js +0 -45
  126. package/dist/hydrate-DmVyww8Y.js.map +0 -1
  127. package/dist/index-ZRxZWzlj.d.ts +0 -1602
  128. package/dist/index.js.map +0 -1
  129. package/dist/keyframes-C9OD_9bX.js +0 -588
  130. package/dist/keyframes-C9OD_9bX.js.map +0 -1
  131. package/dist/merge-styles-B57eQpFZ.js.map +0 -1
  132. package/dist/resolve-recipes-J9mdpVSZ.js +0 -144
  133. package/dist/resolve-recipes-J9mdpVSZ.js.map +0 -1
package/docs/adoption.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Adoption Guide
2
2
 
3
- Tasty is not a drop-in replacement for another styling library. It is a **substrate for building a design-system-defined styling language**: what the comparison guide calls a house styling language. That means adoption usually starts where styling for reusable, stateful components has already become a composition problem, not with an all-at-once rewrite.
3
+ Tasty is most useful where reusable component styling has become a state-resolution problem: hover intersects with disabled, variants intersect with themes, and every extension makes selector behavior harder to predict.
4
4
 
5
- This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase. Use this document for rollout strategy and adoption sequencing; use the [Comparison guide](comparison.md) when the open question is whether Tasty is the right tool in the first place.
5
+ It normally sits underneath a design system’s existing components. You can preserve their public React APIs while moving their style logic into state maps that produce one declared winner. Adoption should start with a small, state-heavy component—not an all-at-once rewrite.
6
+
7
+ This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase. Use it for rollout strategy and adoption sequencing; use the [Comparison guide](comparison.md) when the open question is whether Tasty is the right tool.
6
8
 
7
9
  ---
8
10
 
@@ -18,12 +20,15 @@ Product code
18
20
  ```
19
21
 
20
22
  **What Tasty owns:**
23
+
21
24
  - The DSL and value parser (tokens, custom units, auto-calc, color opacity)
22
25
  - State compilation (mutually exclusive selectors from state maps)
23
26
  - Style injection and deduplication (runtime or build-time)
24
- - The `tasty()` component factory and hooks API
27
+ - The `tasty()` component factory and style functions (`useStyles`, `useGlobalStyles`, …)
28
+ - The lint rules and TypeScript extension interfaces that check usage against your vocabulary
25
29
 
26
30
  **What the DS team owns:**
31
+
27
32
  - Token names and values (colors, spacing, typography)
28
33
  - Custom units and their semantics
29
34
  - State aliases (`@mobile`, `@dark`, `@compact`)
@@ -39,12 +44,14 @@ Two teams using Tasty can end up with very different authoring models. That is b
39
44
  ## Who should adopt Tasty
40
45
 
41
46
  **Strong fit:**
42
- - A design-system or platform team that wants to define a governed styling language
47
+
48
+ - A design-system or platform team that owns shared component APIs
43
49
  - Components with complex, intersecting states (hover + disabled + theme + breakpoint)
44
50
  - Teams that need deterministic style resolution without cascade/specificity bugs
45
- - Organizations where styling decisions should be centralized, not distributed
51
+ - Organizations that want tokens, states, and extension rules to stay consistent across products
46
52
 
47
53
  **Not the right fit:**
54
+
48
55
  - Solo developers building a one-off app with minimal UI structure
49
56
  - Teams that want a shared utility vocabulary and direct markup authoring (Tailwind is better here)
50
57
  - Projects where low ceremony matters more than central governance
@@ -58,16 +65,18 @@ For a detailed comparison with Tailwind, Panda CSS, vanilla-extract, StyleX, Sti
58
65
 
59
66
  Tasty provides the engine. The DS team defines the language that runs on it. Here is what that typically involves:
60
67
 
61
- | Layer | What you define | Where |
62
- |-------|----------------|-------|
63
- | **Tokens** | Color names, spacing scale, border widths, radii | `configure({ tokens })` |
64
- | **Units** | Custom multiplier units (`x`, `r`, `bw`, or your own) | `configure({ units })` |
65
- | **State aliases** | Responsive breakpoints, theme modes, feature flags | `configure({ states })` |
66
- | **Recipes** | Reusable style bundles (card, elevated, input-reset) | `configure({ recipes })` |
67
- | **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ presets: { ... } })` |
68
- | **Style props** | Which CSS properties each component exposes as React props | `styleProps` in each component |
69
- | **Sub-elements** | Inner parts of compound components (Title, Icon, Content) | `elements` + capitalized keys in `styles` |
70
- | **Override rules** | How product engineers extend or constrain components | Styled wrappers via `tasty(Base, { ... })` |
68
+ | Layer | What you define | Where |
69
+ | ------------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------- |
70
+ | **Tokens** | Color names and named values (`#surface`, `$sidebar-width`) | `configure({ tokens })` |
71
+ | **Units** | Spacing step, radius, border and outline widths (`x`, `r`, `bw`, `ow`, or your own) | `configure({ units })` |
72
+ | **State aliases** | Responsive breakpoints, theme modes, feature flags | `configure({ states })` |
73
+ | **Recipes** | Reusable style bundles (card, elevated, input-reset) | `configure({ recipes })` |
74
+ | **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ presets: { ... } })` |
75
+ | **Style props** | Which CSS properties each component exposes as React props | `styleProps` in each component |
76
+ | **Sub-elements** | Inner parts of compound components (Title, Icon, Content) | `elements` + capitalized keys in `styles` |
77
+ | **Component API** | Typed props for states, values, and looks | `modProps`, `tokenProps`, `variants` |
78
+ | **Override rules** | How product engineers extend or constrain components | Styled wrappers via `tasty(Base, { ... })` |
79
+ | **Guardrails** | The names the linter and TypeScript check against | `tasty.config.ts`, `declare module '@tenphi/tasty'` |
71
80
 
72
81
  The same engine can power a minimal design system with a handful of tokens:
73
82
 
@@ -85,9 +94,15 @@ Here is how the layers connect end-to-end. The DS team configures the engine, de
85
94
  ```tsx
86
95
  // ds/config.ts — DS team defines the language
87
96
  configure({
88
- tokens: { '#primary': 'oklch(55% 0.25 265)', '#surface': '#fff', '#text': '#111' },
97
+ tokens: {
98
+ '#primary': 'oklch(55% 0.25 265)',
99
+ '#surface': '#fff',
100
+ '#text': '#111',
101
+ },
89
102
  states: { '@mobile': '@media(w < 768px)', '@dark': '@root(schema=dark)' },
90
- recipes: { card: { padding: '4x', fill: '#surface', radius: '1r', border: true } },
103
+ recipes: {
104
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
105
+ },
91
106
  });
92
107
 
93
108
  // ds/components/Card.tsx — DS team builds components on top
@@ -105,7 +120,7 @@ const Card = tasty({
105
120
  <Card padding={{ '': '4x', '@mobile': '2x' }}>
106
121
  <Card.Title>Monthly Revenue</Card.Title>
107
122
  <Card.Body>$1.2M — up 12% from last month</Card.Body>
108
- </Card>
123
+ </Card>;
109
124
  ```
110
125
 
111
126
  See [Configuration](configuration.md) for the full `configure()` API.
@@ -116,9 +131,21 @@ See [Configuration](configuration.md) for the full `configure()` API.
116
131
 
117
132
  You do not need to adopt everything at once. Tasty is designed to be introduced layer by layer.
118
133
 
119
- A practical way to start is with the components that already suffer from intersecting state and variant logic: buttons, inputs, menus, disclosures, dialogs, list items, interactive cards, and compound components. Those are the places where deterministic resolution pays off fastest.
134
+ A practical first slice is one component that already suffers from intersecting state and variant logic: a button, input, menu item, disclosure, or interactive card. Keep its public API unchanged, move one or two properties into Tasty state maps, and verify that the declared priority matches the behavior your team expects.
135
+
136
+ This proves the differentiator before you invest in a complete token vocabulary or migrate an entire component library.
137
+
138
+ ### Phase 1 -- Pilot one state-heavy component
120
139
 
121
- ### Phase 1 -- Tokens and units
140
+ Choose a component with a known hover/disabled, focus/error, or variant/theme interaction. Preserve its external props and visual behavior. The pilot should answer three questions:
141
+
142
+ 1. Is the state map easier to review than the existing selectors or conditional class logic?
143
+ 2. Does extending the component keep the intended state priority?
144
+ 3. Can your current tokens and component API move over without product-code churn?
145
+
146
+ If the answer is yes, establish the shared design-system vocabulary around the successful slice.
147
+
148
+ ### Phase 2 -- Tokens and units
122
149
 
123
150
  Start by defining your design tokens and custom units. This is the lowest-risk step: it only configures the parser and does not require rewriting any components.
124
151
 
@@ -131,19 +158,24 @@ configure({
131
158
  '#surface': '#white',
132
159
  '#text': '#111',
133
160
  '$card-padding': '4x',
161
+ $gap: '8px',
162
+ $radius: '6px',
163
+ '$border-width': '1px',
134
164
  },
135
- // Common units (x, r, bw, ow, cr) are built-in.
136
- // A DS typically redefines them to use CSS custom properties
137
- // so that the actual scale is controlled via CSS, not JS:
165
+ // Built-in units (x, r, cr, bw, ow) compile to fixed values by default.
166
+ // A DS often points them at the custom properties above, so the scale
167
+ // is controlled by CSS at runtime rather than fixed at build time:
138
168
  units: {
139
- x: 'var(--gap)', // 2x → calc(var(--gap) * 2)
169
+ x: 'var(--gap)', // 2x → calc(2 * var(--gap))
140
170
  r: 'var(--radius)',
141
171
  bw: 'var(--border-width)',
142
172
  },
143
173
  });
144
174
  ```
145
175
 
146
- ### Phase 2 -- State aliases and recipes
176
+ Turn on the guardrails in the same step. Add [`@tenphi/eslint-plugin-tasty`](https://github.com/tenphi/eslint-plugin-tasty) with `tasty.configs.recommended` and a `tasty.config.ts` that lists the tokens, units, states, presets, and recipes as you define them, and register the same color and preset names for TypeScript autocomplete (`TastyNamedColors`, `TastyPresetNames`). Every component you migrate from here on is checked against the vocabulary. See [Getting Started — ESLint plugin](getting-started.md#eslint-plugin).
177
+
178
+ ### Phase 3 -- State aliases and recipes
147
179
 
148
180
  Define the state vocabulary your components will share. This is where you start encoding your team's conventions.
149
181
 
@@ -151,8 +183,9 @@ Define the state vocabulary your components will share. This is where you start
151
183
  configure({
152
184
  states: {
153
185
  '@mobile': '@media(w < 768px)',
154
- '@tablet': '@media(w < 1024px)',
155
- '@dark': '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
186
+ '@tablet': '@media(768px <= w < 1024px)',
187
+ '@dark':
188
+ '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
156
189
  },
157
190
  recipes: {
158
191
  card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
@@ -161,7 +194,7 @@ configure({
161
194
  });
162
195
  ```
163
196
 
164
- ### Phase 3 -- Migrate a few primitives
197
+ ### Phase 4 -- Migrate a few primitives
165
198
 
166
199
  Pick 2-3 widely used primitives (Box, Text, Button) and rewrite them with `tasty()`. Keep the public API identical so product code does not need to change.
167
200
 
@@ -179,7 +212,7 @@ const Box = tasty({
179
212
 
180
213
  At this point you can validate the DSL, token workflow, and component authoring experience before expanding the rollout.
181
214
 
182
- ### Phase 4 -- Encode complex states
215
+ ### Phase 5 -- Expand state resolution
183
216
 
184
217
  Move the components with the most painful intersecting states (buttons with hover + disabled + theme variants, inputs with focus + error + readonly) to Tasty's state map syntax. This is where mutually exclusive selectors start paying off.
185
218
 
@@ -209,7 +242,7 @@ const Button = tasty({
209
242
  });
210
243
  ```
211
244
 
212
- ### Phase 5 -- Standardize style props and sub-elements
245
+ ### Phase 6 -- Standardize style props and sub-elements
213
246
 
214
247
  Define which style props each component category exposes. Layout components get flow/gap/padding. Interactive components get positioning. Compound components declare sub-elements.
215
248
 
@@ -225,9 +258,9 @@ const Card = tasty({
225
258
  });
226
259
  ```
227
260
 
228
- ### Phase 6 -- Expand to full DS coverage
261
+ ### Phase 7 -- Expand to full DS coverage
229
262
 
230
- Migrate the remaining components, add the [ESLint plugin](https://github.com/tenphi/eslint-plugin-tasty) to enforce style conventions at lint time, and consider [zero-runtime mode](tasty-static.md) for static or performance-critical pages.
263
+ Migrate the remaining components, switch the [ESLint plugin](https://github.com/tenphi/eslint-plugin-tasty) to `tasty.configs.strict` to also catch unknown `$` tokens and state aliases, and choose between [server-only `tasty()`](ssr.md) and [`tastyStatic()` build-time extraction](tasty-static.md) when a page should ship no Tasty styling runtime.
231
264
 
232
265
  ---
233
266
 
@@ -254,8 +287,8 @@ const DangerButton = tasty(Button, {
254
287
  const LoadingButton = tasty(Button, {
255
288
  styles: {
256
289
  fill: {
257
- loading: '#yellow', // new state appended
258
- disabled: '#gray.20', // existing state overridden in place
290
+ loading: '#yellow', // new state appended
291
+ disabled: '#gray.20', // existing state overridden in place
259
292
  },
260
293
  },
261
294
  });
@@ -270,7 +303,7 @@ const LoadingButton = tasty(Button, {
270
303
  </Space>
271
304
  ```
272
305
 
273
- **Components are server components by default.** All `tasty()` components and style functions are hook-free, so they work as React Server Components without `'use client'`. In server-only contexts (Next.js RSC, Astro without `client:*` directives), they produce zero client JavaScript. Product engineers only add `'use client'` when their component needs actual React interactivity (state, effects, event handlers), never because of styling.
306
+ **Components are server components by default.** All `tasty()` components and style functions are hook-free, so they work as React Server Components without `'use client'`. In server-only contexts they ship no Tasty styling runtime. Astro without `client:*` directives ships no client JavaScript; server-only Next.js RSC follows the same Tasty architecture, while final output depends on the application deployment. Product engineers only add `'use client'` when their component needs actual React interactivity (state, effects, event handlers), never because of styling.
274
307
 
275
308
  **No cascade/specificity concerns.** Tasty's mutually exclusive selectors mean extending a component cannot accidentally break another. Import order, class name collisions, and specificity arithmetic are non-issues.
276
309
 
@@ -295,4 +328,4 @@ const LoadingButton = tasty(Button, {
295
328
  - [Configuration](configuration.md) -- tokens, recipes, custom units, style handlers, and TypeScript extensions
296
329
  - [Style Properties](styles.md) -- complete reference for all enhanced style properties
297
330
  - [Comparison](comparison.md) -- positioning and trade-offs vs. other styling systems
298
- - [Zero Runtime (tastyStatic)](tasty-static.md) -- build-time static styling with Babel plugin
331
+ - [Build-Time Extraction (`tastyStatic`)](tasty-static.md) -- static styling with the Babel plugin
@@ -0,0 +1,259 @@
1
+ # Tasty Style Rules for AI Agents
2
+
3
+ A compact ruleset for **writing correct `@tenphi/tasty` styles**. It is not an API tour — most rules here are machine-checked by [`@tenphi/eslint-plugin-tasty`](https://www.npmjs.com/package/@tenphi/eslint-plugin-tasty), so following it generally means clean lint output. The plugin ships separately and can lag a new DSL rule, so treat this page as the source of truth and the plugin as the enforcement that catches most of it. For explanations and the complete API, see [Style DSL](dsl.md), [Style Properties](styles.md), [React API](react-api.md).
4
+
5
+ Notation: ❌ wrong → ✅ correct.
6
+
7
+ ---
8
+
9
+ ## 0. Read the project config first
10
+
11
+ Color tokens (`#name`), custom properties (`$name`), `preset` names, `recipe` names, state aliases (`@mobile`) and extra units are **project-defined** in `tasty.config.ts` or a `configure({ … })` call. Look them up before writing styles. Never invent a name — reuse an existing one, or add it to the config.
12
+
13
+ Only Tasty's built-ins exist without config: `#white`, `#black`, `#border`, `#outline`, `#current`, `#clear`, and `$gap`, `$radius`, `$border-width`, `$outline-width`, `$transition`, `$sharp-radius`, `$bold-font-weight`, `$font-sans-fallback`, `$font-mono-fallback`.
14
+
15
+ ## 1. Where styles go
16
+
17
+ ```jsx
18
+ const Card = tasty({ as: 'div', styles: { … }, styleProps: ['padding'] }); // new component
19
+ const Hero = tasty(Card, { styles: { … } }); // extend a component
20
+ const cls = useStyles({ … }); // ad-hoc class name
21
+ tastyStatic('.card', { … }); // build-time extraction
22
+ ```
23
+
24
+ - Wrap, don't pass styles per instance: ❌ `<Box styles={{ padding: '2x' }} />` → ✅ `const Box = tasty({ styles: { padding: '2x' } })`.
25
+ - Style values are **static**. Route anything conditional through a state map plus `mods` (or `tokens` / `styleProps`):
26
+ ❌ `fill: isOpen ? '#primary' : '#surface'` → ✅ `fill: { '': '#surface', open: '#primary' }` with `mods={{ open: isOpen }}`.
27
+ - Keep JavaScript identifiers, calls, computed keys, and interpolated templates
28
+ out of style values. Use token references inside strings for values supplied
29
+ at runtime. Spell out style properties rather than spreading objects; if a
30
+ runtime spread is unavoidable, add a
31
+ `// eslint-disable-next-line tasty/no-style-spread -- reason` comment directly
32
+ above it. `tastyStatic()` cannot use spreads.
33
+
34
+ ## 2. Property names
35
+
36
+ Keys are camelCase — a Tasty property or a real CSS property. No kebab-case, no invented names.
37
+
38
+ Prefer the Tasty shorthand over its CSS equivalents:
39
+
40
+ | Use | Instead of |
41
+ | ---------------------------------------- | ------------------------------------------------------------------------------------- |
42
+ | `fill` | `backgroundColor`, `background` |
43
+ | `image` | `backgroundImage` |
44
+ | `border` | `borderColor`, `borderWidth`, `borderStyle`, `borderTop`/`Right`/`Bottom`/`Left` |
45
+ | `radius` | `borderRadius` |
46
+ | `outline` | `outlineColor`, `outlineWidth`, `outlineStyle`, `outlineOffset` |
47
+ | `shadow` | `boxShadow` |
48
+ | `padding` | `paddingTop`/`Right`/`Bottom`/`Left` |
49
+ | `margin` | `marginTop`/`Right`/`Bottom`/`Left` |
50
+ | `inset` | `top`, `right`, `bottom`, `left` |
51
+ | `width` / `height` | `minWidth`/`maxWidth`, `minHeight`/`maxHeight` |
52
+ | `flow` | `flexDirection`, `flexWrap`, `flexFlow`, `gridAutoFlow` |
53
+ | `preset` | `fontSize`, `lineHeight`, `letterSpacing`, `fontWeight`, `fontStyle`, `textTransform` |
54
+ | `font` | `fontFamily` |
55
+ | `scrollbar` | `scrollbarWidth`, `scrollbarColor`, `scrollbarGutter` |
56
+ | `gridColumns` / `gridRows` / `gridAreas` | `gridTemplateColumns` / `Rows` / `Areas` |
57
+ | `textOverflow: 'ellipsis / 3'` | `lineClamp` |
58
+ | `hide: true` | `display: 'none'` |
59
+ | `flexGrow` / `flexShrink` / `flexBasis` | `flex` |
60
+
61
+ Use logical category styles when layout must follow writing mode or direction: `blockSize`/`inlineSize`, `blockPadding`/`inlinePadding`, `blockMargin`/`inlineMargin`, `blockInset`/`inlineInset`, `blockScrollMargin`/`inlineScrollMargin`, `blockScrollPadding`/`inlineScrollPadding`, and `blockBorder`/`inlineBorder`. Use `start`/`end` value modifiers; do not replace them with physical sides. Native logical CSS properties remain valid as ordinary keys when an individual declaration is needed.
62
+
63
+ The last row goes the other way — longhands over the shorthand — because `flex` is lossy: it resets the components you omit to non-initial values (`flex: '0'` silently sets `flex-basis: 0%`) and cannot express `flexShrink: 0` at all. The longhands also carry separate state maps.
64
+
65
+ ## 3. Values
66
+
67
+ ### Tokens
68
+
69
+ | Syntax | Meaning |
70
+ | --------------------- | -------------------------------------------------------------------------------------------------- |
71
+ | `#name` | color token → `var(--name-color)` |
72
+ | `#name.50` | token at 50% opacity — digits are a decimal fraction: `.5` = `.50` = 50%, `.05` = 5%, `.100` = 10% |
73
+ | `#name.$opacity` | opacity from a custom property |
74
+ | `#clear` / `#current` | `transparent` / `currentcolor` |
75
+ | `#a+#b.04` | `#b` at 4% opacity over `#a`, as one color; layers stack left to right (`#a+#b.1+#c.04`) |
76
+ | `$name` | custom property → `var(--name)` |
77
+ | `(#a, #b)` | fallback chain |
78
+ | `$$name` / `##name` | the custom property _name_ (not its value) — inside `transition` |
79
+ | `$$name(…)` | call a CSS `@function` declared via `@function`, `useFunction`, or config |
80
+
81
+ - ❌ `#f5f5f5`, `rgb(0 0 0)`, `oklch(…)`, `okhsl(…)`, `okhst(…)`, `red` → ✅ `#surface` (add the token to the config if it doesn't exist).
82
+ - CSS system colors (`Canvas`, `CanvasText`, `Highlight`, `ButtonText`, `GrayText`, …) are the exception, for `forced-colors` styles: hold one in a token (`'#forced-border': 'CanvasText'`) or write it under a `@media(forced-colors: active)` state.
83
+ - ❌ `var(--gap)` → ✅ `$gap` · ❌ `$accent-color` → ✅ `#accent` · ❌ `transparent` → ✅ `#clear` · ❌ `currentColor` → ✅ `#current`.
84
+ - `#clear` is a default replace token for `transparent`, so `#clear.5` and `#clear.$opacity` stay transparent. It does not read `--clear-color`; override it through `replaceTokens` if needed.
85
+ - A `$name` must be declared as a `'$name': value` key in the same styles object, or in the config.
86
+ - Names are case-sensitive and start lowercase — `$myVar` → `--myVar`; a leading capital folds (`$Foo` → `--foo`). Prefer kebab-case.
87
+ - A `$name` reference is untyped: it fills the first free slot in a shorthand (`border: '1bw $my-style'` → the line style). Write colors as `#name`; `$name-color` is a fallback for pointing at a raw CSS custom property that holds a color.
88
+ - `preset` and `transition` take token _names_, not values, so a `$name` cannot stand in for one (it warns in dev and is ignored).
89
+
90
+ ### Units
91
+
92
+ Tasty units and their defaults: `x` 8px spacing step, `r` 6px radius, `cr` 10px card radius, `bw` 1px border width, `ow` 3px outline width, `sf` → `minmax(0, Nfr)`. They compile to literal values; change them through `units` in the config, not with `$gap`/`$radius` tokens. All CSS units work too, plus anything in `units` in the config. Any other unit is an error. Inside `@media(…)` / `@(…)` conditions units resolve to their literal length (`@media(w < 40x)` → `width < 320px`), unless the project points that unit at a custom property; then write query lengths in `px`, `em`, or `rem`.
93
+
94
+ Prefer units over raw pixels: `8px` → `1x` … `64px` → `8x`; `radius: '6px'` → `'1r'`; `border: '1px …'` → `'1bw …'`.
95
+
96
+ ### Math
97
+
98
+ ❌ `calc(100% - 2x)` → ✅ `(100% - 2x)`. Parentheses are wrapped in `calc()` automatically — and must be balanced.
99
+
100
+ ### `true`
101
+
102
+ `true` means "the design-system default" and is accepted **only** by: `border`, `radius`, `outline`, `shadow`, `padding`, `margin`, `gap`, `inset`, `width`, `height`, `color`, `fade`, `preset`, `font`, `scrollbar`, `scrollMargin`, `scrollPadding`, and the enhanced logical category styles listed above, plus `hide`. Anywhere else it is an error.
103
+
104
+ ### `!important`
105
+
106
+ Never use it. Tasty owns specificity through doubled selectors and state ordering; `!important` breaks that. Express the exception as a state instead.
107
+
108
+ ### Modifiers
109
+
110
+ A value is `[values…] [modifiers…]`, and several groups can be comma-separated (later groups override earlier ones). A group that names **direction** modifiers takes a **single** value, applied to every direction it names — per-side values come from comma groups. A group naming no direction keeps plain CSS shorthand order (1–4 values). (`inset` + `dock` is the one exception: a second value insets the spanned sides.) Only the modifiers a property knows are valid:
111
+
112
+ | Property | Modifiers |
113
+ | -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
114
+ | `padding`, `margin`, `fade` | `top` `right` `bottom` `left` |
115
+ | `inset` | the four directions + `dock` |
116
+ | `border` | the four directions + `solid` `dashed` `dotted` `double` `groove` `ridge` `inset` `outset` `none` `hidden` |
117
+ | logical axis spacing/inset styles | `start` `end` |
118
+ | `blockBorder`, `inlineBorder` | `start` `end` + the border style keywords above |
119
+ | `outline` | the style keywords above |
120
+ | `radius` | `top` `right` `bottom` `left`, corners `top-left` `top-right` `bottom-right` `bottom-left`, `inherit` + shapes `round` `ellipse` `leaf` `backleaf` |
121
+ | `width`, `height`, `blockSize`, `inlineSize` | `min` `max` `fixed` |
122
+ | `flow` | `row` `column` `row-reverse` `column-reverse` `wrap` `nowrap` `dense` |
123
+ | `overflow` | `visible` `hidden` `scroll` `clip` `auto` `overlay` |
124
+ | `position` | `static` `relative` `absolute` `fixed` `sticky` |
125
+ | `shadow` | `inset` |
126
+ | `preset` | `name / strong` (or `bold`) `italic` `icon` `tight` `normal` |
127
+ | `scrollbar` | `thin` `auto` `none` `stable` `both-edges` `always` |
128
+ | box properties | `longhand` — emit CSS longhands instead of the shorthand |
129
+
130
+ Directional modifiers beat placeholder zeros:
131
+
132
+ - ❌ `padding: '0 0 2x 0'` → ✅ `padding: '2x bottom'`
133
+ - ❌ `padding: '1x 1x 2x 1x'` → ✅ `padding: '1x, 2x bottom'`
134
+ - ❌ `border: '0 0 1bw 0'` — four tokens parse as _one_ border value, so this renders no border at all → ✅ `border: '1bw bottom'`
135
+ - ❌ `padding: '2x 4x top right'` — a directional group takes one value, so `4x` is dropped → ✅ `padding: '2x top, 4x right'`
136
+ - ❌ `fade: '3x 1x top bottom'` → ✅ `fade: '3x top, 1x bottom'`
137
+
138
+ Value-only properties reject both colors and modifiers: `gap`, `columnGap`, `rowGap`, `opacity`, `zIndex`, `order`, `flexGrow`, `flexShrink`, `flexBasis`, `aspectRatio`, `lineClamp`, and `tabSize`. Logical axis category styles accept one or two values in start/end order and the `start`, `end`, and `longhand` modifiers. `fill`, `color`, `caretColor`, and `accentColor` take a color only (use `#clear` for transparent). An overlay is a compound color, in any color slot: ❌ `fill: '#surface #dark.04'` (deprecated overlay layer) · ❌ `fill: '#dark.04, #surface'` (half-transparent mix) → ✅ `fill: '#surface+#dark.04'`. Write it as one word, with no spaces around `+`. Every layer after the first needs an opacity suffix, and its token must be opaque: a translucent layer token, or one that is `#clear` in some state, leaves the result see-through, so vary the suffix (`#surface+#dark.$hover`) or the whole compound per state instead. A comma mix in `fill` is deprecated too: ❌ `fill: '#dark 4%, #surface'` → ✅ `fill: '#surface+#dark.04'`. For any other mix, write `color-mix()` itself: ✅ `fill: 'color-mix(in srgb, #dark $weight, #surface)'`.
139
+
140
+ ### `transition`
141
+
142
+ Use semantic names, not CSS property names: `fade` `fill` `color` `theme` `border` `radius` `shadow` `outline` `preset` `text` `gap` `opacity` `translate` `rotate` `scale` `filter` `image` `background` `width` `height` `zIndex` `inset`.
143
+
144
+ ❌ `transition: 'background-color 0.2s'` → ✅ `transition: 'fill'`
145
+
146
+ Omit the duration to use `$fill-transition` with `$transition` as fallback, or
147
+ use a duration token explicitly (`transition: 'fill $transition'`). Avoid raw
148
+ time values in duration slots. An explicit zero can be useful to disable motion.
149
+
150
+ Use `transition` when defining a complete transition, and the native CSS
151
+ `animation` shorthand when defining a complete animation. Tasty accepts
152
+ `animation` directly and tracks local keyframes referenced by it; no special
153
+ animation handler is needed. Use duration tokens in either form. Keep
154
+ `transitionDuration`, `animationDuration`, and other motion longhands when a
155
+ state or extension changes only one part of an existing effect. A shorthand
156
+ resets omitted parts, including an animation's timeline and range.
157
+
158
+ ## 4. State maps
159
+
160
+ A property value can be an object of `state: value`. Key order is priority — later keys win.
161
+
162
+ | Key | Generated selector |
163
+ | ------------------------ | ----------------------------------------------- |
164
+ | `hovered` | `[data-hovered]` (boolean modifier from `mods`) |
165
+ | `theme=danger` | `[data-theme="danger"]` (value modifier) |
166
+ | `:hover` | pseudo-class |
167
+ | `.active` | class selector |
168
+ | `[aria-expanded="true"]` | attribute selector |
169
+ | `hovered & .active` | AND |
170
+ | `hovered \| focused` | OR (`,` also means OR) |
171
+ | `!disabled` | NOT |
172
+ | `hovered ^ focused` | XOR — exactly one (keep chains ≤ 4 operands) |
173
+
174
+ Precedence `!` > `^` > `|` > `&`; use parentheses to override.
175
+
176
+ Rules:
177
+
178
+ 1. **`''` comes first.** The bare default is the lowest-priority state. Written later, it triggers a `MISPLACED_DEFAULT_STATE` warning and Tasty moves it to the front.
179
+ 2. **Every state map needs `''` or `_`** — except when extending (`tasty(Parent, …)`), where omitting `''` merges into the parent's states and including `''` replaces them wholesale.
180
+ 3. **`_` is standalone-only** and always first (with `''` right after it, if present). `_` is a never-negated fallback floor for cases where a higher-priority branch may be _unknown_ (`@supports`, container queries). If a map contains only `_` and `''`, drop the `''`.
181
+ 4. **No nested maps:** ❌ `{ hovered: { pressed: 'x' } }` → ✅ `{ 'hovered & pressed': 'x' }`
182
+ 5. **State keys never sit at the top level** of a styles object — `:hover`, `.active`, `[open]` belong inside a property value.
183
+ 6. **Write keys Tasty can fully read.** Names start with a letter (a single letter is fine: `x` → `[data-x]`); join states with an operator (`hovered & focused`, not `hovered focused`); no space between `@media` and `(`. Tasty warns (`INVALID_STATE_KEY`) and skips what it cannot read.
184
+ 7. **Prefer automatic native states:** use `disabled`, `checked`, and `hidden` in Tasty component styles instead of `[disabled]`, `[checked]`, and `[hidden]`. Tasty sets `data-disabled`, `data-checked`, and `data-hidden` from the native props automatically.
185
+
186
+ ```jsx
187
+ color: { '': '#text', hovered: '#accent', disabled: '#text.40' }
188
+ ```
189
+
190
+ Advanced states:
191
+
192
+ | Prefix | Use | Example |
193
+ | -------------- | -------------------------------------------------------------------------------- | --------------------------------------------------- |
194
+ | `@media(…)` | media query; dimensions `w` `h`; types `@media:print` `:screen` `:all` `:speech` | `@media(w < 768px)`, `@media(600px <= w < 1200px)` |
195
+ | `@(…)` | container query; dimensions `w` `h` `is` `bs` | `@(layout, w >= 600px)`, `@($variant=primary)` |
196
+ | `@supports(…)` | feature query; `$` first argument tests a selector | `@supports(display: grid)`, `@supports($, :has(*))` |
197
+ | `@root(…)` | condition on `:root` | `@root(schema=dark)` |
198
+ | `@parent(…)` | condition on an ancestor; `, >` for the direct parent | `@parent(hovered, >)` |
199
+ | `@own(…)` | a sub-element's own state — **only inside sub-element styles** | `@own(:hover)` |
200
+ | `@starting` | `@starting-style` entry animation | `@starting` |
201
+ | `@name` | project state alias | `@mobile` |
202
+
203
+ - At root level write the selector directly: ❌ `'@own(:hover)'` → ✅ `':hover'`.
204
+ - `@name` aliases must exist in `states` in the config or be declared locally as an `'@name': '<state expression>'` key; alias keys start with `@` and their value must be a valid state expression.
205
+ - `:is()` / `:has()` / `:not()` / `:where()` work in state keys but support at most 2 levels of nested parentheses, and `:has()` is expensive — prefer `@parent()`, `@own()` and modifiers.
206
+
207
+ When extending a parent's state map: `'@inherit'` reuses the parent's value for that state, `null` removes a state (or resets a property, letting recipes fill in), `false` is a tombstone that blocks it entirely.
208
+
209
+ ## 5. Sub-elements
210
+
211
+ A **capitalized** key targets `[data-element="Name"]`, and its value must be a style object.
212
+
213
+ ```jsx
214
+ styles: { Title: { preset: 'h3' }, Icon: { $: '>', color: { '': '#text', '@own(:last-child)': '#accent' } } }
215
+ ```
216
+
217
+ ❌ nested-selector keys (`'& .title'`, `'&:hover'`) → ✅ sub-elements and state maps. Use the `$` affix property inside a sub-element to control how its selector attaches (`>` direct child, `@` placeholder for the element itself, `&::before` for a root pseudo-element).
218
+
219
+ When `$` ends in a pseudo-element, `@own(…)` is the pseudo-element's own state (`'@own(:focus)'` → `::part(label):where(:focus)`). A pseudo-element has no attributes, classes, or tree position, so `@own([open])`, `@own(hovered)`, or `@own(:first-child)` there is ignored with a warning. Put a condition on the element before the pseudo-element in `$`: `$: 'a[rel="next"]::before'`.
220
+
221
+ ## 6. Special top-level keys
222
+
223
+ | Key | Shape |
224
+ | ---------------- | ----------------------------------------------------------------------------------------------------------- |
225
+ | `@keyframes` | `{ name: { '0%': styles, … } }` |
226
+ | `@property` | `{ '$name': { syntax, inherits, initialValue } }` |
227
+ | `@font-face` | `{ 'Family Name': descriptors \| descriptors[] }` |
228
+ | `@counter-style` | `{ name: descriptors }` |
229
+ | `@function` | `{ '$$name': { args, returns?, result, '$local'? } }` |
230
+ | `recipe` | a **string** of configured recipe names: `'card elevated'`, `'reset input / autofill'`, `'none / disabled'` |
231
+
232
+ `recipe` resolves on the component root and independently in each sub-element's styles: `styles: { Panel: { recipe: 'card elevated' } }` is supported. Configured recipe definitions must be flat and cannot contain their own `recipe` key; references inside recipe values are not recursively expanded. Compose names where the recipe is applied, not inside `configure({ recipes })`. See [Recipes](dsl.md#recipes).
233
+
234
+ At-rule keys match the real CSS at-rule names, so they are kebab-case, not camelCase. Inside `@function`, the callable is `$$name` but its parameters and local variables are `$name`:
235
+
236
+ ```jsx
237
+ styles: {
238
+ '@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
239
+ margin: '$$negative(2x) top',
240
+ }
241
+ ```
242
+
243
+ ## 7. `tastyStatic()`
244
+
245
+ The selector must be a string literal and valid CSS. Values must be static — strings, numbers, booleans, `null`, or objects/arrays of those. No variables, template literals, function calls, or spreads.
246
+
247
+ ## 8. Checklist
248
+
249
+ - Token, preset, recipe, unit and `@alias` names exist in the project config.
250
+ - Tasty shorthand chosen over CSS longhands; `flexGrow`/`flexShrink`/`flexBasis` over `flex`; `hide: true` over `display: 'none'`.
251
+ - Logical category styles keep native `block`/`inline` declarations and accept `start`/`end`, never physical direction modifiers.
252
+ - Colors are `#tokens`, not hex/rgb/oklch/named; `$prop` not `var(--prop)`.
253
+ - Spacing uses `x`/`r`/`bw`/`ow` units; math uses `(…)`, not `calc(…)`.
254
+ - `true` only on the properties that accept it; no `!important`.
255
+ - Modifiers valid for the property; directional shorthand instead of placeholder zeros.
256
+ - Every state map starts with `''` (or `_`), is flat, and lives inside a property value.
257
+ - `@own()` only inside sub-elements; sub-element keys are capitalized and hold objects.
258
+ - At-rule keys are kebab-case (`@property`, `@font-face`, `@counter-style`, `@function`); `@function` names use `$$`, their args and locals use `$`.
259
+ - Values are static; dynamic behavior comes from `mods` / `tokens` / `styleProps`.