@tenphi/tasty 0.0.0-snapshot.1d29633 → 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.
- package/README.md +152 -134
- package/dist/{babel-Cg-mJV_t.d.ts → babel-rZcEwPLM.d.ts} +2 -3
- package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
- package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
- package/dist/chunks/build-config-CL4eRu2z.js +42 -0
- package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
- package/dist/{collector-BMT05AmU.js → chunks/collector-D2ARGT2L.js} +21 -117
- package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
- package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
- package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
- package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
- package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
- package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
- package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
- package/dist/chunks/debug-D8pg9RGI.js +502 -0
- package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
- package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
- package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
- package/dist/chunks/hydration-TRcz5vnk.js +41 -0
- package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
- package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
- package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
- package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
- package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
- package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
- package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
- package/dist/{merge-styles-CkAcnd0Z.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
- package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
- package/dist/{css-writer-b02uBqNF.js → chunks/zero-engine-gJrKBRiw.js} +6 -121
- package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
- package/dist/{collector-BFuqdF2F.d.ts → collector-w4mBj5gd.d.ts} +23 -4
- package/dist/{config-DmFxnBxg.d.ts → config-CZWCzBr6.d.ts} +171 -72
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/{index-D1nMkpUe.d.ts → index-G9JuwM9p.d.ts} +263 -247
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -921
- package/dist/{merge-styles-Cx_6ySBv.d.ts → merge-styles-VXwJ0Frr.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +3 -2
- package/dist/ssr/astro-middleware-static.js +0 -11
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +3 -2
- package/dist/ssr/astro-middleware.js +0 -12
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +40 -6
- package/dist/ssr/astro.js +157 -93
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/index.d.ts +10 -11
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +128 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -8
- package/dist/ssr/next.js +29 -43
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -22
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/{index-LC3O3Jj4.d.ts → types-JEY8PVYP.d.ts} +862 -811
- package/dist/zero/babel.d.ts +1 -1
- package/dist/zero/babel.js +41 -107
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +6 -7
- package/dist/zero/index.js +1 -1
- package/dist/zero/next.d.ts +3 -5
- package/dist/zero/next.js +0 -31
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +13 -8
- package/docs/adoption.md +56 -31
- package/docs/ai-agents.md +107 -80
- package/docs/comparison.md +69 -40
- package/docs/configuration.md +179 -114
- package/docs/debug.md +19 -7
- package/docs/design-system.md +41 -22
- package/docs/dsl.md +310 -201
- package/docs/getting-started.md +64 -41
- package/docs/injector.md +63 -26
- package/docs/methodology.md +44 -38
- package/docs/migration-v3.md +49 -49
- package/docs/pipeline.md +32 -8
- package/docs/plugins.md +38 -34
- package/docs/react-api.md +67 -44
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +219 -61
- package/docs/styles.md +95 -18
- package/docs/tasty-static.md +138 -105
- package/package.json +104 -33
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/collector-BMT05AmU.js.map +0 -1
- package/dist/config-DF93rL3u.js +0 -12661
- package/dist/config-DF93rL3u.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-B5ybnMP1.js +0 -1529
- package/dist/core-B5ybnMP1.js.map +0 -1
- package/dist/css-writer-b02uBqNF.js.map +0 -1
- package/dist/format-global-rules-DklyaXv-.js +0 -22
- package/dist/format-global-rules-DklyaXv-.js.map +0 -1
- package/dist/format-rules-Cs4e3M9m.js +0 -130
- package/dist/format-rules-Cs4e3M9m.js.map +0 -1
- package/dist/hydrate-aaUSNJZJ.js +0 -37
- package/dist/hydrate-aaUSNJZJ.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-BedEzEXk.js +0 -424
- package/dist/keyframes-BedEzEXk.js.map +0 -1
- package/dist/merge-styles-CkAcnd0Z.js.map +0 -1
- package/dist/resolve-recipes-CiyLtJG9.js +0 -144
- package/dist/resolve-recipes-CiyLtJG9.js.map +0 -1
package/docs/ai-agents.md
CHANGED
|
@@ -16,12 +16,18 @@ Color tokens (`#name`), custom properties (`$name`), `preset` names, `recipe` na
|
|
|
16
16
|
const Card = tasty({ as: 'div', styles: { … }, styleProps: ['padding'] }); // new component
|
|
17
17
|
const Hero = tasty(Card, { styles: { … } }); // extend a component
|
|
18
18
|
const cls = useStyles({ … }); // ad-hoc class name
|
|
19
|
-
tastyStatic('.card', { … }); // build-time
|
|
19
|
+
tastyStatic('.card', { … }); // build-time extraction
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
- Wrap, don't pass styles per instance: ❌ `<Box styles={{ padding: '2x' }} />` → ✅ `const Box = tasty({ styles: { padding: '2x' } })`.
|
|
23
23
|
- Style values are **static**. Route anything conditional through a state map plus `mods` (or `tokens` / `styleProps`):
|
|
24
24
|
❌ `fill: isOpen ? '#primary' : '#surface'` → ✅ `fill: { '': '#surface', open: '#primary' }` with `mods={{ open: isOpen }}`.
|
|
25
|
+
- Keep JavaScript identifiers, calls, computed keys, and interpolated templates
|
|
26
|
+
out of style values. Use token references inside strings for values supplied
|
|
27
|
+
at runtime. Spell out style properties rather than spreading objects; if a
|
|
28
|
+
runtime spread is unavoidable, add a
|
|
29
|
+
`// eslint-disable-next-line tasty/no-style-spread -- reason` comment directly
|
|
30
|
+
above it. `tastyStatic()` cannot use spreads.
|
|
25
31
|
|
|
26
32
|
## 2. Property names
|
|
27
33
|
|
|
@@ -29,26 +35,28 @@ Keys are camelCase — a Tasty property or a real CSS property. No kebab-case, n
|
|
|
29
35
|
|
|
30
36
|
Prefer the Tasty shorthand over its CSS equivalents:
|
|
31
37
|
|
|
32
|
-
| Use
|
|
33
|
-
|
|
34
|
-
| `fill`
|
|
35
|
-
| `image`
|
|
36
|
-
| `border`
|
|
37
|
-
| `radius`
|
|
38
|
-
| `outline`
|
|
39
|
-
| `shadow`
|
|
40
|
-
| `padding`
|
|
41
|
-
| `margin`
|
|
42
|
-
| `inset`
|
|
43
|
-
| `width` / `height`
|
|
44
|
-
| `flow`
|
|
45
|
-
| `preset`
|
|
46
|
-
| `font`
|
|
47
|
-
| `scrollbar`
|
|
48
|
-
| `gridColumns` / `gridRows` / `gridAreas` | `gridTemplateColumns` / `Rows` / `Areas`
|
|
49
|
-
| `textOverflow: 'ellipsis / 3'`
|
|
50
|
-
| `hide: true`
|
|
51
|
-
| `flexGrow` / `flexShrink` / `flexBasis`
|
|
38
|
+
| Use | Instead of |
|
|
39
|
+
| ---------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
40
|
+
| `fill` | `backgroundColor`, `background` |
|
|
41
|
+
| `image` | `backgroundImage` |
|
|
42
|
+
| `border` | `borderColor`, `borderWidth`, `borderStyle`, `borderTop`/`Right`/`Bottom`/`Left` |
|
|
43
|
+
| `radius` | `borderRadius` |
|
|
44
|
+
| `outline` | `outlineColor`, `outlineWidth`, `outlineStyle`, `outlineOffset` |
|
|
45
|
+
| `shadow` | `boxShadow` |
|
|
46
|
+
| `padding` | `paddingTop`/`Right`/`Bottom`/`Left` |
|
|
47
|
+
| `margin` | `marginTop`/`Right`/`Bottom`/`Left` |
|
|
48
|
+
| `inset` | `top`, `right`, `bottom`, `left` |
|
|
49
|
+
| `width` / `height` | `minWidth`/`maxWidth`, `minHeight`/`maxHeight` |
|
|
50
|
+
| `flow` | `flexDirection`, `flexWrap`, `flexFlow`, `gridAutoFlow` |
|
|
51
|
+
| `preset` | `fontSize`, `lineHeight`, `letterSpacing`, `fontWeight`, `fontStyle`, `textTransform` |
|
|
52
|
+
| `font` | `fontFamily` |
|
|
53
|
+
| `scrollbar` | `scrollbarWidth`, `scrollbarColor`, `scrollbarGutter` |
|
|
54
|
+
| `gridColumns` / `gridRows` / `gridAreas` | `gridTemplateColumns` / `Rows` / `Areas` |
|
|
55
|
+
| `textOverflow: 'ellipsis / 3'` | `lineClamp` |
|
|
56
|
+
| `hide: true` | `display: 'none'` |
|
|
57
|
+
| `flexGrow` / `flexShrink` / `flexBasis` | `flex` |
|
|
58
|
+
|
|
59
|
+
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.
|
|
52
60
|
|
|
53
61
|
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.
|
|
54
62
|
|
|
@@ -56,23 +64,23 @@ The last row goes the other way — longhands over the shorthand — because `fl
|
|
|
56
64
|
|
|
57
65
|
### Tokens
|
|
58
66
|
|
|
59
|
-
| Syntax
|
|
60
|
-
|
|
61
|
-
| `#name`
|
|
62
|
-
| `#name.50`
|
|
63
|
-
| `#name.$opacity`
|
|
64
|
-
| `#clear` / `#current` | `transparent` / `currentcolor`
|
|
65
|
-
| `$name`
|
|
66
|
-
| `(#a, #b)`
|
|
67
|
-
| `$$name` / `##name`
|
|
68
|
-
| `$$name(…)`
|
|
67
|
+
| Syntax | Meaning |
|
|
68
|
+
| --------------------- | ------------------------------------------------------------------------- |
|
|
69
|
+
| `#name` | color token → `var(--name-color)` |
|
|
70
|
+
| `#name.50` | token at 50% opacity (`0`–`100`) |
|
|
71
|
+
| `#name.$opacity` | opacity from a custom property |
|
|
72
|
+
| `#clear` / `#current` | `transparent` / `currentcolor` |
|
|
73
|
+
| `$name` | custom property → `var(--name)` |
|
|
74
|
+
| `(#a, #b)` | fallback chain |
|
|
75
|
+
| `$$name` / `##name` | the custom property _name_ (not its value) — inside `transition` |
|
|
76
|
+
| `$$name(…)` | call a CSS `@function` declared via `@function`, `useFunction`, or config |
|
|
69
77
|
|
|
70
78
|
- ❌ `#f5f5f5`, `rgb(0 0 0)`, `oklch(…)`, `okhsl(…)`, `red` → ✅ `#surface` (add the token to the config if it doesn't exist).
|
|
71
79
|
- ❌ `var(--gap)` → ✅ `$gap` · ❌ `$accent-color` → ✅ `#accent` · ❌ `transparent` → ✅ `#clear` · ❌ `currentColor` → ✅ `#current`.
|
|
72
80
|
- A `$name` must be declared as a `'$name': value` key in the same styles object, or in the config.
|
|
73
81
|
- Names are case-sensitive and start lowercase — `$myVar` → `--myVar`; a leading capital folds (`$Foo` → `--foo`). Prefer kebab-case.
|
|
74
82
|
- 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.
|
|
75
|
-
- `preset` and `transition` take token
|
|
83
|
+
- `preset` and `transition` take token _names_, not values, so a `$name` cannot stand in for one (it warns in dev and is ignored).
|
|
76
84
|
|
|
77
85
|
### Units
|
|
78
86
|
|
|
@@ -86,7 +94,7 @@ Prefer units over raw pixels: `8px` → `1x` … `64px` → `8x`; `radius: '6px'
|
|
|
86
94
|
|
|
87
95
|
### `true`
|
|
88
96
|
|
|
89
|
-
`true` means "the design-system default" and is accepted **only** by: `border`, `radius`, `outline`, `shadow`, `padding`, `margin`, `gap`, `inset`, `width`, `height`, `fill`, `color`, `fade`, `preset`, `font`, `scrollbar`, `hide`. Anywhere else it is an error.
|
|
97
|
+
`true` means "the design-system default" and is accepted **only** by: `border`, `radius`, `outline`, `shadow`, `padding`, `margin`, `gap`, `inset`, `width`, `height`, `fill`, `color`, `fade`, `preset`, `font`, `scrollbar`, `scrollMargin`, `scrollPadding`, and the enhanced logical category styles listed above, plus `hide`. Anywhere else it is an error.
|
|
90
98
|
|
|
91
99
|
### `!important`
|
|
92
100
|
|
|
@@ -96,51 +104,65 @@ Never use it. Tasty owns specificity through doubled selectors and state orderin
|
|
|
96
104
|
|
|
97
105
|
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:
|
|
98
106
|
|
|
99
|
-
| Property
|
|
100
|
-
|
|
101
|
-
| `padding`, `margin`, `inset`, `fade` | `top` `right` `bottom` `left`
|
|
102
|
-
| `border`
|
|
103
|
-
|
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
|
|
|
107
|
+
| Property | Modifiers |
|
|
108
|
+
| ------------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
|
109
|
+
| `padding`, `margin`, `inset`, `fade` | `top` `right` `bottom` `left` |
|
|
110
|
+
| `border` | the four directions + `solid` `dashed` `dotted` `double` `groove` `ridge` `inset` `outset` `none` `hidden` |
|
|
111
|
+
| logical axis spacing/inset styles | `start` `end` |
|
|
112
|
+
| `blockBorder`, `inlineBorder` | `start` `end` + the border style keywords above |
|
|
113
|
+
| `outline` | the style keywords above |
|
|
114
|
+
| `radius` | `top` `right` `bottom` `left` + shapes `round` `ellipse` `leaf` `backleaf` |
|
|
115
|
+
| `width`, `height`, `blockSize`, `inlineSize` | `min` `max` `fixed` |
|
|
116
|
+
| `flow` | `row` `column` `row-reverse` `column-reverse` `wrap` `nowrap` `dense` |
|
|
117
|
+
| `overflow` | `visible` `hidden` `scroll` `clip` `auto` `overlay` |
|
|
118
|
+
| `position` | `static` `relative` `absolute` `fixed` `sticky` |
|
|
119
|
+
| `shadow` | `inset` |
|
|
120
|
+
| `preset` | `name / strong` (or `bold`) `italic` `icon` `tight` |
|
|
121
|
+
| box properties | `longhand` — emit CSS longhands instead of the shorthand |
|
|
112
122
|
|
|
113
123
|
Directional modifiers beat placeholder zeros:
|
|
114
124
|
|
|
115
125
|
- ❌ `padding: '0 0 2x 0'` → ✅ `padding: '2x bottom'`
|
|
116
126
|
- ❌ `padding: '1x 1x 2x 1x'` → ✅ `padding: '1x, 2x bottom'`
|
|
117
|
-
- ❌ `border: '0 0 1bw 0'` — four tokens parse as
|
|
127
|
+
- ❌ `border: '0 0 1bw 0'` — four tokens parse as _one_ border value, so this renders no border at all → ✅ `border: '1bw bottom'`
|
|
118
128
|
- ❌ `padding: '2x 4x top right'` — a directional group takes one value, so `4x` is dropped → ✅ `padding: '2x top, 4x right'`
|
|
119
129
|
- ❌ `fade: '3x 1x top bottom'` → ✅ `fade: '3x top, 1x bottom'`
|
|
120
130
|
|
|
121
|
-
Value-only properties reject both colors and modifiers: `gap`, `columnGap`, `rowGap`, `opacity`, `zIndex`, `order`, `flexGrow`, `flexShrink`, `flexBasis`, `aspectRatio`, `lineClamp`, `tabSize`, `
|
|
131
|
+
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` and `color` take a color (plus `none` / `transparent`); `caretColor` and `accentColor` take a color only.
|
|
122
132
|
|
|
123
133
|
### `transition`
|
|
124
134
|
|
|
125
135
|
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` `flow` `dimension`.
|
|
126
136
|
|
|
127
|
-
❌ `transition: 'background-color 0.2s'` → ✅ `transition: 'fill
|
|
137
|
+
❌ `transition: 'background-color 0.2s'` → ✅ `transition: 'fill'`
|
|
138
|
+
|
|
139
|
+
Omit the duration to use `$fill-transition` with `$transition` as fallback, or
|
|
140
|
+
use a duration token explicitly (`transition: 'fill $transition'`). Avoid raw
|
|
141
|
+
time values in duration slots. An explicit zero can be useful to disable motion.
|
|
142
|
+
|
|
143
|
+
Use `transition` when defining a complete transition, and the native CSS
|
|
144
|
+
`animation` shorthand when defining a complete animation. Tasty accepts
|
|
145
|
+
`animation` directly and tracks local keyframes referenced by it; no special
|
|
146
|
+
animation handler is needed. Use duration tokens in either form. Keep
|
|
147
|
+
`transitionDuration`, `animationDuration`, and other motion longhands when a
|
|
148
|
+
state or extension changes only one part of an existing effect. A shorthand
|
|
149
|
+
resets omitted parts, including an animation's timeline and range.
|
|
128
150
|
|
|
129
151
|
## 4. State maps
|
|
130
152
|
|
|
131
153
|
A property value can be an object of `state: value`. Key order is priority — later keys win.
|
|
132
154
|
|
|
133
|
-
| Key
|
|
134
|
-
|
|
135
|
-
| `hovered`
|
|
136
|
-
| `theme=danger`
|
|
137
|
-
| `:hover`
|
|
138
|
-
| `.active`
|
|
139
|
-
| `[aria-expanded="true"]` | attribute selector
|
|
140
|
-
| `hovered & .active`
|
|
141
|
-
| `hovered \| focused`
|
|
142
|
-
| `!disabled`
|
|
143
|
-
| `hovered ^ focused`
|
|
155
|
+
| Key | Generated selector |
|
|
156
|
+
| ------------------------ | ----------------------------------------------- |
|
|
157
|
+
| `hovered` | `[data-hovered]` (boolean modifier from `mods`) |
|
|
158
|
+
| `theme=danger` | `[data-theme="danger"]` (value modifier) |
|
|
159
|
+
| `:hover` | pseudo-class |
|
|
160
|
+
| `.active` | class selector |
|
|
161
|
+
| `[aria-expanded="true"]` | attribute selector |
|
|
162
|
+
| `hovered & .active` | AND |
|
|
163
|
+
| `hovered \| focused` | OR (`,` also means OR) |
|
|
164
|
+
| `!disabled` | NOT |
|
|
165
|
+
| `hovered ^ focused` | XOR — exactly one (keep chains ≤ 4 operands) |
|
|
144
166
|
|
|
145
167
|
Precedence `!` > `^` > `|` > `&`; use parentheses to override.
|
|
146
168
|
|
|
@@ -148,9 +170,11 @@ Rules:
|
|
|
148
170
|
|
|
149
171
|
1. **`''` comes first.** The bare default is the lowest-priority state; placing it later would override everything above it.
|
|
150
172
|
2. **Every state map needs `''` or `_`** — except when extending (`tasty(Parent, …)`), where omitting `''` merges into the parent's states and including `''` replaces them wholesale.
|
|
151
|
-
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
|
|
173
|
+
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 `''`.
|
|
152
174
|
4. **No nested maps:** ❌ `{ hovered: { pressed: 'x' } }` → ✅ `{ 'hovered & pressed': 'x' }`
|
|
153
175
|
5. **State keys never sit at the top level** of a styles object — `:hover`, `.active`, `[open]` belong inside a property value.
|
|
176
|
+
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.
|
|
177
|
+
7. **Prefer automatic native states:** use `disabled` and `checked` in Tasty component styles instead of `[disabled]` and `[checked]`. The concise states track the corresponding native prop or attribute automatically.
|
|
154
178
|
|
|
155
179
|
```jsx
|
|
156
180
|
color: { '': '#text', hovered: '#accent', disabled: '#text.40' }
|
|
@@ -158,16 +182,16 @@ color: { '': '#text', hovered: '#accent', disabled: '#text.40' }
|
|
|
158
182
|
|
|
159
183
|
Advanced states:
|
|
160
184
|
|
|
161
|
-
| Prefix
|
|
162
|
-
|
|
163
|
-
| `@media(…)`
|
|
164
|
-
| `@(…)`
|
|
165
|
-
| `@supports(…)` | feature query; `$` first argument tests a selector
|
|
166
|
-
| `@root(…)`
|
|
167
|
-
| `@parent(…)`
|
|
168
|
-
| `@own(…)`
|
|
169
|
-
| `@starting`
|
|
170
|
-
| `@name`
|
|
185
|
+
| Prefix | Use | Example |
|
|
186
|
+
| -------------- | -------------------------------------------------------------------------------- | --------------------------------------------------- |
|
|
187
|
+
| `@media(…)` | media query; dimensions `w` `h`; types `@media:print` `:screen` `:all` `:speech` | `@media(w < 768px)`, `@media(600px <= w < 1200px)` |
|
|
188
|
+
| `@(…)` | container query; dimensions `w` `h` `is` `bs` | `@(layout, w >= 600px)`, `@($variant=primary)` |
|
|
189
|
+
| `@supports(…)` | feature query; `$` first argument tests a selector | `@supports(display: grid)`, `@supports($, :has(*))` |
|
|
190
|
+
| `@root(…)` | condition on `:root` | `@root(schema=dark)` |
|
|
191
|
+
| `@parent(…)` | condition on an ancestor; `, >` for the direct parent | `@parent(hovered, >)` |
|
|
192
|
+
| `@own(…)` | a sub-element's own state — **only inside sub-element styles** | `@own(:hover)` |
|
|
193
|
+
| `@starting` | `@starting-style` entry animation | `@starting` |
|
|
194
|
+
| `@name` | project state alias | `@mobile` |
|
|
171
195
|
|
|
172
196
|
- At root level write the selector directly: ❌ `'@own(:hover)'` → ✅ `':hover'`.
|
|
173
197
|
- `@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.
|
|
@@ -187,21 +211,23 @@ styles: { Title: { preset: 'h3' }, Icon: { $: '>@:last-child', color: '#accent'
|
|
|
187
211
|
|
|
188
212
|
## 6. Special top-level keys
|
|
189
213
|
|
|
190
|
-
| Key
|
|
191
|
-
|
|
192
|
-
| `@keyframes`
|
|
193
|
-
| `@property`
|
|
194
|
-
| `@font-face`
|
|
195
|
-
| `@counter-style` | `{ name: descriptors }`
|
|
196
|
-
| `@function`
|
|
197
|
-
| `recipe`
|
|
214
|
+
| Key | Shape |
|
|
215
|
+
| ---------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
216
|
+
| `@keyframes` | `{ name: { '0%': styles, … } }` |
|
|
217
|
+
| `@property` | `{ '$name': { syntax, inherits, initialValue } }` |
|
|
218
|
+
| `@font-face` | `{ 'Family Name': descriptors \| descriptors[] }` |
|
|
219
|
+
| `@counter-style` | `{ name: descriptors }` |
|
|
220
|
+
| `@function` | `{ '$$name': { args, returns?, result, '$local'? } }` |
|
|
221
|
+
| `recipe` | a **string** of configured recipe names: `'card elevated'`, `'reset input / autofill'`, `'none / disabled'` |
|
|
222
|
+
|
|
223
|
+
`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).
|
|
198
224
|
|
|
199
225
|
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`:
|
|
200
226
|
|
|
201
227
|
```jsx
|
|
202
228
|
styles: {
|
|
203
229
|
'@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
|
|
204
|
-
|
|
230
|
+
margin: '$$negative(2x) top',
|
|
205
231
|
}
|
|
206
232
|
```
|
|
207
233
|
|
|
@@ -213,6 +239,7 @@ The selector must be a string literal and valid CSS. Values must be static — s
|
|
|
213
239
|
|
|
214
240
|
- Token, preset, recipe, unit and `@alias` names exist in the project config.
|
|
215
241
|
- Tasty shorthand chosen over CSS longhands; `flexGrow`/`flexShrink`/`flexBasis` over `flex`; `hide: true` over `display: 'none'`.
|
|
242
|
+
- Logical category styles keep native `block`/`inline` declarations and accept `start`/`end`, never physical direction modifiers.
|
|
216
243
|
- Colors are `#tokens`, not hex/rgb/oklch/named; `$prop` not `var(--prop)`.
|
|
217
244
|
- Spacing uses `x`/`r`/`bw`/`ow` units; math uses `(…)`, not `calc(…)`.
|
|
218
245
|
- `true` only on the properties that accept it; no `!important`.
|
package/docs/comparison.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Use this guide when you are deciding whether Tasty is the right tool. If you have already decided to adopt it and need rollout guidance, use the [Adoption Guide](adoption.md) instead.
|
|
4
4
|
|
|
5
|
-
Tasty is
|
|
5
|
+
Tasty is CSS-in-JS for React design systems. It is built for the point where reusable components have enough intersecting states, variants, themes, and extension rules that ordinary selector competition becomes hard to reason about.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Its distinctive guarantee is narrow and concrete: each property’s state map compiles into selectors that cannot compete, so one declared branch wins regardless of CSS source order.
|
|
8
8
|
|
|
9
9
|
That does not require a big upfront configuration step. Tasty's built-in units and normal CSS color values work out of the box, and `okhsl(...)` is available immediately as the recommended path for color authoring. The extra setup comes later if a team wants shared tokens, aliases, recipes, or stricter conventions.
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ Most styling tools focus on one of these layers:
|
|
|
16
16
|
- utility composition
|
|
17
17
|
- atomic CSS generation
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
For design-system teams, that state model can sit alongside tokens, typed style props, recipes, custom units, and sub-element rules. Tasty can therefore define the styling language exposed by shared components, not just another syntax for writing CSS.
|
|
20
20
|
|
|
21
21
|
That is why syntax-level comparisons are often shallow. The more meaningful comparison is about:
|
|
22
22
|
|
|
@@ -29,14 +29,14 @@ That is why syntax-level comparisons are often shallow. The more meaningful comp
|
|
|
29
29
|
|
|
30
30
|
## High-level positioning
|
|
31
31
|
|
|
32
|
-
| System
|
|
33
|
-
|
|
34
|
-
| **Tasty**
|
|
35
|
-
| **Tailwind CSS**
|
|
36
|
-
| **Panda CSS**
|
|
37
|
-
| **vanilla-extract**
|
|
38
|
-
| **StyleX**
|
|
39
|
-
| **Stitches** (deprecated) **/ Emotion** | Component-first CSS-in-JS
|
|
32
|
+
| System | Best described as | Main authoring model | Conflict model | RSC / zero-JS SSG | Best fit |
|
|
33
|
+
| --------------------------------------- | ---------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------------- | ------------------------------------------------------------- |
|
|
34
|
+
| **Tasty** | CSS-in-JS for React design systems | CSS-like objects with state maps, tokens, recipes, style props, and sub-elements | **Mutually exclusive selector resolution** for stateful styles | Yes — hook-free, server components by default | Teams building long-lived shared component APIs |
|
|
35
|
+
| **Tailwind CSS** | Utility-first styling framework | Utility classes in markup | Utility composition, variants, and framework-controlled ordering | Yes — no JS runtime | Product teams optimizing for speed and direct authoring |
|
|
36
|
+
| **Panda CSS** | Typed styling engine with atomic output | Typed style objects, recipes, generated primitives, style props | Atomic CSS with static analysis | Yes — build-time extraction | Teams wanting a DS-friendly engine with typed primitives |
|
|
37
|
+
| **vanilla-extract** | Zero-runtime TS-native stylesheet system | `.css.ts` files, theme contracts, style composition | Standard CSS semantics | Yes — build-time extraction | Teams wanting static CSS and low-level control |
|
|
38
|
+
| **StyleX** | Compiler-based atomic styling system | JS authoring with compiler-generated atomic CSS | Compiler-controlled atomic composition | Yes — compiler-extracted | Large app teams wanting optimized, predictable atomic styling |
|
|
39
|
+
| **Stitches** (deprecated) **/ Emotion** | Component-first CSS-in-JS | Styled components, `css()` APIs, object/string styles | Composition within CSS-in-JS rules | No — requires `'use client'` | Teams optimizing for component DX and flexible styling |
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -69,8 +69,12 @@ This is especially relevant for components with intersecting states such as:
|
|
|
69
69
|
Here is a minimal example. Two CSS rules for a button's background — one for `:hover`, one for `[disabled]`:
|
|
70
70
|
|
|
71
71
|
```css
|
|
72
|
-
.btn:hover
|
|
73
|
-
|
|
72
|
+
.btn:hover {
|
|
73
|
+
background: dodgerblue;
|
|
74
|
+
}
|
|
75
|
+
.btn[disabled] {
|
|
76
|
+
background: gray;
|
|
77
|
+
}
|
|
74
78
|
```
|
|
75
79
|
|
|
76
80
|
When the button is both hovered **and** disabled, both selectors match with equal specificity. The last rule in source order wins. Swap the two lines and the visual behavior silently reverses — a hovered disabled button turns blue instead of gray.
|
|
@@ -81,11 +85,11 @@ In Tasty, the same intent is declared as a state map:
|
|
|
81
85
|
fill: {
|
|
82
86
|
'': '#primary',
|
|
83
87
|
':hover': '#primary-hover',
|
|
84
|
-
'disabled': '#surface',
|
|
88
|
+
'[disabled]': '#surface',
|
|
85
89
|
}
|
|
86
90
|
```
|
|
87
91
|
|
|
88
|
-
|
|
92
|
+
Because `[disabled]` is declared later, it has higher priority. Tasty excludes disabled buttons from the hover selector, so exactly one background rule matches. The outcome is defined by the state map, not by which CSS rule comes last.
|
|
89
93
|
|
|
90
94
|
That makes Tasty less of a "better way to write CSS objects" and more of a **state-aware style compiler for design systems**.
|
|
91
95
|
|
|
@@ -131,16 +135,36 @@ To make this concrete, consider a button with `hover`, `disabled`, and `theme=da
|
|
|
131
135
|
**Plain CSS** — you need a selector for every intersection, and equal-specificity rules depend on source order:
|
|
132
136
|
|
|
133
137
|
```css
|
|
134
|
-
.btn {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
.btn {
|
|
139
|
+
background: var(--primary);
|
|
140
|
+
color: white;
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
}
|
|
143
|
+
.btn:hover {
|
|
144
|
+
background: var(--primary-hover);
|
|
145
|
+
}
|
|
146
|
+
.btn:active {
|
|
147
|
+
background: var(--primary-pressed);
|
|
148
|
+
}
|
|
149
|
+
.btn[disabled] {
|
|
150
|
+
background: var(--surface);
|
|
151
|
+
color: var(--text-40);
|
|
152
|
+
cursor: not-allowed;
|
|
153
|
+
}
|
|
138
154
|
|
|
139
155
|
/* theme=danger overrides — must repeat disabled/hover/active */
|
|
140
|
-
.btn[data-theme=
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.btn[data-theme=
|
|
156
|
+
.btn[data-theme='danger'] {
|
|
157
|
+
background: var(--danger);
|
|
158
|
+
}
|
|
159
|
+
.btn[data-theme='danger']:hover {
|
|
160
|
+
background: var(--danger-hover);
|
|
161
|
+
}
|
|
162
|
+
.btn[data-theme='danger']:active {
|
|
163
|
+
background: var(--danger-pressed);
|
|
164
|
+
}
|
|
165
|
+
.btn[data-theme='danger'][disabled] {
|
|
166
|
+
background: var(--surface);
|
|
167
|
+
}
|
|
144
168
|
|
|
145
169
|
/* Bug: .btn:hover and .btn[disabled] have the same specificity.
|
|
146
170
|
A hovered disabled button gets :hover styles — unless source order saves you. */
|
|
@@ -172,18 +196,18 @@ const Button = tasty({
|
|
|
172
196
|
'': '#primary',
|
|
173
197
|
':hover': '#primary-hover',
|
|
174
198
|
':active': '#primary-pressed',
|
|
175
|
-
|
|
199
|
+
disabled: '#surface',
|
|
176
200
|
'theme=danger': '#danger',
|
|
177
201
|
'theme=danger & :hover': '#danger-hover',
|
|
178
202
|
'theme=danger & :active': '#danger-pressed',
|
|
179
203
|
},
|
|
180
204
|
color: {
|
|
181
205
|
'': '#on-primary',
|
|
182
|
-
|
|
206
|
+
disabled: '#text.40',
|
|
183
207
|
},
|
|
184
208
|
cursor: {
|
|
185
209
|
'': 'pointer',
|
|
186
|
-
|
|
210
|
+
disabled: 'not-allowed',
|
|
187
211
|
},
|
|
188
212
|
},
|
|
189
213
|
});
|
|
@@ -235,12 +259,12 @@ Tasty is more opinionated.
|
|
|
235
259
|
|
|
236
260
|
It behaves less like "TypeScript that outputs CSS" and more like a **state-aware style compiler**. It is designed to encode higher-level styling semantics rather than only expose CSS primitives in typed form.
|
|
237
261
|
|
|
238
|
-
This also makes Tasty's
|
|
262
|
+
This also makes Tasty's delivery model notable:
|
|
239
263
|
|
|
240
|
-
- `tasty()` components are hook-free and work as React Server Components. In server-only contexts
|
|
241
|
-
- `tastyStatic()` with the Babel plugin produces static class
|
|
264
|
+
- `tasty()` components are hook-free and work as React Server Components. In server-only contexts, they produce HTML + CSS with zero Tasty styling runtime in the browser while retaining the full React feature set. Astro without islands is the concrete integration; server-only Next.js RSC uses the same architecture.
|
|
265
|
+
- `tastyStatic()` with the Babel plugin produces static class-name objects via build-time extraction, with no React dependency — the output works with any JavaScript framework.
|
|
242
266
|
|
|
243
|
-
|
|
267
|
+
React component features like `styleProps`, sub-element components, and dynamic variants are available in the `tasty()` path whether it renders on the server or in the browser. The `tastyStatic()` path is framework-agnostic but limited to the DSL, tokens, and state logic.
|
|
244
268
|
|
|
245
269
|
So the tradeoff is roughly:
|
|
246
270
|
|
|
@@ -298,32 +322,32 @@ It is less focused on "how do I style this component ergonomically right now?" a
|
|
|
298
322
|
- what should be allowed or constrained?
|
|
299
323
|
- how do we keep style behavior deterministic as the system grows?
|
|
300
324
|
|
|
301
|
-
So while Stitches and Emotion are strong tools for building components, Tasty is more naturally positioned as
|
|
325
|
+
So while Stitches and Emotion are strong tools for building components, Tasty is more naturally positioned as the **styling engine underneath a design system’s component API**.
|
|
302
326
|
|
|
303
327
|
That makes it narrower in audience, but deeper in architectural ambition.
|
|
304
328
|
|
|
305
|
-
There is also a fundamental architectural difference: Emotion and styled-components rely on React context and hooks internally, which means they require `'use client'` in modern React and cannot run as React Server Components. Tasty's style functions and `tasty()` components are hook-free, so they work as server components by default and
|
|
329
|
+
There is also a fundamental architectural difference: Emotion and styled-components rely on React context and hooks internally, which means they require `'use client'` in modern React and cannot run as React Server Components. Tasty's style functions and `tasty()` components are hook-free, so they work as server components by default and ship no Tasty styling runtime in server-only contexts. This is not a minor compatibility detail — it means Tasty-based components stay as server components until _your_ code needs interactivity, while Emotion and styled-components force the client boundary at the styling layer.
|
|
306
330
|
|
|
307
331
|
For teams evaluating runtime styling at scale, Tasty also documents its runtime benchmarks and caching model in the main [README](../README.md#performance). That matters, but it is still secondary to the core question of whether you want Tasty's deterministic selector model.
|
|
308
332
|
|
|
309
333
|
---
|
|
310
334
|
|
|
311
|
-
##
|
|
335
|
+
## Where styles are computed
|
|
312
336
|
|
|
313
337
|
Tasty is not limited to one execution model.
|
|
314
338
|
|
|
315
|
-
|
|
339
|
+
Zero-runtime delivery is an outcome, not a synonym for `tastyStatic()`. `tasty()` computes styles during React rendering, but that rendering can happen only on the server. In that case it produces HTML + CSS and ships **zero Tasty styling runtime** to the browser. The full feature set — `styleProps`, sub-elements, variants, state maps — remains available. Astro's `tastyIntegration({ islands: false })` is the explicit setup for this path. Server-only Next.js RSC follows the same architecture; verify the generated output for the target deployment.
|
|
316
340
|
|
|
317
341
|
Client JavaScript only enters the picture when a component needs React interactivity (state, effects, event handlers) — and that is the consuming component's decision, never Tasty's. Tasty never forces the `'use client'` boundary.
|
|
318
342
|
|
|
319
|
-
`tastyStatic()` with the Babel plugin
|
|
343
|
+
`tastyStatic()` with the Babel plugin reaches zero-runtime delivery differently: CSS is extracted **during the build**, without React. The output is framework-agnostic — any JavaScript framework can consume the resulting class names and CSS. This makes Tasty usable as the compiler layer underneath a design-system implementation, even outside the React ecosystem.
|
|
320
344
|
|
|
321
345
|
The tradeoff is that some capabilities — `styleProps`, sub-element components (`<Card.Title>`), dynamic variants — are tied to the `tasty()` path. The `tastyStatic()` path is best understood as extraction and compilation of the DSL, tokens, and state logic without a React dependency.
|
|
322
346
|
|
|
323
|
-
This
|
|
347
|
+
This gives Tasty two zero-runtime paths:
|
|
324
348
|
|
|
325
|
-
- `tasty()`
|
|
326
|
-
- `tastyStatic()` as a
|
|
349
|
+
- server-only `tasty()` for the full React component API, with CSS generated during server or static rendering
|
|
350
|
+
- `tastyStatic()` as a build-time compiler whose output works with any framework, including non-React ones
|
|
327
351
|
|
|
328
352
|
---
|
|
329
353
|
|
|
@@ -332,22 +356,27 @@ This flexibility is one of Tasty's more unusual strengths:
|
|
|
332
356
|
Another useful way to think about the ecosystem is by abstraction level.
|
|
333
357
|
|
|
334
358
|
### Direct styling tools
|
|
359
|
+
|
|
335
360
|
These are optimized for styling product code directly.
|
|
336
361
|
|
|
337
362
|
Examples:
|
|
363
|
+
|
|
338
364
|
- Tailwind CSS
|
|
339
365
|
- Emotion (requires `'use client'` — not RSC-compatible)
|
|
340
366
|
- Stitches (deprecated, requires `'use client'`)
|
|
341
367
|
|
|
342
368
|
### Typed styling engines
|
|
369
|
+
|
|
343
370
|
These are optimized for generating CSS with stronger structure and tooling.
|
|
344
371
|
|
|
345
372
|
Examples:
|
|
373
|
+
|
|
346
374
|
- Panda CSS
|
|
347
375
|
- vanilla-extract
|
|
348
376
|
- StyleX
|
|
349
377
|
|
|
350
378
|
### Design-system language engines
|
|
379
|
+
|
|
351
380
|
These are optimized for helping a team define its own styling grammar and semantics.
|
|
352
381
|
|
|
353
382
|
Tasty belongs most naturally here.
|
|
@@ -364,7 +393,7 @@ Tasty makes the most sense when:
|
|
|
364
393
|
- a shared component API is emerging even if the design system is still lightweight
|
|
365
394
|
- styling should be governed through a central platform team
|
|
366
395
|
- component state logic is complex
|
|
367
|
-
- the team wants a
|
|
396
|
+
- the team wants a design-system-owned styling language instead of raw CSS-shaped authoring
|
|
368
397
|
- tokens, recipes, and sub-elements should be first-class
|
|
369
398
|
- deterministic state resolution matters more than minimum abstraction overhead
|
|
370
399
|
- the styling engine may need to work as either a runtime tool or a build-time compiler
|
|
@@ -414,6 +443,6 @@ Tasty is most compelling when the problem is not just "how do we write styles,"
|
|
|
414
443
|
- [React API](react-api.md) — `tasty()` factory, component props, variants, sub-elements, style functions
|
|
415
444
|
- [Style Properties](styles.md) — complete reference for all enhanced style properties
|
|
416
445
|
- [Configuration](configuration.md) — tokens, recipes, custom units, style handlers, and TypeScript extensions
|
|
417
|
-
- [
|
|
446
|
+
- [Build-Time Extraction (`tastyStatic`)](tasty-static.md) — static styling with the Babel plugin
|
|
418
447
|
- [Adoption Guide](adoption.md) — where Tasty sits in the stack, incremental adoption, and what changes for product engineers
|
|
419
448
|
- [Server-Side Rendering](ssr.md) — SSR setup for Next.js, Astro, and generic frameworks
|