@tenphi/tasty 0.0.0-snapshot.da430e1 → 0.0.0-snapshot.db2ef70
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 +408 -385
- package/dist/babel-types-Dc5zghyE.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
- package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
- package/dist/{collector-BevHh16N.js → chunks/collector-Cb8ah2JF.js} +10 -127
- package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
- package/dist/chunks/config-engine-CMYFZYQh.js +272 -0
- package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/css-definitions-B4aWBkH3.js +910 -0
- package/dist/chunks/css-definitions-B4aWBkH3.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-D2Pu7Xhy.js +502 -0
- package/dist/chunks/debug-D2Pu7Xhy.js.map +1 -0
- package/dist/chunks/dsl-CsFl9LGn.js +1458 -0
- package/dist/chunks/dsl-CsFl9LGn.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-DHiopXCu.js +691 -0
- package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
- package/dist/chunks/runtime-engine-NGCofNXy.js +2435 -0
- package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
- package/dist/chunks/runtime-state-lZjMbvwV.js +152 -0
- package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
- package/dist/{merge-styles-BKfagXfV.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-DnkV_4Jg.js +5602 -0
- package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
- package/dist/{css-writer-BDPmetHV.js → chunks/zero-engine-DcwaCvFs.js} +65 -145
- package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
- package/dist/{collector-CLVr5_p3.d.ts → collector-D2OT6I2G.d.ts} +6 -5
- package/dist/{config-YsxGv4tq.d.ts → config-C4ftFxgI.d.ts} +181 -77
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-CBK778ne.d.ts → index-DxQNRj50.d.ts} +308 -255
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -922
- package/dist/{merge-styles-CU7JbEwg.d.ts → merge-styles-D39qBtox.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 +1 -2
- package/dist/ssr/astro-middleware-extract-static.js +1 -1
- package/dist/ssr/astro-middleware-extract.d.ts +1 -2
- package/dist/ssr/astro-middleware-extract.js +1 -1
- package/dist/ssr/astro-middleware-static.d.ts +1 -2
- package/dist/ssr/astro-middleware-static.js +1 -12
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +1 -2
- package/dist/ssr/astro-middleware.js +1 -13
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +17 -17
- package/dist/ssr/astro.js +220 -1
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +5 -25
- package/dist/ssr/index.js +5 -5
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +64 -0
- package/dist/ssr/next-config.js +123 -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-Cd45t5NM.d.ts → types-CYQIhUg1.d.ts} +868 -820
- package/dist/zero/babel.d.ts +73 -2
- package/dist/zero/babel.js +81 -144
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +63 -8
- package/dist/zero/index.js +25 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +3 -38
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +68 -33
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +204 -70
- package/docs/debug.md +21 -8
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +307 -117
- package/docs/getting-started.md +81 -22
- package/docs/injector.md +105 -67
- package/docs/methodology.md +48 -23
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +54 -27
- package/docs/plugins.md +22 -42
- package/docs/react-api.md +76 -11
- package/docs/runtime-benchmarks.md +282 -110
- package/docs/ssr.md +226 -80
- package/docs/styles.md +169 -33
- package/docs/tasty-static.md +176 -58
- package/package.json +108 -44
- package/tasty.config.ts +1 -0
- package/dist/astro-C_by9qPq.js +0 -307
- package/dist/astro-C_by9qPq.js.map +0 -1
- package/dist/async-storage-DKK-wTD4.js +0 -44
- package/dist/async-storage-DKK-wTD4.js.map +0 -1
- package/dist/babel-BUQGeOXA.d.ts +0 -83
- package/dist/collector-BevHh16N.js.map +0 -1
- package/dist/config-NcdqU9PC.js +0 -12269
- package/dist/config-NcdqU9PC.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-D7s7u-k1.js +0 -1566
- package/dist/core-D7s7u-k1.js.map +0 -1
- package/dist/css-writer-BDPmetHV.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-BQCn7JZH.js +0 -130
- package/dist/format-rules-BQCn7JZH.js.map +0 -1
- package/dist/hydrate-C3cfqlaQ.js +0 -37
- package/dist/hydrate-C3cfqlaQ.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-ByhOtsXB.js +0 -493
- package/dist/keyframes-ByhOtsXB.js.map +0 -1
- package/dist/merge-styles-BKfagXfV.js.map +0 -1
- package/dist/resolve-recipes-vvygrWLw.js +0 -144
- package/dist/resolve-recipes-vvygrWLw.js.map +0 -1
package/docs/dsl.md
CHANGED
|
@@ -6,6 +6,8 @@ The same value syntax, state maps, tokens, units, extension semantics, and speci
|
|
|
6
6
|
|
|
7
7
|
For the React API (`tasty()`, style functions, component props), see [React API](react-api.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
|
|
8
8
|
|
|
9
|
+
To autocomplete your own token and preset names, see [TypeScript autocomplete](getting-started.md#typescript-autocomplete); to check state keys, tokens, units, and values at lint time, see [ESLint plugin](getting-started.md#eslint-plugin).
|
|
10
|
+
|
|
9
11
|
---
|
|
10
12
|
|
|
11
13
|
## Dictionary
|
|
@@ -18,6 +20,15 @@ Object where keys represent states and values are the styles to apply:
|
|
|
18
20
|
fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
|
|
19
21
|
```
|
|
20
22
|
|
|
23
|
+
Define an alias for one component by adding an `'@name': '<state expression>'` key to its styles. It works like a global alias from [`configure({ states })`](configuration.md#options), scoped to that component:
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
styles: {
|
|
27
|
+
'@narrow': '@media(w < 600px)',
|
|
28
|
+
fill: { '': '#surface', '@narrow': '#surface-mobile' },
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
21
32
|
#### State Key Types
|
|
22
33
|
|
|
23
34
|
| Syntax | Example | Generated CSS |
|
|
@@ -34,17 +45,20 @@ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
|
|
|
34
45
|
|
|
35
46
|
#### Automatic Native States
|
|
36
47
|
|
|
37
|
-
`disabled` and `
|
|
48
|
+
`disabled`, `checked`, and `hidden` are built-in automatic states. A Tasty component sets `data-disabled`, `data-checked`, and `data-hidden` from the native `disabled`, `checked`, and `hidden` props (or `isDisabled`, `isChecked`, `isHidden`), so each pair below expresses the same component state:
|
|
38
49
|
|
|
39
|
-
| Concise Tasty state | Explicit attribute selector |
|
|
40
|
-
| ------------------- | --------------------------- |
|
|
41
|
-
| `disabled` | `[disabled]` |
|
|
42
|
-
| `checked` | `[checked]` |
|
|
50
|
+
| Concise Tasty state | Compiles to | Explicit attribute selector |
|
|
51
|
+
| ------------------- | ----------------- | --------------------------- |
|
|
52
|
+
| `disabled` | `[data-disabled]` | `[disabled]` |
|
|
53
|
+
| `checked` | `[data-checked]` | `[checked]` |
|
|
54
|
+
| `hidden` | `[data-hidden]` | `[hidden]` |
|
|
43
55
|
|
|
44
56
|
Prefer the concise form when authoring Tasty component styles. Explicit attribute selectors remain valid and can be useful when targeting arbitrary attributes or when CSS-shaped syntax makes an introductory example easier to recognize.
|
|
45
57
|
|
|
46
58
|
Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
|
|
47
59
|
|
|
60
|
+
A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
|
|
61
|
+
|
|
48
62
|
`^` (XOR) means "exactly one of" — `A ^ B` expands to `(A & !B) | (!A & B)`. This is useful for mutually exclusive states where exactly one should be active:
|
|
49
63
|
|
|
50
64
|
```jsx
|
|
@@ -54,6 +68,8 @@ fill: {
|
|
|
54
68
|
}
|
|
55
69
|
```
|
|
56
70
|
|
|
71
|
+
Modifier and class names start with a letter and may be a single letter (`x` → `[data-x]`, `.x`). Tasty emits an `INVALID_STATE_KEY` warning for a key it cannot fully read and skips the unreadable parts. That covers characters outside the notation (`1st`, or `@media (w < 600px)` with a space before the parenthesis), an operator missing a state (`hovered &`), and two states with no operator between them (`hovered focused`). A partly read key can apply in states you did not mean, so fix the key rather than rely on what it produces.
|
|
72
|
+
|
|
57
73
|
#### Default State Ordering
|
|
58
74
|
|
|
59
75
|
Key order sets priority — later keys win and turn off earlier ones via negation. The bare default (`''`) is the lowest-priority state, so it **must be the first key**. If it appears after other states, Tasty moves it to the front and emits a dev warning (`MISPLACED_DEFAULT_STATE`); otherwise it would override every state above it.
|
|
@@ -74,9 +90,7 @@ Element styled using a capitalized key. Identified by `data-element` attribute:
|
|
|
74
90
|
|
|
75
91
|
```jsx
|
|
76
92
|
styles: {
|
|
77
|
-
Title: {
|
|
78
|
-
preset: 'h3';
|
|
79
|
-
}
|
|
93
|
+
Title: { preset: 'h3' },
|
|
80
94
|
}
|
|
81
95
|
// Targets: <div data-element="Title">
|
|
82
96
|
```
|
|
@@ -115,20 +129,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
|
|
|
115
129
|
const List = tasty({
|
|
116
130
|
styles: {
|
|
117
131
|
Item: {
|
|
118
|
-
$: '
|
|
119
|
-
|
|
132
|
+
$: '>@::after',
|
|
133
|
+
content: '""',
|
|
120
134
|
},
|
|
121
135
|
},
|
|
122
136
|
});
|
|
123
|
-
// → .
|
|
137
|
+
// → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
|
|
124
138
|
```
|
|
125
139
|
|
|
140
|
+
Keep conditions such as `:last-child` out of `$` and write them as `@own(:last-child)` in a state map; `tasty/no-state-in-selector` warns otherwise. When `$` ends in a pseudo-element, `@own()` describes the pseudo-element instead (see [`@own(...)`](#own--sub-elements-own-state)), so a condition on the element it belongs to stays in `$`, before the pseudo-element: `$: 'a[rel="next"]::before'`.
|
|
141
|
+
|
|
126
142
|
### Color Token
|
|
127
143
|
|
|
128
144
|
Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
|
|
129
145
|
|
|
130
146
|
```jsx
|
|
131
|
-
fill: '#purple.5'; // →
|
|
147
|
+
fill: '#purple.5'; // → color-mix(in oklab, var(--purple-color) 50%, transparent)
|
|
132
148
|
```
|
|
133
149
|
|
|
134
150
|
### Modifier
|
|
@@ -152,19 +168,23 @@ color: '#purple.5', // 50% opacity
|
|
|
152
168
|
color: '#purple.05', // 5% opacity
|
|
153
169
|
color: '#purple.$fade', // Opacity from a custom property
|
|
154
170
|
fill: '#current', // → currentcolor
|
|
171
|
+
fill: '#surface+#dark.04', // #dark at 4% opacity over #surface, as one color
|
|
155
172
|
color: '(#primary, #secondary)', // Fallback syntax
|
|
156
173
|
```
|
|
157
174
|
|
|
158
|
-
|
|
175
|
+
`#white`, `#black`, `#border`, and `#outline` are registered by default (see [Default properties](#default-properties)), and `#clear` is a built-in alias for `transparent` (see [below](#clear-is-transparent)), so they work before you define any tokens.
|
|
176
|
+
|
|
177
|
+
A name that is also a hex color is read as a token with the literal as its fallback, in every color style: `color: '#ddd'` emits `var(--ddd-color, #ddd)`, and `#ddd.5` emits `color-mix(in oklab, var(--ddd-color, #ddd) 50%, transparent)`. A `#ddd` token, if you define one, wins over the literal.
|
|
178
|
+
|
|
179
|
+
The suffix fades the token's color by mixing it with `transparent`:
|
|
159
180
|
|
|
160
181
|
```jsx
|
|
161
182
|
fill: '#purple.5';
|
|
162
|
-
// →
|
|
183
|
+
// → color-mix(in oklab, var(--purple-color) 50%, transparent)
|
|
163
184
|
```
|
|
164
185
|
|
|
165
|
-
The
|
|
166
|
-
|
|
167
|
-
these:
|
|
186
|
+
The mix asks nothing of the color beyond _being_ a color. That means the suffix
|
|
187
|
+
works on every one of these:
|
|
168
188
|
|
|
169
189
|
- a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
|
|
170
190
|
Tasty cannot convert — none of which have channels to decompose
|
|
@@ -172,13 +192,29 @@ these:
|
|
|
172
192
|
- a `--name-color` variable declared in your own CSS, with no Tasty token
|
|
173
193
|
definition behind it
|
|
174
194
|
|
|
175
|
-
|
|
195
|
+
`color-mix()` is Baseline widely available (Chrome 111, Firefox 113, Safari
|
|
196
|
+
16.2). Two properties follow from mixing rather than writing an alpha channel:
|
|
197
|
+
|
|
198
|
+
- **Alpha composes.** The mix is premultiplied, so a color that is already
|
|
199
|
+
translucent is faded further: a token holding `rgb(255 0 0 / .8)` faded to
|
|
200
|
+
`.5` is alpha `.4`. An opaque token — the usual case — ends at exactly the
|
|
201
|
+
suffix. System colors are whatever the platform draws, and some are
|
|
202
|
+
translucent: Chrome and Safari on macOS give `Highlight` an alpha of `.6`, so
|
|
203
|
+
a token holding it faded to `.5` ends at `.3` there.
|
|
204
|
+
- **A `$prop` alpha must be a number.** `#purple.$fade` emits
|
|
205
|
+
`calc(var(--fade) * 100%)`, because a mix percentage cannot be a `<number>`,
|
|
206
|
+
so `$fade` has to hold `.5`, not `50%`.
|
|
207
|
+
|
|
208
|
+
### `#clear` is transparent
|
|
209
|
+
|
|
210
|
+
`#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
|
|
211
|
+
Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
|
|
212
|
+
`transparent`. The same rule applies to user-defined replace tokens resolving
|
|
213
|
+
to `transparent`, including aliases of `#clear`.
|
|
176
214
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
`/ var(--fade)` unchanged, so it works whether `$fade` holds `.5` or `50%` —
|
|
181
|
-
which is what `--*-opacity` properties are registered to accept.
|
|
215
|
+
It does not read `--clear-color` or require an `@property` registration.
|
|
216
|
+
An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
|
|
217
|
+
default alias and uses the replacement's usual opacity behavior.
|
|
182
218
|
|
|
183
219
|
### `#current` is the keyword
|
|
184
220
|
|
|
@@ -201,42 +237,75 @@ A color that already reads the color it inherits — `#current`, a `#current` fa
|
|
|
201
237
|
— is not published into it: resolving such a value a second time at a descendant
|
|
202
238
|
would fade it twice.
|
|
203
239
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
240
|
+
### `#current` fades compose
|
|
241
|
+
|
|
242
|
+
`currentcolor` is the color an element **inherits**, which an ancestor may
|
|
243
|
+
already have faded, so `#current.4` means "40% of what reaches me":
|
|
207
244
|
|
|
208
245
|
```jsx
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
// fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
|
|
246
|
+
fill: '#current.4';
|
|
247
|
+
// → color-mix(in oklab, currentcolor 40%, transparent)
|
|
212
248
|
```
|
|
213
249
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
`#current`
|
|
250
|
+
A `#current` fade nested inside another one composes: a label at `#current.4`
|
|
251
|
+
with a fill of `#current.18` under it lands at `.072`. Color ramps built on
|
|
252
|
+
`#current` depend on that.
|
|
253
|
+
|
|
254
|
+
Fades always mix `in oklab`: it is unbounded, so a wide-gamut color is not
|
|
255
|
+
clamped, and rectangular, so there is no hue to interpolate against
|
|
256
|
+
`transparent`. Nothing configures it — see
|
|
257
|
+
[Color space](configuration.md#color-space).
|
|
217
258
|
|
|
218
|
-
###
|
|
259
|
+
### Compound colors
|
|
219
260
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
**inherits**, which an ancestor may already have faded — `#current.4` means "40%
|
|
223
|
-
of what reaches me":
|
|
261
|
+
Join color tokens with `+` to paint each one, at its own opacity, over the
|
|
262
|
+
colors before it. The result is one color, so it works anywhere a token does:
|
|
224
263
|
|
|
225
264
|
```jsx
|
|
226
|
-
fill: '#
|
|
227
|
-
// → color-mix(in
|
|
228
|
-
```
|
|
265
|
+
fill: '#surface+#dark.04',
|
|
266
|
+
// → color-mix(in srgb, var(--dark-color) 4%, var(--surface-color))
|
|
229
267
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
custom property used as `#current.$fade` must hold a unitless number; a token
|
|
235
|
-
accepts either form.
|
|
268
|
+
border: '1bw #border+#dark.1',
|
|
269
|
+
color: 'light-dark(#primary+#black.2, #primary+#white.2)',
|
|
270
|
+
'#hover-surface': '#surface-2+#surface-text.03',
|
|
271
|
+
```
|
|
236
272
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
273
|
+
Read it left to right, bottom layer first: `#surface+#accent.1+#dark.04` paints
|
|
274
|
+
`#accent` at 10% over `#surface`, then `#dark` at 4% over that. Every operand is
|
|
275
|
+
an ordinary token — `#current`, `#clear`, a hex color, a replace token — and
|
|
276
|
+
takes its opacity suffix as it does anywhere: `#surface+#dark.$hover` reads the
|
|
277
|
+
opacity from `$hover`, and a faded base such as `#surface.5+#dark.04` is layered
|
|
278
|
+
as it is.
|
|
279
|
+
|
|
280
|
+
The layers mix in sRGB, the space browsers composite in, so the color is exactly
|
|
281
|
+
what stacking them as layers would show — but it is one color, which contrast
|
|
282
|
+
checkers can read and transitions interpolate. A faded base is exact too:
|
|
283
|
+
`#surface.5+#dark.04` is as translucent as the two layers would be.
|
|
284
|
+
|
|
285
|
+
Every layer's token has to be opaque. The mix counts a layer's own alpha as well
|
|
286
|
+
as its opacity suffix, and lowers the alpha of the whole color, so a layer token
|
|
287
|
+
that holds a translucent color, or turns transparent in some state, leaves the
|
|
288
|
+
result see-through: with `'#overlay': { '': '#clear', hovered: '#dark' }`,
|
|
289
|
+
`'#surface+#overlay.04'` is 96% opaque at rest. Vary the opacity instead
|
|
290
|
+
(`'#surface+#dark.$hover'`), or give each state its own color
|
|
291
|
+
(`fill: { '': '#surface', hovered: '#surface+#dark.04' }`).
|
|
292
|
+
|
|
293
|
+
- Write it as one word: `#surface + #dark.04` is three separate values, and
|
|
294
|
+
Tasty warns in development.
|
|
295
|
+
- A layer without an opacity covers everything before it: `#surface+#dark` is
|
|
296
|
+
`#dark`, with a development warning.
|
|
297
|
+
- A layer Tasty can see is transparent — `#clear`, a fade to `.0`, a color with
|
|
298
|
+
a zero alpha — is left out: `#surface+#clear` is `#surface`.
|
|
299
|
+
- Over a transparent base, a layer is just its fade: `#clear+#dark.04` compiles
|
|
300
|
+
to `#dark.04`.
|
|
301
|
+
- A `+` joining anything but color tokens (`#surface+1x`) is not a compound: the
|
|
302
|
+
token is dropped, with a development warning, and the style renders as if
|
|
303
|
+
that color were not there.
|
|
304
|
+
|
|
305
|
+
A `+` joins tokens only. To fade a whole compound, give it a token
|
|
306
|
+
(`'#hover-surface': '#surface+#dark.04'`) and fade that (`#hover-surface.5`). For
|
|
307
|
+
a mix that is not a layer over another color, such as an even blend in OKLCH,
|
|
308
|
+
write `color-mix()` itself.
|
|
240
309
|
|
|
241
310
|
---
|
|
242
311
|
|
|
@@ -254,6 +323,9 @@ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
|
|
|
254
323
|
shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
|
|
255
324
|
```
|
|
256
325
|
|
|
326
|
+
Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
|
|
327
|
+
time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
|
|
328
|
+
|
|
257
329
|
`light-dark()` is the one exception to "always a color": CSS lets it pick between
|
|
258
330
|
values of any type, so it is treated as a color only when its arguments are
|
|
259
331
|
colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
|
|
@@ -284,23 +356,52 @@ configure({
|
|
|
284
356
|
});
|
|
285
357
|
|
|
286
358
|
fill: '#solid.5'; // → hsl(220 90% 50% / .5)
|
|
287
|
-
fill: '#adaptive.5'; // →
|
|
359
|
+
fill: '#adaptive.5'; // → color-mix(in oklab, light-dark(…) 50%, transparent)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Color keywords
|
|
363
|
+
|
|
364
|
+
CSS named colors (`rebeccapurple`) and system colors (`Canvas`, `CanvasText`,
|
|
365
|
+
`Highlight`, `ButtonText`, `GrayText`, `LinkText`, …) are colors too: they land
|
|
366
|
+
in the color slot of any style and can be a color token's value. System colors
|
|
367
|
+
are what `forced-colors` styles are written in:
|
|
368
|
+
|
|
369
|
+
```jsx
|
|
370
|
+
const Checkbox = tasty({
|
|
371
|
+
styles: {
|
|
372
|
+
'#forced-border': 'CanvasText',
|
|
373
|
+
border: {
|
|
374
|
+
'': '1bw #border',
|
|
375
|
+
'@media(forced-colors: active)': '1bw #forced-border',
|
|
376
|
+
},
|
|
377
|
+
outline: { '': false, focused: '2px Highlight' },
|
|
378
|
+
},
|
|
379
|
+
});
|
|
288
380
|
```
|
|
289
381
|
|
|
382
|
+
A custom property whose fallback is a single color is read as a color, so it
|
|
383
|
+
also fills the color slot: `border: '1bw var(--accent, Highlight)'`, as does
|
|
384
|
+
`($accent, Highlight)`. Keywords are case-insensitive: a color token keeps the
|
|
385
|
+
case it was written in, and a property value such as `border` or `fill` emits
|
|
386
|
+
them lowercase.
|
|
387
|
+
|
|
388
|
+
The deprecated system colors (`Menu`, `Window`, `ButtonHighlight`, …) are not
|
|
389
|
+
recognized.
|
|
390
|
+
|
|
290
391
|
---
|
|
291
392
|
|
|
292
393
|
## Built-in Units
|
|
293
394
|
|
|
294
|
-
| Unit | Description | Example | CSS
|
|
295
|
-
| ---- | ------------------ | ------- |
|
|
296
|
-
| `x` |
|
|
297
|
-
| `r` | Border radius | `1r` | `
|
|
298
|
-
| `cr` | Card border radius | `1cr` | `
|
|
299
|
-
| `bw` | Border width | `2bw` | `
|
|
300
|
-
| `ow` | Outline width | `1ow` | `
|
|
301
|
-
| `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)`
|
|
395
|
+
| Unit | Description | Default | Example | CSS output |
|
|
396
|
+
| ---- | ------------------ | ---------------- | ------- | ---------------- |
|
|
397
|
+
| `x` | Spacing step | `8px` | `2x` | `16px` |
|
|
398
|
+
| `r` | Border radius | `6px` | `1r` | `6px` |
|
|
399
|
+
| `cr` | Card border radius | `10px` | `1cr` | `10px` |
|
|
400
|
+
| `bw` | Border width | `1px` | `2bw` | `2px` |
|
|
401
|
+
| `ow` | Outline width | `3px` | `1ow` | `3px` |
|
|
402
|
+
| `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
|
|
302
403
|
|
|
303
|
-
|
|
404
|
+
Units compile to plain values. Change the scale with `configure({ units: { x: '4px' } })`, or point a unit at a custom property when it must change at runtime: with `units: { x: 'var(--gap)' }`, `2x` compiles to `calc(2 * var(--gap))`. Setting a `$gap` or `$radius` token does not change the units. Register additional units the same way via [`configure()`](configuration.md#options).
|
|
304
405
|
|
|
305
406
|
---
|
|
306
407
|
|
|
@@ -341,6 +442,26 @@ const ElevatedCard = tasty({
|
|
|
341
442
|
});
|
|
342
443
|
```
|
|
343
444
|
|
|
445
|
+
**Where recipes resolve:**
|
|
446
|
+
|
|
447
|
+
The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
|
|
448
|
+
|
|
449
|
+
```jsx
|
|
450
|
+
const CardWithPanel = tasty({
|
|
451
|
+
styles: {
|
|
452
|
+
recipe: 'card',
|
|
453
|
+
Panel: {
|
|
454
|
+
recipe: 'card elevated',
|
|
455
|
+
padding: '2x', // Overrides the panel's base recipe padding
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
At each level, base recipes are collected in the order listed (later recipes replace earlier values for the same property), then local styles are merged, then post recipes are merged. The merges with local styles and post recipes follow the [state-map extension and replacement rules](#extending-vs-replacing-state-maps).
|
|
462
|
+
|
|
463
|
+
Recipe definitions themselves cannot contain a `recipe` reference to another recipe: there is no recursive expansion or recipe inheritance. Compose names in the root or sub-element `recipe` property instead. See [Configuration — Recipes](configuration.md#recipes) for an unsupported nesting example.
|
|
464
|
+
|
|
344
465
|
**Post-merge recipes (`/` separator):**
|
|
345
466
|
|
|
346
467
|
Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
|
|
@@ -417,12 +538,14 @@ fill: {
|
|
|
417
538
|
Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
|
|
418
539
|
|
|
419
540
|
```jsx
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
541
|
+
const MyButton = tasty(Button, {
|
|
542
|
+
styles: {
|
|
543
|
+
fill: {
|
|
544
|
+
hovered: null, // removes the parent's hovered state
|
|
545
|
+
disabled: false, // tombstone — no CSS for disabled, blocks recipe too
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
});
|
|
426
549
|
```
|
|
427
550
|
|
|
428
551
|
### Resetting Properties with `null` and `false`
|
|
@@ -472,7 +595,7 @@ const SimpleButton = tasty(Button, {
|
|
|
472
595
|
|
|
473
596
|
### `@media(...)` — Media Queries
|
|
474
597
|
|
|
475
|
-
Media queries support dimension shorthands
|
|
598
|
+
Media queries support dimension shorthands:
|
|
476
599
|
|
|
477
600
|
| Shorthand | Expands to |
|
|
478
601
|
| --------- | ---------- |
|
|
@@ -494,10 +617,17 @@ fill: {
|
|
|
494
617
|
| `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
|
|
495
618
|
| `@media:print` | `@media print` |
|
|
496
619
|
| `@media:screen` | `@media screen` |
|
|
620
|
+
| `@media:all` | `@media all` |
|
|
621
|
+
| `@media:speech` | `@media speech` |
|
|
497
622
|
| `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
|
|
498
623
|
| `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
|
|
624
|
+
| `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
|
|
625
|
+
|
|
626
|
+
Tasty units resolve to their literal length inside query conditions, built-in and configured units alike: `@media(w < 40x)` emits `@media (width < 320px)`. A query condition cannot read a custom property, so a unit configured as one (`units: { x: 'var(--gap)' }`) cannot be used there; write that length in `px`, `em`, or `rem`.
|
|
499
627
|
|
|
500
|
-
|
|
628
|
+
Units are only converted in features that take a length: `width`, `height`, `inline-size`, and `block-size`, with or without `min-`/`max-` (`@media(min-width: 40x)` converts too). Every other feature keeps its value as written, so `@media(min-resolution: 2x)` and `@media(resolution >= 2x)` reach the browser unchanged: there `x` is CSS's own resolution unit, an alias of `dppx`.
|
|
629
|
+
|
|
630
|
+
When it combines or orders conditions, Tasty compares bounds only within one unit. `@media(w >= 600px) & @media(w < 40em)` keeps both bounds, because a query `em` follows the user's font size, so `600px` and `40em` cannot be ordered at build time.
|
|
501
631
|
|
|
502
632
|
In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
|
|
503
633
|
|
|
@@ -523,26 +653,31 @@ const Panel = tasty({
|
|
|
523
653
|
});
|
|
524
654
|
```
|
|
525
655
|
|
|
526
|
-
| Tasty syntax | CSS output
|
|
527
|
-
| ---------------------------------- |
|
|
528
|
-
| `@(layout, w < 600px)` | `@container layout (width < 600px)`
|
|
529
|
-
| `@(w < 600px)` | `@container (width < 600px)`
|
|
530
|
-
| `@(layout, $variant=danger)` | `@container layout style(--variant:
|
|
531
|
-
| `@(layout, $compact)` | `@container layout style(--compact)`
|
|
532
|
-
| `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)`
|
|
533
|
-
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)`
|
|
656
|
+
| Tasty syntax | CSS output |
|
|
657
|
+
| ---------------------------------- | -------------------------------------------- |
|
|
658
|
+
| `@(layout, w < 600px)` | `@container layout (width < 600px)` |
|
|
659
|
+
| `@(w < 600px)` | `@container (width < 600px)` |
|
|
660
|
+
| `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
|
|
661
|
+
| `@(layout, $compact)` | `@container layout style(--compact)` |
|
|
662
|
+
| `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
|
|
663
|
+
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
|
|
664
|
+
|
|
665
|
+
Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: value)`. The value is emitted unquoted, so it matches a custom property set to the identifier `danger`, not the string `"danger"`.
|
|
534
666
|
|
|
535
|
-
|
|
667
|
+
Other size features pass through as written: `@(aspect-ratio > 1)` → `@container (aspect-ratio > 1)`, `@(orientation: portrait)` → `@container (orientation: portrait)`. They need a container with `containerType: 'size'`, since an `inline-size` container has no block size to compare against.
|
|
536
668
|
|
|
537
669
|
### `@supports(...)` — Feature Queries
|
|
538
670
|
|
|
539
|
-
Feature queries test CSS property support
|
|
671
|
+
Feature queries test CSS property support and accept CSS support functions such
|
|
672
|
+
as `at-rule()`. Use `$` as the first argument to test selector support:
|
|
540
673
|
|
|
541
|
-
| Tasty syntax
|
|
542
|
-
|
|
|
543
|
-
| `@supports(display: grid)`
|
|
544
|
-
| `@supports($, :has(*))`
|
|
545
|
-
|
|
|
674
|
+
| Tasty syntax | CSS output |
|
|
675
|
+
| ----------------------------- | ----------------------------------- |
|
|
676
|
+
| `@supports(display: grid)` | `@supports (display: grid)` |
|
|
677
|
+
| `@supports($, :has(*))` | `@supports selector(:has(*))` |
|
|
678
|
+
| `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
|
|
679
|
+
| `!@supports(display: grid)` | `@supports (not (display: grid))` |
|
|
680
|
+
| `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
|
|
546
681
|
|
|
547
682
|
```jsx
|
|
548
683
|
display: {
|
|
@@ -551,6 +686,25 @@ display: {
|
|
|
551
686
|
}
|
|
552
687
|
```
|
|
553
688
|
|
|
689
|
+
`at-rule()` tests whether the browser supports the named at-rule. Its surrounding
|
|
690
|
+
parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
|
|
691
|
+
other states use the same syntax as property queries:
|
|
692
|
+
|
|
693
|
+
```jsx
|
|
694
|
+
color: {
|
|
695
|
+
_: 'red',
|
|
696
|
+
'@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
Use `_` to keep a base value when a browser cannot evaluate a query. A support
|
|
701
|
+
query only detects a browser feature; it does not add an API for authoring the
|
|
702
|
+
queried at-rule in a Tasty style object. For conditional stylesheet imports such
|
|
703
|
+
as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
|
|
704
|
+
stylesheet or document-level `useRawCSS()`. Put imports before other rules in
|
|
705
|
+
that stylesheet. Imports cannot be used in constructable stylesheets, including
|
|
706
|
+
Tasty's adopted-sheet mode for Shadow DOM.
|
|
707
|
+
|
|
554
708
|
### `_` — Fallback Floor
|
|
555
709
|
|
|
556
710
|
By default Tasty makes states **mutually exclusive**: a higher-priority state
|
|
@@ -576,12 +730,12 @@ inset: {
|
|
|
576
730
|
|
|
577
731
|
```css
|
|
578
732
|
.t0.t0 {
|
|
579
|
-
inset: 0
|
|
733
|
+
inset: 0 auto auto auto;
|
|
580
734
|
}
|
|
581
|
-
@container scroll-state
|
|
582
|
-
@
|
|
735
|
+
@supports (container-type: scroll-state) {
|
|
736
|
+
@container scroll-state(scrolled: block-end) {
|
|
583
737
|
.t0.t0 {
|
|
584
|
-
inset: -
|
|
738
|
+
inset: -640px auto auto auto;
|
|
585
739
|
}
|
|
586
740
|
}
|
|
587
741
|
}
|
|
@@ -590,7 +744,7 @@ inset: {
|
|
|
590
744
|
The floor is emitted as a bare rule (no negated `@supports` / container branches),
|
|
591
745
|
so it always applies. When the override matches it wins because it is emitted
|
|
592
746
|
later and all state selectors share the same specificity (see the note on
|
|
593
|
-
`:where()`
|
|
747
|
+
`:where()` above).
|
|
594
748
|
|
|
595
749
|
Notes:
|
|
596
750
|
|
|
@@ -662,7 +816,7 @@ color: {
|
|
|
662
816
|
| `@root([lang="en"])` | `:root[lang="en"]` |
|
|
663
817
|
| `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
|
|
664
818
|
|
|
665
|
-
Root conditions are prepended to the component selector
|
|
819
|
+
Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
|
|
666
820
|
|
|
667
821
|
### `@own(...)` — Sub-element's Own State
|
|
668
822
|
|
|
@@ -692,6 +846,20 @@ const Nav = tasty({
|
|
|
692
846
|
|
|
693
847
|
`@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
|
|
694
848
|
|
|
849
|
+
When `$` ends in a pseudo-element, `@own()` is the pseudo-element's own state and goes after it:
|
|
850
|
+
|
|
851
|
+
```jsx
|
|
852
|
+
Label: {
|
|
853
|
+
$: '@::part(label)',
|
|
854
|
+
color: { '': '#text', '@own(:focus)': '#primary' },
|
|
855
|
+
},
|
|
856
|
+
// → .t0.t0 [data-element="Label"]::part(label):where(:focus) { … }
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
A pseudo-element has no attributes, classes, or place in the DOM tree. So a state that tests a modifier (`@own(hovered)`), an attribute (`@own([open])`), a class, or a tree position (`@own(:first-child)`, `@own(:has(…))`) can never match it. Tasty ignores such a state and warns. To condition on the element the pseudo-element belongs to, write it in `$` before the pseudo-element (`$: 'a[rel="next"]::before'`), or use `@parent()` for its ancestors.
|
|
860
|
+
|
|
861
|
+
This covers every pseudo-element form: `::before`, `::marker`, `::backdrop`, vendor-prefixed ones such as `::-webkit-details-marker`, functional ones such as `::part(label)`, and the legacy `:before`, `:after`, `:first-line`, `:first-letter`. Each item of a `$` list is judged on its own. Tasty emits pseudo-class states regardless of browser support. Only some pseudo-elements, such as `::part()` and `::-webkit-scrollbar-thumb`, match states like `:hover` or `:focus` today.
|
|
862
|
+
|
|
695
863
|
### `@starting` — Entry Animation
|
|
696
864
|
|
|
697
865
|
Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
|
|
@@ -701,18 +869,18 @@ const FadeIn = tasty({
|
|
|
701
869
|
styles: {
|
|
702
870
|
opacity: { '': '1', '@starting': '0' },
|
|
703
871
|
transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
|
|
704
|
-
transition: 'opacity
|
|
872
|
+
transition: 'opacity, translate',
|
|
705
873
|
},
|
|
706
874
|
});
|
|
707
875
|
```
|
|
708
876
|
|
|
709
877
|
| Tasty syntax | CSS output |
|
|
710
878
|
| ------------ | ------------------------------------ |
|
|
711
|
-
| `@starting` |
|
|
879
|
+
| `@starting` | `.t0.t0 { @starting-style { ... } }` |
|
|
712
880
|
|
|
713
881
|
### `@parent(...)` — Parent Element States
|
|
714
882
|
|
|
715
|
-
Style based on ancestor element attributes. Uses `:
|
|
883
|
+
Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
|
|
716
884
|
|
|
717
885
|
```jsx
|
|
718
886
|
const Highlight = tasty({
|
|
@@ -726,15 +894,15 @@ const Highlight = tasty({
|
|
|
726
894
|
});
|
|
727
895
|
```
|
|
728
896
|
|
|
729
|
-
| Syntax | CSS Output
|
|
730
|
-
| ------------------------------------- |
|
|
731
|
-
| `@parent(hovered)` | `:
|
|
732
|
-
| `!@parent(hovered)` | `:not([data-hovered] *)`
|
|
733
|
-
| `@parent(hovered, >)` | `:
|
|
734
|
-
| `@parent(.active)` | `:
|
|
735
|
-
| `@parent(hovered & focused)` | `:
|
|
736
|
-
| `@parent(hovered) & @parent(focused)` | `:
|
|
737
|
-
| `@parent(hovered \| focused)` | `:
|
|
897
|
+
| Syntax | CSS Output |
|
|
898
|
+
| ------------------------------------- | -------------------------------------------------------------------------- |
|
|
899
|
+
| `@parent(hovered)` | `:where([data-hovered] *)` |
|
|
900
|
+
| `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
|
|
901
|
+
| `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
|
|
902
|
+
| `@parent(.active)` | `:where(.active *)` |
|
|
903
|
+
| `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
|
|
904
|
+
| `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
|
|
905
|
+
| `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
|
|
738
906
|
|
|
739
907
|
For sub-elements, the parent check applies to the root element's ancestors:
|
|
740
908
|
|
|
@@ -749,12 +917,12 @@ const Card = tasty({
|
|
|
749
917
|
},
|
|
750
918
|
},
|
|
751
919
|
});
|
|
752
|
-
// → .t0.t0:
|
|
920
|
+
// → .t0.t0:where([data-hovered] *) [data-element="Label"]
|
|
753
921
|
```
|
|
754
922
|
|
|
755
923
|
### `:is()`, `:has()` — CSS Structural Pseudo-classes
|
|
756
924
|
|
|
757
|
-
Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`.
|
|
925
|
+
Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`. Leading combinators (`> Icon`, `+ Icon`) are relative selectors and are valid only inside `:has()`.
|
|
758
926
|
|
|
759
927
|
`:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
|
|
760
928
|
|
|
@@ -777,18 +945,18 @@ const Card = tasty({
|
|
|
777
945
|
});
|
|
778
946
|
```
|
|
779
947
|
|
|
780
|
-
| Syntax
|
|
781
|
-
|
|
|
782
|
-
| `:has(> Icon)`
|
|
783
|
-
| `:has(+ Icon)`
|
|
784
|
-
| `:has(~ Icon)`
|
|
785
|
-
| `:has(Icon +)`
|
|
786
|
-
| `:has(Icon ~)`
|
|
787
|
-
| `:has(>)`
|
|
788
|
-
| `:is(
|
|
789
|
-
| `:has(button)`
|
|
790
|
-
| `!:has(> Icon)`
|
|
791
|
-
| `!:is(Panel)`
|
|
948
|
+
| Syntax | CSS Output | Meaning |
|
|
949
|
+
| -------------------- | ------------------------------------- | --------------------------------------- |
|
|
950
|
+
| `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
|
|
951
|
+
| `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
|
|
952
|
+
| `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
|
|
953
|
+
| `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
|
|
954
|
+
| `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
|
|
955
|
+
| `:has(>)` | `:has(> *)` | Has any direct child |
|
|
956
|
+
| `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
|
|
957
|
+
| `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
|
|
958
|
+
| `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
|
|
959
|
+
| `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
|
|
792
960
|
|
|
793
961
|
Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
|
|
794
962
|
|
|
@@ -821,6 +989,8 @@ const Pulse = tasty({
|
|
|
821
989
|
});
|
|
822
990
|
```
|
|
823
991
|
|
|
992
|
+
Keyframes names are case-sensitive and keep their authored case in `animation` and `animationName` (`fadeIn`, not `fadein`), so they match `@keyframes` defined here, in `configure({ keyframes })`, or in plain CSS. Everything else in the value — durations, timing functions, keywords — is parsed as usual.
|
|
993
|
+
|
|
824
994
|
---
|
|
825
995
|
|
|
826
996
|
## Properties (`@property`)
|
|
@@ -833,7 +1003,7 @@ const AnimatedGradient = tasty({
|
|
|
833
1003
|
'$gradient-angle': '0deg',
|
|
834
1004
|
'#theme': 'okhst(280 80% 50%)',
|
|
835
1005
|
image: 'linear-gradient($gradient-angle, #theme, #clear)',
|
|
836
|
-
transition: '$$gradient-angle
|
|
1006
|
+
transition: '$$gradient-angle, ##theme',
|
|
837
1007
|
},
|
|
838
1008
|
});
|
|
839
1009
|
```
|
|
@@ -848,6 +1018,26 @@ Use explicit `@property` when you need non-default settings like `inherits: fals
|
|
|
848
1018
|
},
|
|
849
1019
|
```
|
|
850
1020
|
|
|
1021
|
+
### Default properties
|
|
1022
|
+
|
|
1023
|
+
Tasty registers these properties itself. Style handlers read their defaults from them rather than repeating the values inline, so styles work before you define any tokens, and defining a token replaces the initial value.
|
|
1024
|
+
|
|
1025
|
+
| Token | Initial value | Read by |
|
|
1026
|
+
| ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
|
|
1027
|
+
| `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
|
|
1028
|
+
| `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
|
|
1029
|
+
| `#border` | `currentcolor` | `border` with no color |
|
|
1030
|
+
| `#outline` | `currentcolor` | `outline` with no color |
|
|
1031
|
+
| `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
|
|
1032
|
+
| `$transition` | `80ms` | `transition` with no duration |
|
|
1033
|
+
| `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
|
|
1034
|
+
| `$bold-font-weight` | `700` | `preset: 'name / strong'` |
|
|
1035
|
+
| `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
|
|
1036
|
+
|
|
1037
|
+
Every rendering path emits them: the client injector, the SSR collector (`TastyRegistry`, `tastyIntegration()`, `runWithCollector()`), the `withTastyNext()` shared stylesheet, and the Babel plugin. CSS written with the programmatic API needs [`extractConfigProperties()`](tasty-static.md#programmatic-api), once per stylesheet. Server rendering without a collector, such as Astro without `tastyIntegration()`, emits none of them.
|
|
1038
|
+
|
|
1039
|
+
The initial values need `@property` support: Chrome and Edge 85+, Firefox 128+, Safari 16.4+. In older engines a handler that reads one of these tokens resolves to nothing unless your tokens define it: a `border` with no color draws no border, and a `transition` with no duration does not animate. To support those engines, define the tokens your styles rely on in `configure({ tokens })`.
|
|
1040
|
+
|
|
851
1041
|
---
|
|
852
1042
|
|
|
853
1043
|
## Font Face (`@font-face`)
|
|
@@ -908,7 +1098,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
|
|
|
908
1098
|
|
|
909
1099
|
```ts
|
|
910
1100
|
const EmojiList = tasty({
|
|
911
|
-
|
|
1101
|
+
as: 'ol',
|
|
912
1102
|
styles: {
|
|
913
1103
|
'@counter-style': {
|
|
914
1104
|
thumbs: {
|
|
@@ -1000,7 +1190,7 @@ Generated CSS:
|
|
|
1000
1190
|
|
|
1001
1191
|
A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
|
|
1002
1192
|
|
|
1003
|
-
Functions can also be registered with the [`useFunction`](react-api.md#usefunction)
|
|
1193
|
+
Functions can also be registered with the [`useFunction`](react-api.md#usefunction) style function or globally via [`configure({ functions })`](configuration.md#functions) (the same map also accepts bare-key parse functions).
|
|
1004
1194
|
|
|
1005
1195
|
> `@function` is permanent — injected once and never cleaned up, like `@counter-style`. It is an experimental CSS feature ([Chrome 139+](https://developer.mozilla.org/en-US/docs/Web/CSS/@function)); unsupported browsers safely ignore the native rule, so use it as progressive enhancement — or enable the [`configure({ polyfills: { functions: true } })`](configuration.md#polyfills) inline polyfill to expand `$$name(...)` calls into plain CSS for full cross-browser support.
|
|
1006
1196
|
|