@tenphi/tasty 0.0.0-snapshot.a85ade8 → 0.0.0-snapshot.a8a2a5d
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 +418 -381
- package/dist/babel-types-BOABQvEI.d.ts +16 -0
- package/dist/chunks/async-storage-CzSKAyrI.js +36 -0
- package/dist/chunks/async-storage-CzSKAyrI.js.map +1 -0
- package/dist/chunks/build-config-DQkT3Wru.js +59 -0
- package/dist/chunks/build-config-DQkT3Wru.js.map +1 -0
- package/dist/{collector-C6TtL8HJ.js → chunks/collector-Df9zcabl.js} +11 -129
- package/dist/chunks/collector-Df9zcabl.js.map +1 -0
- package/dist/chunks/config-engine-C7OUmM1J.js +269 -0
- package/dist/chunks/config-engine-C7OUmM1J.js.map +1 -0
- package/dist/chunks/config-file-BX3F_61U.js +24 -0
- package/dist/chunks/config-file-BX3F_61U.js.map +1 -0
- package/dist/chunks/css-definitions-BkdTqT7G.js +896 -0
- package/dist/chunks/css-definitions-BkdTqT7G.js.map +1 -0
- package/dist/chunks/css-resources-C0zT36nQ.js +141 -0
- package/dist/chunks/css-resources-C0zT36nQ.js.map +1 -0
- package/dist/chunks/debug-CwGMB2RI.js +501 -0
- package/dist/chunks/debug-CwGMB2RI.js.map +1 -0
- package/dist/chunks/dsl-BAwiOznp.js +1442 -0
- package/dist/chunks/dsl-BAwiOznp.js.map +1 -0
- package/dist/chunks/hydration-DEmoq1sQ.js +39 -0
- package/dist/chunks/hydration-DEmoq1sQ.js.map +1 -0
- package/dist/chunks/react-runtime-B8YqpFx7.js +678 -0
- package/dist/chunks/react-runtime-B8YqpFx7.js.map +1 -0
- package/dist/chunks/runtime-engine-CHNH2nGy.js +2418 -0
- package/dist/chunks/runtime-engine-CHNH2nGy.js.map +1 -0
- package/dist/chunks/runtime-state-BxLKsQzs.js +150 -0
- package/dist/chunks/runtime-state-BxLKsQzs.js.map +1 -0
- package/dist/{merge-styles-DuoZEsm9.js → chunks/shared-utils-CYgOs2mp.js} +58 -57
- package/dist/chunks/shared-utils-CYgOs2mp.js.map +1 -0
- package/dist/chunks/style-engine-DkKH-TqL.js +5573 -0
- package/dist/chunks/style-engine-DkKH-TqL.js.map +1 -0
- package/dist/{css-writer-Bgowobbx.js → chunks/zero-engine-C-0ar_PT.js} +67 -149
- package/dist/chunks/zero-engine-C-0ar_PT.js.map +1 -0
- package/dist/{collector-BTVXj2hS.d.ts → collector-BN6hCWIx.d.ts} +3 -6
- package/dist/{config-LfIDmVHx.d.ts → config-Chmu-PnP.d.ts} +49 -63
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +9 -6
- package/dist/hydrate-CTh8SGd9.d.ts +20 -0
- package/dist/{index-Bm9ltvdH.d.ts → index-szujmf6W.d.ts} +263 -348
- package/dist/index.d.ts +5 -5
- package/dist/index.js +11 -922
- package/dist/merge-styles-Cx25bpax.d.ts +4 -0
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +2 -16
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +1 -4
- package/dist/ssr/astro-middleware-extract-static.js +1 -2
- package/dist/ssr/astro-middleware-extract.d.ts +1 -4
- package/dist/ssr/astro-middleware-extract.js +1 -2
- package/dist/ssr/astro-middleware-static.d.ts +1 -4
- package/dist/ssr/astro-middleware-static.js +2 -14
- package/dist/ssr/astro-middleware-static.js.map +1 -1
- package/dist/ssr/astro-middleware.d.ts +1 -4
- package/dist/ssr/astro-middleware.js +2 -15
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +17 -19
- package/dist/ssr/astro.js +218 -1
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +1 -0
- package/dist/ssr/index.d.ts +5 -27
- package/dist/ssr/index.js +6 -7
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +63 -0
- package/dist/ssr/next-config.js +122 -0
- package/dist/ssr/next-config.js.map +1 -0
- package/dist/ssr/next.d.ts +9 -10
- package/dist/ssr/next.js +30 -45
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -13
- package/dist/static/index.js +6 -26
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -4
- package/dist/static/inject.js +1 -2
- package/dist/{index-BmogEzTo.d.ts → types-DbMN-Yyn.d.ts} +1013 -1043
- package/dist/zero/babel.d.ts +71 -2
- package/dist/zero/babel.js +84 -150
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +61 -12
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +5 -7
- package/dist/zero/next.js +4 -40
- 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 +69 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +204 -70
- package/docs/debug.md +18 -7
- package/docs/design-system.md +129 -15
- package/docs/dsl.md +327 -117
- package/docs/getting-started.md +81 -22
- package/docs/injector.md +41 -40
- package/docs/llms.txt +31 -0
- package/docs/methodology.md +48 -23
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +55 -28
- package/docs/plugins.md +22 -42
- package/docs/react-api.md +76 -11
- package/docs/runtime-benchmarks.md +257 -47
- package/docs/ssr.md +226 -80
- package/docs/styles.md +169 -33
- package/docs/tasty-static.md +176 -58
- package/harness/dev.harnesspm/rules/usage.md +12 -0
- package/harness/dev.harnesspm/scripts/render.mjs +320 -0
- package/harness/dev.harnesspm/scripts/styles.mjs +299 -0
- package/harness/plugin.json +20 -0
- package/package.json +116 -48
- package/tasty.config.ts +1 -0
- package/dist/astro-ib7E7V4Y.js +0 -307
- package/dist/astro-ib7E7V4Y.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-DWCsafYw.d.ts +0 -83
- package/dist/collector-C6TtL8HJ.js.map +0 -1
- package/dist/config-B3gPdCqd.js +0 -12421
- package/dist/config-B3gPdCqd.js.map +0 -1
- package/dist/context-CA8YKeMn.js +0 -24
- package/dist/context-CA8YKeMn.js.map +0 -1
- package/dist/core-Bq7w2kti.js +0 -1686
- package/dist/core-Bq7w2kti.js.map +0 -1
- package/dist/css-writer-Bgowobbx.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-rCZ37rqY.js +0 -130
- package/dist/format-rules-rCZ37rqY.js.map +0 -1
- package/dist/hydrate-CNOmZprz.js +0 -37
- package/dist/hydrate-CNOmZprz.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keyframes-DE-OE76F.js +0 -535
- package/dist/keyframes-DE-OE76F.js.map +0 -1
- package/dist/merge-styles-BcLl1u_d.d.ts +0 -7
- package/dist/merge-styles-DuoZEsm9.js.map +0 -1
- package/dist/resolve-recipes-H9NqOQuP.js +0 -144
- package/dist/resolve-recipes-H9NqOQuP.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,35 @@ 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
|
+
|
|
32
|
+
An alias can use other aliases, anywhere in its expression:
|
|
33
|
+
|
|
34
|
+
```jsx
|
|
35
|
+
configure({
|
|
36
|
+
states: {
|
|
37
|
+
'@mobile': '@media(w < 768px)',
|
|
38
|
+
'@collapsed': '@mobile & !expanded',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
styles: {
|
|
43
|
+
'@compact': '@collapsed | @media:print', // local, built on a global alias
|
|
44
|
+
padding: { '': '4x', '@compact': '2x' },
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- A local alias sees the component's aliases first, then the global ones. Aliases declared inside a sub-element also see the root-level ones.
|
|
49
|
+
- A global alias sees only global aliases. It means the same thing in every component: if a component redefines `@mobile` locally, the global `@collapsed` keeps using the global `@mobile`.
|
|
50
|
+
- A circular alias (`'@a': '@b'` with `'@b': '@a'`, or `'@a': '@a & hovered'`) never matches, and a `CIRCULAR_STATE_ALIAS` warning names the loop.
|
|
51
|
+
|
|
21
52
|
#### State Key Types
|
|
22
53
|
|
|
23
54
|
| Syntax | Example | Generated CSS |
|
|
@@ -34,17 +65,20 @@ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
|
|
|
34
65
|
|
|
35
66
|
#### Automatic Native States
|
|
36
67
|
|
|
37
|
-
`disabled` and `
|
|
68
|
+
`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
69
|
|
|
39
|
-
| Concise Tasty state | Explicit attribute selector |
|
|
40
|
-
| ------------------- | --------------------------- |
|
|
41
|
-
| `disabled` | `[disabled]` |
|
|
42
|
-
| `checked` | `[checked]` |
|
|
70
|
+
| Concise Tasty state | Compiles to | Explicit attribute selector |
|
|
71
|
+
| ------------------- | ----------------- | --------------------------- |
|
|
72
|
+
| `disabled` | `[data-disabled]` | `[disabled]` |
|
|
73
|
+
| `checked` | `[data-checked]` | `[checked]` |
|
|
74
|
+
| `hidden` | `[data-hidden]` | `[hidden]` |
|
|
43
75
|
|
|
44
76
|
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
77
|
|
|
46
78
|
Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
|
|
47
79
|
|
|
80
|
+
A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
|
|
81
|
+
|
|
48
82
|
`^` (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
83
|
|
|
50
84
|
```jsx
|
|
@@ -54,6 +88,8 @@ fill: {
|
|
|
54
88
|
}
|
|
55
89
|
```
|
|
56
90
|
|
|
91
|
+
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.
|
|
92
|
+
|
|
57
93
|
#### Default State Ordering
|
|
58
94
|
|
|
59
95
|
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 +110,7 @@ Element styled using a capitalized key. Identified by `data-element` attribute:
|
|
|
74
110
|
|
|
75
111
|
```jsx
|
|
76
112
|
styles: {
|
|
77
|
-
Title: {
|
|
78
|
-
preset: 'h3';
|
|
79
|
-
}
|
|
113
|
+
Title: { preset: 'h3' },
|
|
80
114
|
}
|
|
81
115
|
// Targets: <div data-element="Title">
|
|
82
116
|
```
|
|
@@ -115,20 +149,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
|
|
|
115
149
|
const List = tasty({
|
|
116
150
|
styles: {
|
|
117
151
|
Item: {
|
|
118
|
-
$: '
|
|
119
|
-
|
|
152
|
+
$: '>@::after',
|
|
153
|
+
content: '""',
|
|
120
154
|
},
|
|
121
155
|
},
|
|
122
156
|
});
|
|
123
|
-
// → .
|
|
157
|
+
// → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
|
|
124
158
|
```
|
|
125
159
|
|
|
160
|
+
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'`.
|
|
161
|
+
|
|
126
162
|
### Color Token
|
|
127
163
|
|
|
128
164
|
Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
|
|
129
165
|
|
|
130
166
|
```jsx
|
|
131
|
-
fill: '#purple.5'; // →
|
|
167
|
+
fill: '#purple.5'; // → color-mix(in oklab, var(--purple-color) 50%, transparent)
|
|
132
168
|
```
|
|
133
169
|
|
|
134
170
|
### Modifier
|
|
@@ -152,19 +188,23 @@ color: '#purple.5', // 50% opacity
|
|
|
152
188
|
color: '#purple.05', // 5% opacity
|
|
153
189
|
color: '#purple.$fade', // Opacity from a custom property
|
|
154
190
|
fill: '#current', // → currentcolor
|
|
191
|
+
fill: '#surface+#dark.04', // #dark at 4% opacity over #surface, as one color
|
|
155
192
|
color: '(#primary, #secondary)', // Fallback syntax
|
|
156
193
|
```
|
|
157
194
|
|
|
158
|
-
|
|
195
|
+
`#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.
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
The suffix fades the token's color by mixing it with `transparent`:
|
|
159
200
|
|
|
160
201
|
```jsx
|
|
161
202
|
fill: '#purple.5';
|
|
162
|
-
// →
|
|
203
|
+
// → color-mix(in oklab, var(--purple-color) 50%, transparent)
|
|
163
204
|
```
|
|
164
205
|
|
|
165
|
-
The
|
|
166
|
-
|
|
167
|
-
these:
|
|
206
|
+
The mix asks nothing of the color beyond _being_ a color. That means the suffix
|
|
207
|
+
works on every one of these:
|
|
168
208
|
|
|
169
209
|
- a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
|
|
170
210
|
Tasty cannot convert — none of which have channels to decompose
|
|
@@ -172,13 +212,29 @@ these:
|
|
|
172
212
|
- a `--name-color` variable declared in your own CSS, with no Tasty token
|
|
173
213
|
definition behind it
|
|
174
214
|
|
|
175
|
-
|
|
215
|
+
`color-mix()` is Baseline widely available (Chrome 111, Firefox 113, Safari
|
|
216
|
+
16.2). Two properties follow from mixing rather than writing an alpha channel:
|
|
217
|
+
|
|
218
|
+
- **Alpha composes.** The mix is premultiplied, so a color that is already
|
|
219
|
+
translucent is faded further: a token holding `rgb(255 0 0 / .8)` faded to
|
|
220
|
+
`.5` is alpha `.4`. An opaque token — the usual case — ends at exactly the
|
|
221
|
+
suffix. System colors are whatever the platform draws, and some are
|
|
222
|
+
translucent: Chrome and Safari on macOS give `Highlight` an alpha of `.6`, so
|
|
223
|
+
a token holding it faded to `.5` ends at `.3` there.
|
|
224
|
+
- **A `$prop` alpha must be a number.** `#purple.$fade` emits
|
|
225
|
+
`calc(var(--fade) * 100%)`, because a mix percentage cannot be a `<number>`,
|
|
226
|
+
so `$fade` has to hold `.5`, not `50%`.
|
|
227
|
+
|
|
228
|
+
### `#clear` is transparent
|
|
176
229
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
230
|
+
`#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
|
|
231
|
+
Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
|
|
232
|
+
`transparent`. The same rule applies to user-defined replace tokens resolving
|
|
233
|
+
to `transparent`, including aliases of `#clear`.
|
|
234
|
+
|
|
235
|
+
It does not read `--clear-color` or require an `@property` registration.
|
|
236
|
+
An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
|
|
237
|
+
default alias and uses the replacement's usual opacity behavior.
|
|
182
238
|
|
|
183
239
|
### `#current` is the keyword
|
|
184
240
|
|
|
@@ -201,42 +257,75 @@ A color that already reads the color it inherits — `#current`, a `#current` fa
|
|
|
201
257
|
— is not published into it: resolving such a value a second time at a descendant
|
|
202
258
|
would fade it twice.
|
|
203
259
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
260
|
+
### `#current` fades compose
|
|
261
|
+
|
|
262
|
+
`currentcolor` is the color an element **inherits**, which an ancestor may
|
|
263
|
+
already have faded, so `#current.4` means "40% of what reaches me":
|
|
207
264
|
|
|
208
265
|
```jsx
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
// fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
|
|
266
|
+
fill: '#current.4';
|
|
267
|
+
// → color-mix(in oklab, currentcolor 40%, transparent)
|
|
212
268
|
```
|
|
213
269
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
`#current`
|
|
270
|
+
A `#current` fade nested inside another one composes: a label at `#current.4`
|
|
271
|
+
with a fill of `#current.18` under it lands at `.072`. Color ramps built on
|
|
272
|
+
`#current` depend on that.
|
|
273
|
+
|
|
274
|
+
Fades always mix `in oklab`: it is unbounded, so a wide-gamut color is not
|
|
275
|
+
clamped, and rectangular, so there is no hue to interpolate against
|
|
276
|
+
`transparent`. Nothing configures it — see
|
|
277
|
+
[Color space](configuration.md#color-space).
|
|
217
278
|
|
|
218
|
-
###
|
|
279
|
+
### Compound colors
|
|
219
280
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
**inherits**, which an ancestor may already have faded — `#current.4` means "40%
|
|
223
|
-
of what reaches me":
|
|
281
|
+
Join color tokens with `+` to paint each one, at its own opacity, over the
|
|
282
|
+
colors before it. The result is one color, so it works anywhere a token does:
|
|
224
283
|
|
|
225
284
|
```jsx
|
|
226
|
-
fill: '#
|
|
227
|
-
// → color-mix(in
|
|
228
|
-
```
|
|
285
|
+
fill: '#surface+#dark.04',
|
|
286
|
+
// → color-mix(in srgb, var(--dark-color) 4%, var(--surface-color))
|
|
229
287
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
custom property used as `#current.$fade` must hold a unitless number; a token
|
|
235
|
-
accepts either form.
|
|
288
|
+
border: '1bw #border+#dark.1',
|
|
289
|
+
color: 'light-dark(#primary+#black.2, #primary+#white.2)',
|
|
290
|
+
'#hover-surface': '#surface-2+#surface-text.03',
|
|
291
|
+
```
|
|
236
292
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
293
|
+
Read it left to right, bottom layer first: `#surface+#accent.1+#dark.04` paints
|
|
294
|
+
`#accent` at 10% over `#surface`, then `#dark` at 4% over that. Every operand is
|
|
295
|
+
an ordinary token — `#current`, `#clear`, a hex color, a replace token — and
|
|
296
|
+
takes its opacity suffix as it does anywhere: `#surface+#dark.$hover` reads the
|
|
297
|
+
opacity from `$hover`, and a faded base such as `#surface.5+#dark.04` is layered
|
|
298
|
+
as it is.
|
|
299
|
+
|
|
300
|
+
The layers mix in sRGB, the space browsers composite in, so the color is exactly
|
|
301
|
+
what stacking them as layers would show — but it is one color, which contrast
|
|
302
|
+
checkers can read and transitions interpolate. A faded base is exact too:
|
|
303
|
+
`#surface.5+#dark.04` is as translucent as the two layers would be.
|
|
304
|
+
|
|
305
|
+
Every layer's token has to be opaque. The mix counts a layer's own alpha as well
|
|
306
|
+
as its opacity suffix, and lowers the alpha of the whole color, so a layer token
|
|
307
|
+
that holds a translucent color, or turns transparent in some state, leaves the
|
|
308
|
+
result see-through: with `'#overlay': { '': '#clear', hovered: '#dark' }`,
|
|
309
|
+
`'#surface+#overlay.04'` is 96% opaque at rest. Vary the opacity instead
|
|
310
|
+
(`'#surface+#dark.$hover'`), or give each state its own color
|
|
311
|
+
(`fill: { '': '#surface', hovered: '#surface+#dark.04' }`).
|
|
312
|
+
|
|
313
|
+
- Write it as one word: `#surface + #dark.04` is three separate values, and
|
|
314
|
+
Tasty warns in development.
|
|
315
|
+
- A layer without an opacity covers everything before it: `#surface+#dark` is
|
|
316
|
+
`#dark`, with a development warning.
|
|
317
|
+
- A layer Tasty can see is transparent — `#clear`, a fade to `.0`, a color with
|
|
318
|
+
a zero alpha — is left out: `#surface+#clear` is `#surface`.
|
|
319
|
+
- Over a transparent base, a layer is just its fade: `#clear+#dark.04` compiles
|
|
320
|
+
to `#dark.04`.
|
|
321
|
+
- A `+` joining anything but color tokens (`#surface+1x`) is not a compound: the
|
|
322
|
+
token is dropped, with a development warning, and the style renders as if
|
|
323
|
+
that color were not there.
|
|
324
|
+
|
|
325
|
+
A `+` joins tokens only. To fade a whole compound, give it a token
|
|
326
|
+
(`'#hover-surface': '#surface+#dark.04'`) and fade that (`#hover-surface.5`). For
|
|
327
|
+
a mix that is not a layer over another color, such as an even blend in OKLCH,
|
|
328
|
+
write `color-mix()` itself.
|
|
240
329
|
|
|
241
330
|
---
|
|
242
331
|
|
|
@@ -254,6 +343,9 @@ border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
|
|
|
254
343
|
shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
|
|
255
344
|
```
|
|
256
345
|
|
|
346
|
+
Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
|
|
347
|
+
time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
|
|
348
|
+
|
|
257
349
|
`light-dark()` is the one exception to "always a color": CSS lets it pick between
|
|
258
350
|
values of any type, so it is treated as a color only when its arguments are
|
|
259
351
|
colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
|
|
@@ -284,23 +376,52 @@ configure({
|
|
|
284
376
|
});
|
|
285
377
|
|
|
286
378
|
fill: '#solid.5'; // → hsl(220 90% 50% / .5)
|
|
287
|
-
fill: '#adaptive.5'; // →
|
|
379
|
+
fill: '#adaptive.5'; // → color-mix(in oklab, light-dark(…) 50%, transparent)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Color keywords
|
|
383
|
+
|
|
384
|
+
CSS named colors (`rebeccapurple`) and system colors (`Canvas`, `CanvasText`,
|
|
385
|
+
`Highlight`, `ButtonText`, `GrayText`, `LinkText`, …) are colors too: they land
|
|
386
|
+
in the color slot of any style and can be a color token's value. System colors
|
|
387
|
+
are what `forced-colors` styles are written in:
|
|
388
|
+
|
|
389
|
+
```jsx
|
|
390
|
+
const Checkbox = tasty({
|
|
391
|
+
styles: {
|
|
392
|
+
'#forced-border': 'CanvasText',
|
|
393
|
+
border: {
|
|
394
|
+
'': '1bw #border',
|
|
395
|
+
'@media(forced-colors: active)': '1bw #forced-border',
|
|
396
|
+
},
|
|
397
|
+
outline: { '': false, focused: '2px Highlight' },
|
|
398
|
+
},
|
|
399
|
+
});
|
|
288
400
|
```
|
|
289
401
|
|
|
402
|
+
A custom property whose fallback is a single color is read as a color, so it
|
|
403
|
+
also fills the color slot: `border: '1bw var(--accent, Highlight)'`, as does
|
|
404
|
+
`($accent, Highlight)`. Keywords are case-insensitive: a color token keeps the
|
|
405
|
+
case it was written in, and a property value such as `border` or `fill` emits
|
|
406
|
+
them lowercase.
|
|
407
|
+
|
|
408
|
+
The deprecated system colors (`Menu`, `Window`, `ButtonHighlight`, …) are not
|
|
409
|
+
recognized.
|
|
410
|
+
|
|
290
411
|
---
|
|
291
412
|
|
|
292
413
|
## Built-in Units
|
|
293
414
|
|
|
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)`
|
|
415
|
+
| Unit | Description | Default | Example | CSS output |
|
|
416
|
+
| ---- | ------------------ | ---------------- | ------- | ---------------- |
|
|
417
|
+
| `x` | Spacing step | `8px` | `2x` | `16px` |
|
|
418
|
+
| `r` | Border radius | `6px` | `1r` | `6px` |
|
|
419
|
+
| `cr` | Card border radius | `10px` | `1cr` | `10px` |
|
|
420
|
+
| `bw` | Border width | `1px` | `2bw` | `2px` |
|
|
421
|
+
| `ow` | Outline width | `3px` | `1ow` | `3px` |
|
|
422
|
+
| `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
|
|
302
423
|
|
|
303
|
-
|
|
424
|
+
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
425
|
|
|
305
426
|
---
|
|
306
427
|
|
|
@@ -341,6 +462,26 @@ const ElevatedCard = tasty({
|
|
|
341
462
|
});
|
|
342
463
|
```
|
|
343
464
|
|
|
465
|
+
**Where recipes resolve:**
|
|
466
|
+
|
|
467
|
+
The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
|
|
468
|
+
|
|
469
|
+
```jsx
|
|
470
|
+
const CardWithPanel = tasty({
|
|
471
|
+
styles: {
|
|
472
|
+
recipe: 'card',
|
|
473
|
+
Panel: {
|
|
474
|
+
recipe: 'card elevated',
|
|
475
|
+
padding: '2x', // Overrides the panel's base recipe padding
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
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).
|
|
482
|
+
|
|
483
|
+
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.
|
|
484
|
+
|
|
344
485
|
**Post-merge recipes (`/` separator):**
|
|
345
486
|
|
|
346
487
|
Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
|
|
@@ -417,12 +558,14 @@ fill: {
|
|
|
417
558
|
Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
|
|
418
559
|
|
|
419
560
|
```jsx
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
561
|
+
const MyButton = tasty(Button, {
|
|
562
|
+
styles: {
|
|
563
|
+
fill: {
|
|
564
|
+
hovered: null, // removes the parent's hovered state
|
|
565
|
+
disabled: false, // tombstone — no CSS for disabled, blocks recipe too
|
|
566
|
+
},
|
|
567
|
+
},
|
|
568
|
+
});
|
|
426
569
|
```
|
|
427
570
|
|
|
428
571
|
### Resetting Properties with `null` and `false`
|
|
@@ -472,7 +615,7 @@ const SimpleButton = tasty(Button, {
|
|
|
472
615
|
|
|
473
616
|
### `@media(...)` — Media Queries
|
|
474
617
|
|
|
475
|
-
Media queries support dimension shorthands
|
|
618
|
+
Media queries support dimension shorthands:
|
|
476
619
|
|
|
477
620
|
| Shorthand | Expands to |
|
|
478
621
|
| --------- | ---------- |
|
|
@@ -494,10 +637,17 @@ fill: {
|
|
|
494
637
|
| `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
|
|
495
638
|
| `@media:print` | `@media print` |
|
|
496
639
|
| `@media:screen` | `@media screen` |
|
|
640
|
+
| `@media:all` | `@media all` |
|
|
641
|
+
| `@media:speech` | `@media speech` |
|
|
497
642
|
| `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
|
|
498
643
|
| `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
|
|
644
|
+
| `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
|
|
499
645
|
|
|
500
|
-
|
|
646
|
+
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`.
|
|
647
|
+
|
|
648
|
+
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`.
|
|
649
|
+
|
|
650
|
+
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
651
|
|
|
502
652
|
In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
|
|
503
653
|
|
|
@@ -523,26 +673,31 @@ const Panel = tasty({
|
|
|
523
673
|
});
|
|
524
674
|
```
|
|
525
675
|
|
|
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)`
|
|
676
|
+
| Tasty syntax | CSS output |
|
|
677
|
+
| ---------------------------------- | -------------------------------------------- |
|
|
678
|
+
| `@(layout, w < 600px)` | `@container layout (width < 600px)` |
|
|
679
|
+
| `@(w < 600px)` | `@container (width < 600px)` |
|
|
680
|
+
| `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
|
|
681
|
+
| `@(layout, $compact)` | `@container layout style(--compact)` |
|
|
682
|
+
| `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
|
|
683
|
+
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
|
|
684
|
+
|
|
685
|
+
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
686
|
|
|
535
|
-
|
|
687
|
+
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
688
|
|
|
537
689
|
### `@supports(...)` — Feature Queries
|
|
538
690
|
|
|
539
|
-
Feature queries test CSS property support
|
|
691
|
+
Feature queries test CSS property support and accept CSS support functions such
|
|
692
|
+
as `at-rule()`. Use `$` as the first argument to test selector support:
|
|
540
693
|
|
|
541
|
-
| Tasty syntax
|
|
542
|
-
|
|
|
543
|
-
| `@supports(display: grid)`
|
|
544
|
-
| `@supports($, :has(*))`
|
|
545
|
-
|
|
|
694
|
+
| Tasty syntax | CSS output |
|
|
695
|
+
| ----------------------------- | ----------------------------------- |
|
|
696
|
+
| `@supports(display: grid)` | `@supports (display: grid)` |
|
|
697
|
+
| `@supports($, :has(*))` | `@supports selector(:has(*))` |
|
|
698
|
+
| `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
|
|
699
|
+
| `!@supports(display: grid)` | `@supports (not (display: grid))` |
|
|
700
|
+
| `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
|
|
546
701
|
|
|
547
702
|
```jsx
|
|
548
703
|
display: {
|
|
@@ -551,6 +706,25 @@ display: {
|
|
|
551
706
|
}
|
|
552
707
|
```
|
|
553
708
|
|
|
709
|
+
`at-rule()` tests whether the browser supports the named at-rule. Its surrounding
|
|
710
|
+
parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
|
|
711
|
+
other states use the same syntax as property queries:
|
|
712
|
+
|
|
713
|
+
```jsx
|
|
714
|
+
color: {
|
|
715
|
+
_: 'red',
|
|
716
|
+
'@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
|
|
717
|
+
}
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
Use `_` to keep a base value when a browser cannot evaluate a query. A support
|
|
721
|
+
query only detects a browser feature; it does not add an API for authoring the
|
|
722
|
+
queried at-rule in a Tasty style object. For conditional stylesheet imports such
|
|
723
|
+
as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
|
|
724
|
+
stylesheet or document-level `useRawCSS()`. Put imports before other rules in
|
|
725
|
+
that stylesheet. Imports cannot be used in constructable stylesheets, including
|
|
726
|
+
Tasty's adopted-sheet mode for Shadow DOM.
|
|
727
|
+
|
|
554
728
|
### `_` — Fallback Floor
|
|
555
729
|
|
|
556
730
|
By default Tasty makes states **mutually exclusive**: a higher-priority state
|
|
@@ -576,12 +750,12 @@ inset: {
|
|
|
576
750
|
|
|
577
751
|
```css
|
|
578
752
|
.t0.t0 {
|
|
579
|
-
inset: 0
|
|
753
|
+
inset: 0 auto auto auto;
|
|
580
754
|
}
|
|
581
|
-
@container scroll-state
|
|
582
|
-
@
|
|
755
|
+
@supports (container-type: scroll-state) {
|
|
756
|
+
@container scroll-state(scrolled: block-end) {
|
|
583
757
|
.t0.t0 {
|
|
584
|
-
inset: -
|
|
758
|
+
inset: -640px auto auto auto;
|
|
585
759
|
}
|
|
586
760
|
}
|
|
587
761
|
}
|
|
@@ -590,7 +764,7 @@ inset: {
|
|
|
590
764
|
The floor is emitted as a bare rule (no negated `@supports` / container branches),
|
|
591
765
|
so it always applies. When the override matches it wins because it is emitted
|
|
592
766
|
later and all state selectors share the same specificity (see the note on
|
|
593
|
-
`:where()`
|
|
767
|
+
`:where()` above).
|
|
594
768
|
|
|
595
769
|
Notes:
|
|
596
770
|
|
|
@@ -662,7 +836,7 @@ color: {
|
|
|
662
836
|
| `@root([lang="en"])` | `:root[lang="en"]` |
|
|
663
837
|
| `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
|
|
664
838
|
|
|
665
|
-
Root conditions are prepended to the component selector
|
|
839
|
+
Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
|
|
666
840
|
|
|
667
841
|
### `@own(...)` — Sub-element's Own State
|
|
668
842
|
|
|
@@ -692,6 +866,20 @@ const Nav = tasty({
|
|
|
692
866
|
|
|
693
867
|
`@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
|
|
694
868
|
|
|
869
|
+
When `$` ends in a pseudo-element, `@own()` is the pseudo-element's own state and goes after it:
|
|
870
|
+
|
|
871
|
+
```jsx
|
|
872
|
+
Label: {
|
|
873
|
+
$: '@::part(label)',
|
|
874
|
+
color: { '': '#text', '@own(:focus)': '#primary' },
|
|
875
|
+
},
|
|
876
|
+
// → .t0.t0 [data-element="Label"]::part(label):where(:focus) { … }
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
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.
|
|
880
|
+
|
|
881
|
+
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.
|
|
882
|
+
|
|
695
883
|
### `@starting` — Entry Animation
|
|
696
884
|
|
|
697
885
|
Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
|
|
@@ -701,18 +889,18 @@ const FadeIn = tasty({
|
|
|
701
889
|
styles: {
|
|
702
890
|
opacity: { '': '1', '@starting': '0' },
|
|
703
891
|
transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
|
|
704
|
-
transition: 'opacity
|
|
892
|
+
transition: 'opacity, translate',
|
|
705
893
|
},
|
|
706
894
|
});
|
|
707
895
|
```
|
|
708
896
|
|
|
709
897
|
| Tasty syntax | CSS output |
|
|
710
898
|
| ------------ | ------------------------------------ |
|
|
711
|
-
| `@starting` |
|
|
899
|
+
| `@starting` | `.t0.t0 { @starting-style { ... } }` |
|
|
712
900
|
|
|
713
901
|
### `@parent(...)` — Parent Element States
|
|
714
902
|
|
|
715
|
-
Style based on ancestor element attributes. Uses `:
|
|
903
|
+
Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
|
|
716
904
|
|
|
717
905
|
```jsx
|
|
718
906
|
const Highlight = tasty({
|
|
@@ -726,15 +914,15 @@ const Highlight = tasty({
|
|
|
726
914
|
});
|
|
727
915
|
```
|
|
728
916
|
|
|
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)` | `:
|
|
917
|
+
| Syntax | CSS Output |
|
|
918
|
+
| ------------------------------------- | -------------------------------------------------------------------------- |
|
|
919
|
+
| `@parent(hovered)` | `:where([data-hovered] *)` |
|
|
920
|
+
| `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
|
|
921
|
+
| `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
|
|
922
|
+
| `@parent(.active)` | `:where(.active *)` |
|
|
923
|
+
| `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
|
|
924
|
+
| `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
|
|
925
|
+
| `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
|
|
738
926
|
|
|
739
927
|
For sub-elements, the parent check applies to the root element's ancestors:
|
|
740
928
|
|
|
@@ -749,12 +937,12 @@ const Card = tasty({
|
|
|
749
937
|
},
|
|
750
938
|
},
|
|
751
939
|
});
|
|
752
|
-
// → .t0.t0:
|
|
940
|
+
// → .t0.t0:where([data-hovered] *) [data-element="Label"]
|
|
753
941
|
```
|
|
754
942
|
|
|
755
943
|
### `:is()`, `:has()` — CSS Structural Pseudo-classes
|
|
756
944
|
|
|
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 `*`.
|
|
945
|
+
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
946
|
|
|
759
947
|
`:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
|
|
760
948
|
|
|
@@ -777,18 +965,18 @@ const Card = tasty({
|
|
|
777
965
|
});
|
|
778
966
|
```
|
|
779
967
|
|
|
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)`
|
|
968
|
+
| Syntax | CSS Output | Meaning |
|
|
969
|
+
| -------------------- | ------------------------------------- | --------------------------------------- |
|
|
970
|
+
| `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
|
|
971
|
+
| `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
|
|
972
|
+
| `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
|
|
973
|
+
| `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
|
|
974
|
+
| `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
|
|
975
|
+
| `:has(>)` | `:has(> *)` | Has any direct child |
|
|
976
|
+
| `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
|
|
977
|
+
| `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
|
|
978
|
+
| `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
|
|
979
|
+
| `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
|
|
792
980
|
|
|
793
981
|
Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
|
|
794
982
|
|
|
@@ -821,6 +1009,8 @@ const Pulse = tasty({
|
|
|
821
1009
|
});
|
|
822
1010
|
```
|
|
823
1011
|
|
|
1012
|
+
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.
|
|
1013
|
+
|
|
824
1014
|
---
|
|
825
1015
|
|
|
826
1016
|
## Properties (`@property`)
|
|
@@ -833,7 +1023,7 @@ const AnimatedGradient = tasty({
|
|
|
833
1023
|
'$gradient-angle': '0deg',
|
|
834
1024
|
'#theme': 'okhst(280 80% 50%)',
|
|
835
1025
|
image: 'linear-gradient($gradient-angle, #theme, #clear)',
|
|
836
|
-
transition: '$$gradient-angle
|
|
1026
|
+
transition: '$$gradient-angle, ##theme',
|
|
837
1027
|
},
|
|
838
1028
|
});
|
|
839
1029
|
```
|
|
@@ -848,6 +1038,26 @@ Use explicit `@property` when you need non-default settings like `inherits: fals
|
|
|
848
1038
|
},
|
|
849
1039
|
```
|
|
850
1040
|
|
|
1041
|
+
### Default properties
|
|
1042
|
+
|
|
1043
|
+
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.
|
|
1044
|
+
|
|
1045
|
+
| Token | Initial value | Read by |
|
|
1046
|
+
| ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
|
|
1047
|
+
| `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
|
|
1048
|
+
| `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
|
|
1049
|
+
| `#border` | `currentcolor` | `border` with no color |
|
|
1050
|
+
| `#outline` | `currentcolor` | `outline` with no color |
|
|
1051
|
+
| `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
|
|
1052
|
+
| `$transition` | `80ms` | `transition` with no duration |
|
|
1053
|
+
| `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
|
|
1054
|
+
| `$bold-font-weight` | `700` | `preset: 'name / strong'` |
|
|
1055
|
+
| `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
|
|
1056
|
+
|
|
1057
|
+
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.
|
|
1058
|
+
|
|
1059
|
+
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 })`.
|
|
1060
|
+
|
|
851
1061
|
---
|
|
852
1062
|
|
|
853
1063
|
## Font Face (`@font-face`)
|
|
@@ -908,7 +1118,7 @@ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counte
|
|
|
908
1118
|
|
|
909
1119
|
```ts
|
|
910
1120
|
const EmojiList = tasty({
|
|
911
|
-
|
|
1121
|
+
as: 'ol',
|
|
912
1122
|
styles: {
|
|
913
1123
|
'@counter-style': {
|
|
914
1124
|
thumbs: {
|
|
@@ -1000,7 +1210,7 @@ Generated CSS:
|
|
|
1000
1210
|
|
|
1001
1211
|
A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
|
|
1002
1212
|
|
|
1003
|
-
Functions can also be registered with the [`useFunction`](react-api.md#usefunction)
|
|
1213
|
+
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
1214
|
|
|
1005
1215
|
> `@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
1216
|
|