@tenphi/tasty 0.0.0-snapshot.efb24cc → 0.0.0-snapshot.effc80a
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 +440 -367
- package/dist/babel-types-BKDTT4--.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-DHL8W6vf.js +60 -0
- package/dist/chunks/build-config-DHL8W6vf.js.map +1 -0
- package/dist/{ssr/collector.js → chunks/collector-P1lIDioe.js} +79 -104
- package/dist/chunks/collector-P1lIDioe.js.map +1 -0
- package/dist/chunks/config-engine-HlsfjR7T.js +272 -0
- package/dist/chunks/config-engine-HlsfjR7T.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-BE12wEJB.js +910 -0
- package/dist/chunks/css-definitions-BE12wEJB.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/{debug.js → chunks/debug-CWZkJJ7A.js} +196 -147
- package/dist/chunks/debug-CWZkJJ7A.js.map +1 -0
- package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
- package/dist/chunks/dsl-DYSJc1-T.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-BwKuG_3d.js +689 -0
- package/dist/chunks/react-runtime-BwKuG_3d.js.map +1 -0
- package/dist/chunks/runtime-engine-D2N-eiPD.js +2432 -0
- package/dist/chunks/runtime-engine-D2N-eiPD.js.map +1 -0
- package/dist/chunks/runtime-state-BJoTY_DP.js +152 -0
- package/dist/chunks/runtime-state-BJoTY_DP.js.map +1 -0
- package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +60 -56
- package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
- package/dist/chunks/style-engine-CJoK33le.js +5521 -0
- package/dist/chunks/style-engine-CJoK33le.js.map +1 -0
- package/dist/chunks/zero-engine-BCqhSuwo.js +310 -0
- package/dist/chunks/zero-engine-BCqhSuwo.js.map +1 -0
- package/dist/collector-CTU-nl0g.d.ts +164 -0
- package/dist/config-CcxqSZI2.d.ts +1368 -0
- package/dist/core/index.d.ts +5 -34
- package/dist/core/index.js +9 -27
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/index--GdqCPlp.d.ts +1962 -0
- package/dist/index.d.ts +5 -51
- package/dist/index.js +11 -36
- package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.d.ts} +3 -4
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-client.js +1 -14
- package/dist/ssr/astro-client.js.map +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract-static.js +9 -0
- package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
- package/dist/ssr/astro-middleware-extract.d.ts +10 -0
- package/dist/ssr/astro-middleware-extract.js +9 -0
- package/dist/ssr/astro-middleware-extract.js.map +1 -0
- package/dist/ssr/astro-middleware-static.d.ts +17 -0
- package/dist/ssr/astro-middleware-static.js +7 -0
- package/dist/ssr/astro-middleware-static.js.map +1 -0
- package/dist/ssr/astro-middleware.d.ts +11 -8
- package/dist/ssr/astro-middleware.js +2 -14
- package/dist/ssr/astro-middleware.js.map +1 -1
- package/dist/ssr/astro.d.ts +33 -14
- package/dist/ssr/astro.js +163 -91
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +17 -4
- package/dist/ssr/index.js +6 -6
- 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 -9
- package/dist/ssr/next.js +30 -45
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +90 -5
- package/dist/static/index.js +31 -3
- package/dist/static/index.js.map +1 -0
- package/dist/static/inject.d.ts +1 -2
- package/dist/static/inject.js.map +1 -1
- package/dist/types-DJEM_BOJ.d.ts +1567 -0
- package/dist/zero/babel.d.ts +5 -19
- package/dist/zero/babel.js +104 -151
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +135 -3
- package/dist/zero/index.js +24 -3
- 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 +21 -10
- package/docs/adoption.md +69 -36
- package/docs/ai-agents.md +257 -0
- package/docs/comparison.md +77 -47
- package/docs/configuration.md +646 -85
- package/docs/debug.md +39 -24
- package/docs/design-system.md +154 -33
- package/docs/dsl.md +653 -196
- package/docs/getting-started.md +130 -50
- package/docs/injector.md +162 -71
- package/docs/methodology.md +106 -49
- package/docs/migration-v3.md +285 -0
- package/docs/pipeline.md +768 -0
- package/docs/plugins.md +333 -0
- package/docs/react-api.md +232 -45
- package/docs/runtime-benchmarks.md +388 -0
- package/docs/ssr.md +310 -116
- package/docs/styles.md +182 -47
- package/docs/tasty-static.md +284 -130
- package/package.json +142 -35
- package/tasty.config.ts +6 -0
- package/dist/_virtual/_rolldown/runtime.js +0 -7
- package/dist/chunks/cacheKey.d.ts +0 -1
- package/dist/chunks/cacheKey.js +0 -77
- package/dist/chunks/cacheKey.js.map +0 -1
- package/dist/chunks/definitions.d.ts +0 -37
- package/dist/chunks/definitions.js +0 -258
- package/dist/chunks/definitions.js.map +0 -1
- package/dist/chunks/index.d.ts +0 -1
- package/dist/chunks/renderChunk.d.ts +0 -1
- package/dist/chunks/renderChunk.js +0 -59
- package/dist/chunks/renderChunk.js.map +0 -1
- package/dist/compute-styles.d.ts +0 -31
- package/dist/compute-styles.js +0 -322
- package/dist/compute-styles.js.map +0 -1
- package/dist/config.d.ts +0 -407
- package/dist/config.js +0 -591
- package/dist/config.js.map +0 -1
- package/dist/counter-style/index.js +0 -51
- package/dist/counter-style/index.js.map +0 -1
- package/dist/debug.d.ts +0 -89
- package/dist/debug.js.map +0 -1
- package/dist/font-face/index.js +0 -63
- package/dist/font-face/index.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -7
- package/dist/hooks/useCounterStyle.d.ts +0 -36
- package/dist/hooks/useCounterStyle.js +0 -65
- package/dist/hooks/useCounterStyle.js.map +0 -1
- package/dist/hooks/useFontFace.d.ts +0 -45
- package/dist/hooks/useFontFace.js +0 -66
- package/dist/hooks/useFontFace.js.map +0 -1
- package/dist/hooks/useGlobalStyles.d.ts +0 -46
- package/dist/hooks/useGlobalStyles.js +0 -88
- package/dist/hooks/useGlobalStyles.js.map +0 -1
- package/dist/hooks/useKeyframes.d.ts +0 -58
- package/dist/hooks/useKeyframes.js +0 -55
- package/dist/hooks/useKeyframes.js.map +0 -1
- package/dist/hooks/useProperty.d.ts +0 -81
- package/dist/hooks/useProperty.js +0 -96
- package/dist/hooks/useProperty.js.map +0 -1
- package/dist/hooks/useRawCSS.d.ts +0 -22
- package/dist/hooks/useRawCSS.js +0 -103
- package/dist/hooks/useRawCSS.js.map +0 -1
- package/dist/hooks/useStyles.d.ts +0 -40
- package/dist/hooks/useStyles.js +0 -31
- package/dist/hooks/useStyles.js.map +0 -1
- package/dist/injector/index.d.ts +0 -182
- package/dist/injector/index.js +0 -185
- package/dist/injector/index.js.map +0 -1
- package/dist/injector/injector.d.ts +0 -198
- package/dist/injector/injector.js +0 -651
- package/dist/injector/injector.js.map +0 -1
- package/dist/injector/sheet-manager.d.ts +0 -132
- package/dist/injector/sheet-manager.js +0 -699
- package/dist/injector/sheet-manager.js.map +0 -1
- package/dist/injector/types.d.ts +0 -235
- package/dist/keyframes/index.js +0 -206
- package/dist/keyframes/index.js.map +0 -1
- package/dist/parser/classify.js +0 -319
- package/dist/parser/classify.js.map +0 -1
- package/dist/parser/const.js +0 -60
- package/dist/parser/const.js.map +0 -1
- package/dist/parser/lru.js +0 -109
- package/dist/parser/lru.js.map +0 -1
- package/dist/parser/parser.d.ts +0 -25
- package/dist/parser/parser.js +0 -115
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/tokenizer.js +0 -69
- package/dist/parser/tokenizer.js.map +0 -1
- package/dist/parser/types.d.ts +0 -51
- package/dist/parser/types.js +0 -46
- package/dist/parser/types.js.map +0 -1
- package/dist/pipeline/conditions.d.ts +0 -134
- package/dist/pipeline/conditions.js +0 -406
- package/dist/pipeline/conditions.js.map +0 -1
- package/dist/pipeline/exclusive.js +0 -285
- package/dist/pipeline/exclusive.js.map +0 -1
- package/dist/pipeline/index.d.ts +0 -55
- package/dist/pipeline/index.js +0 -708
- package/dist/pipeline/index.js.map +0 -1
- package/dist/pipeline/materialize.js +0 -1157
- package/dist/pipeline/materialize.js.map +0 -1
- package/dist/pipeline/parseStateKey.d.ts +0 -15
- package/dist/pipeline/parseStateKey.js +0 -446
- package/dist/pipeline/parseStateKey.js.map +0 -1
- package/dist/pipeline/simplify.js +0 -690
- package/dist/pipeline/simplify.js.map +0 -1
- package/dist/pipeline/warnings.js +0 -18
- package/dist/pipeline/warnings.js.map +0 -1
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/okhsl-plugin.d.ts +0 -35
- package/dist/plugins/okhsl-plugin.js +0 -97
- package/dist/plugins/okhsl-plugin.js.map +0 -1
- package/dist/plugins/types.d.ts +0 -87
- package/dist/properties/index.js +0 -222
- package/dist/properties/index.js.map +0 -1
- package/dist/properties/property-type-resolver.d.ts +0 -24
- package/dist/properties/property-type-resolver.js +0 -90
- package/dist/properties/property-type-resolver.js.map +0 -1
- package/dist/rsc-cache.js +0 -79
- package/dist/rsc-cache.js.map +0 -1
- package/dist/ssr/async-storage.d.ts +0 -17
- package/dist/ssr/async-storage.js +0 -44
- package/dist/ssr/async-storage.js.map +0 -1
- package/dist/ssr/collect-auto-properties.js +0 -58
- package/dist/ssr/collect-auto-properties.js.map +0 -1
- package/dist/ssr/collector.d.ts +0 -98
- package/dist/ssr/collector.js.map +0 -1
- package/dist/ssr/context.js +0 -16
- package/dist/ssr/context.js.map +0 -1
- package/dist/ssr/format-global-rules.js +0 -22
- package/dist/ssr/format-global-rules.js.map +0 -1
- package/dist/ssr/format-keyframes.js +0 -69
- package/dist/ssr/format-keyframes.js.map +0 -1
- package/dist/ssr/format-property.js +0 -49
- package/dist/ssr/format-property.js.map +0 -1
- package/dist/ssr/format-rules.js +0 -73
- package/dist/ssr/format-rules.js.map +0 -1
- package/dist/ssr/hydrate.d.ts +0 -29
- package/dist/ssr/hydrate.js +0 -45
- package/dist/ssr/hydrate.js.map +0 -1
- package/dist/ssr/ssr-collector-ref.js +0 -29
- package/dist/ssr/ssr-collector-ref.js.map +0 -1
- package/dist/states/index.d.ts +0 -49
- package/dist/states/index.js +0 -170
- package/dist/states/index.js.map +0 -1
- package/dist/static/tastyStatic.d.ts +0 -46
- package/dist/static/tastyStatic.js +0 -30
- package/dist/static/tastyStatic.js.map +0 -1
- package/dist/static/types.d.ts +0 -49
- package/dist/static/types.js +0 -24
- package/dist/static/types.js.map +0 -1
- package/dist/styles/border.d.ts +0 -25
- package/dist/styles/border.js +0 -120
- package/dist/styles/border.js.map +0 -1
- package/dist/styles/color.d.ts +0 -14
- package/dist/styles/color.js +0 -26
- package/dist/styles/color.js.map +0 -1
- package/dist/styles/const.js +0 -17
- package/dist/styles/const.js.map +0 -1
- package/dist/styles/createStyle.js +0 -79
- package/dist/styles/createStyle.js.map +0 -1
- package/dist/styles/dimension.js +0 -109
- package/dist/styles/dimension.js.map +0 -1
- package/dist/styles/directional.js +0 -133
- package/dist/styles/directional.js.map +0 -1
- package/dist/styles/display.d.ts +0 -30
- package/dist/styles/display.js +0 -73
- package/dist/styles/display.js.map +0 -1
- package/dist/styles/fade.d.ts +0 -15
- package/dist/styles/fade.js +0 -62
- package/dist/styles/fade.js.map +0 -1
- package/dist/styles/fill.d.ts +0 -42
- package/dist/styles/fill.js +0 -51
- package/dist/styles/fill.js.map +0 -1
- package/dist/styles/flow.d.ts +0 -16
- package/dist/styles/flow.js +0 -12
- package/dist/styles/flow.js.map +0 -1
- package/dist/styles/gap.d.ts +0 -31
- package/dist/styles/gap.js +0 -38
- package/dist/styles/gap.js.map +0 -1
- package/dist/styles/height.d.ts +0 -17
- package/dist/styles/height.js +0 -19
- package/dist/styles/height.js.map +0 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/index.js +0 -8
- package/dist/styles/index.js.map +0 -1
- package/dist/styles/inset.d.ts +0 -24
- package/dist/styles/inset.js +0 -34
- package/dist/styles/inset.js.map +0 -1
- package/dist/styles/list.d.ts +0 -16
- package/dist/styles/list.js +0 -100
- package/dist/styles/list.js.map +0 -1
- package/dist/styles/margin.d.ts +0 -24
- package/dist/styles/margin.js +0 -32
- package/dist/styles/margin.js.map +0 -1
- package/dist/styles/outline.d.ts +0 -29
- package/dist/styles/outline.js +0 -55
- package/dist/styles/outline.js.map +0 -1
- package/dist/styles/padding.d.ts +0 -24
- package/dist/styles/padding.js +0 -32
- package/dist/styles/padding.js.map +0 -1
- package/dist/styles/placement.d.ts +0 -37
- package/dist/styles/placement.js +0 -74
- package/dist/styles/placement.js.map +0 -1
- package/dist/styles/predefined.d.ts +0 -71
- package/dist/styles/predefined.js +0 -237
- package/dist/styles/predefined.js.map +0 -1
- package/dist/styles/preset.d.ts +0 -52
- package/dist/styles/preset.js +0 -127
- package/dist/styles/preset.js.map +0 -1
- package/dist/styles/radius.d.ts +0 -12
- package/dist/styles/radius.js +0 -83
- package/dist/styles/radius.js.map +0 -1
- package/dist/styles/scrollMargin.d.ts +0 -24
- package/dist/styles/scrollMargin.js +0 -32
- package/dist/styles/scrollMargin.js.map +0 -1
- package/dist/styles/scrollbar.d.ts +0 -25
- package/dist/styles/scrollbar.js +0 -51
- package/dist/styles/scrollbar.js.map +0 -1
- package/dist/styles/shadow.d.ts +0 -14
- package/dist/styles/shadow.js +0 -25
- package/dist/styles/shadow.js.map +0 -1
- package/dist/styles/shared.js +0 -17
- package/dist/styles/shared.js.map +0 -1
- package/dist/styles/transition.d.ts +0 -14
- package/dist/styles/transition.js +0 -159
- package/dist/styles/transition.js.map +0 -1
- package/dist/styles/types.d.ts +0 -564
- package/dist/styles/width.d.ts +0 -17
- package/dist/styles/width.js +0 -19
- package/dist/styles/width.js.map +0 -1
- package/dist/tasty.d.ts +0 -134
- package/dist/tasty.js +0 -248
- package/dist/tasty.js.map +0 -1
- package/dist/types.d.ts +0 -184
- package/dist/utils/cache-wrapper.js +0 -21
- package/dist/utils/cache-wrapper.js.map +0 -1
- package/dist/utils/case-converter.js +0 -8
- package/dist/utils/case-converter.js.map +0 -1
- package/dist/utils/color-math.d.ts +0 -46
- package/dist/utils/color-math.js +0 -749
- package/dist/utils/color-math.js.map +0 -1
- package/dist/utils/color-space.d.ts +0 -5
- package/dist/utils/color-space.js +0 -228
- package/dist/utils/color-space.js.map +0 -1
- package/dist/utils/colors.d.ts +0 -5
- package/dist/utils/colors.js +0 -10
- package/dist/utils/colors.js.map +0 -1
- package/dist/utils/css-types.d.ts +0 -7
- package/dist/utils/deps-equal.js +0 -15
- package/dist/utils/deps-equal.js.map +0 -1
- package/dist/utils/dotize.d.ts +0 -26
- package/dist/utils/dotize.js +0 -122
- package/dist/utils/dotize.js.map +0 -1
- package/dist/utils/filter-base-props.d.ts +0 -15
- package/dist/utils/filter-base-props.js +0 -45
- package/dist/utils/filter-base-props.js.map +0 -1
- package/dist/utils/get-display-name.d.ts +0 -7
- package/dist/utils/get-display-name.js +0 -10
- package/dist/utils/get-display-name.js.map +0 -1
- package/dist/utils/has-keys.js +0 -13
- package/dist/utils/has-keys.js.map +0 -1
- package/dist/utils/hash.js +0 -14
- package/dist/utils/hash.js.map +0 -1
- package/dist/utils/is-dev-env.js +0 -19
- package/dist/utils/is-dev-env.js.map +0 -1
- package/dist/utils/is-valid-element-type.js +0 -15
- package/dist/utils/is-valid-element-type.js.map +0 -1
- package/dist/utils/merge-styles.js.map +0 -1
- package/dist/utils/mod-attrs.d.ts +0 -6
- package/dist/utils/mod-attrs.js +0 -20
- package/dist/utils/mod-attrs.js.map +0 -1
- package/dist/utils/process-tokens.d.ts +0 -17
- package/dist/utils/process-tokens.js +0 -83
- package/dist/utils/process-tokens.js.map +0 -1
- package/dist/utils/resolve-recipes.d.ts +0 -17
- package/dist/utils/resolve-recipes.js +0 -146
- package/dist/utils/resolve-recipes.js.map +0 -1
- package/dist/utils/selector-transform.js +0 -32
- package/dist/utils/selector-transform.js.map +0 -1
- package/dist/utils/string.js +0 -8
- package/dist/utils/string.js.map +0 -1
- package/dist/utils/styles.d.ts +0 -99
- package/dist/utils/styles.js +0 -220
- package/dist/utils/styles.js.map +0 -1
- package/dist/utils/typography.d.ts +0 -58
- package/dist/utils/typography.js +0 -51
- package/dist/utils/typography.js.map +0 -1
- package/dist/utils/warnings.d.ts +0 -16
- package/dist/utils/warnings.js +0 -16
- package/dist/utils/warnings.js.map +0 -1
- package/dist/zero/css-writer.d.ts +0 -45
- package/dist/zero/css-writer.js +0 -73
- package/dist/zero/css-writer.js.map +0 -1
- package/dist/zero/extractor.d.ts +0 -24
- package/dist/zero/extractor.js +0 -266
- package/dist/zero/extractor.js.map +0 -1
- package/docs/PIPELINE.md +0 -519
package/docs/dsl.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Style DSL Reference
|
|
2
2
|
|
|
3
|
-
This is the Tasty
|
|
3
|
+
This is the language behind Tasty’s predictable state resolution. Every property can use a state map; later branches declare higher priority, and Tasty compiles them so only one generated selector can match.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The same value syntax, state maps, tokens, units, extension semantics, and special declarations apply to React `tasty()`—whether rendered on the client or server—and build-time `tastyStatic()`.
|
|
6
|
+
|
|
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
|
+
|
|
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).
|
|
6
10
|
|
|
7
11
|
---
|
|
8
12
|
|
|
@@ -16,22 +20,45 @@ Object where keys represent states and values are the styles to apply:
|
|
|
16
20
|
fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
|
|
17
21
|
```
|
|
18
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
|
+
|
|
19
32
|
#### State Key Types
|
|
20
33
|
|
|
21
|
-
| Syntax
|
|
22
|
-
|
|
23
|
-
| Boolean modifier
|
|
24
|
-
| Value modifier
|
|
25
|
-
| Pseudo-class
|
|
26
|
-
| Class selector
|
|
27
|
-
| Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]`
|
|
28
|
-
| Combined (AND)
|
|
29
|
-
| Combined (OR)
|
|
30
|
-
| Negated (NOT)
|
|
31
|
-
| Exclusive (XOR)
|
|
34
|
+
| Syntax | Example | Generated CSS |
|
|
35
|
+
| ------------------ | ------------------------ | ------------------------------------------------------------------------ |
|
|
36
|
+
| Boolean modifier | `hovered` | `[data-hovered]` |
|
|
37
|
+
| Value modifier | `theme=danger` | `[data-theme="danger"]` |
|
|
38
|
+
| Pseudo-class | `:hover` | `:hover` |
|
|
39
|
+
| Class selector | `.active` | `.active` |
|
|
40
|
+
| Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
|
|
41
|
+
| Combined (AND) | `hovered & .active` | `[data-hovered].active` |
|
|
42
|
+
| Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
|
|
43
|
+
| Negated (NOT) | `!disabled` | `:not([data-disabled])` |
|
|
44
|
+
| Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
|
|
45
|
+
|
|
46
|
+
#### Automatic Native States
|
|
47
|
+
|
|
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:
|
|
49
|
+
|
|
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]` |
|
|
55
|
+
|
|
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.
|
|
32
57
|
|
|
33
58
|
Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
|
|
34
59
|
|
|
60
|
+
A top-level comma is the same as `|`: `'hovered, focused'` is `'hovered | focused'`.
|
|
61
|
+
|
|
35
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:
|
|
36
63
|
|
|
37
64
|
```jsx
|
|
@@ -41,32 +68,52 @@ fill: {
|
|
|
41
68
|
}
|
|
42
69
|
```
|
|
43
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
|
+
|
|
73
|
+
#### Default State Ordering
|
|
74
|
+
|
|
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.
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
// Correct — default first
|
|
79
|
+
color: { '': '#text', hovered: '#accent' }
|
|
80
|
+
|
|
81
|
+
// Auto-corrected with a warning — '' moved to the front
|
|
82
|
+
color: { hovered: '#accent', '': '#text' }
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The bare `''` default still **receives negation** (it is turned off when a higher-priority state matches). For a value that must always apply as a guaranteed floor — even where a query is _unknown_ — use the [`_` fallback floor](#_--fallback-floor) instead. The two can coexist: `''` is the negated default, `_` is the always-on floor. If a map contains only `_` and `''` (no other states), the `''` default is redundant — Tasty keeps the `_` value and drops `''` with a `REDUNDANT_DEFAULT_STATE` warning.
|
|
86
|
+
|
|
44
87
|
### Sub-element
|
|
45
88
|
|
|
46
89
|
Element styled using a capitalized key. Identified by `data-element` attribute:
|
|
47
90
|
|
|
48
91
|
```jsx
|
|
49
|
-
styles: {
|
|
92
|
+
styles: {
|
|
93
|
+
Title: { preset: 'h3' },
|
|
94
|
+
}
|
|
50
95
|
// Targets: <div data-element="Title">
|
|
51
96
|
```
|
|
52
97
|
|
|
53
98
|
#### Selector Affix (`$`)
|
|
54
99
|
|
|
55
|
-
Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
| `
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
100
|
+
Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles.
|
|
101
|
+
|
|
102
|
+
Examples below assume the sub-element key is **Cell** (i.e. `[data-element="Cell"]` in CSS):
|
|
103
|
+
|
|
104
|
+
| Pattern | Result | Description |
|
|
105
|
+
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
106
|
+
| _(none)_ | `[data-element="Cell"]` | Descendant (default) |
|
|
107
|
+
| `>` | `> [data-element="Cell"]` | Direct child |
|
|
108
|
+
| `>Body>` | `> [data-element="Body"] > [data-element="Cell"]` | Chained elements |
|
|
109
|
+
| `> Cell` | `> [data-element="Cell"]` | Self-name shorthand — when the trailing element name matches the sub-element's own key, it acts as the placeholder (same as `@`); no duplication |
|
|
110
|
+
| `h1` | `h1` | Tag selector (no key injection) |
|
|
111
|
+
| `h1 >` | `h1 > [data-element="Cell"]` | Key is direct child of tag |
|
|
112
|
+
| `h1 *` | `h1 *` | Any descendant of tag |
|
|
113
|
+
| `*` | `*` | All descendants |
|
|
114
|
+
| `&::before` | `::before` | Root pseudo (no key); `&` is required |
|
|
115
|
+
| `@::before` | `[data-element="Cell"]::before` | Pseudo on the sub-element |
|
|
116
|
+
| `>@.active` | `> [data-element="Cell"].active` | Class on the sub-element |
|
|
70
117
|
|
|
71
118
|
Rules for key injection (`[data-element="..."]`):
|
|
72
119
|
|
|
@@ -82,20 +129,22 @@ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allo
|
|
|
82
129
|
const List = tasty({
|
|
83
130
|
styles: {
|
|
84
131
|
Item: {
|
|
85
|
-
$: '
|
|
86
|
-
|
|
132
|
+
$: '>@::after',
|
|
133
|
+
content: '""',
|
|
87
134
|
},
|
|
88
135
|
},
|
|
89
136
|
});
|
|
90
|
-
// → .
|
|
137
|
+
// → .t1x29r0l.t1x29r0l > [data-element="Item"]::after { content: ""; }
|
|
91
138
|
```
|
|
92
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. This works when `$` ends in a pseudo-element too: the condition attaches to the element the pseudo-element belongs to (see [`@own(...)`](#own--sub-elements-own-state)).
|
|
141
|
+
|
|
93
142
|
### Color Token
|
|
94
143
|
|
|
95
144
|
Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
|
|
96
145
|
|
|
97
146
|
```jsx
|
|
98
|
-
fill: '#purple.5'
|
|
147
|
+
fill: '#purple.5'; // → oklch(from var(--purple-color) l c h / .5)
|
|
99
148
|
```
|
|
100
149
|
|
|
101
150
|
### Modifier
|
|
@@ -107,7 +156,7 @@ mods={{ hovered: true, theme: 'danger' }}
|
|
|
107
156
|
// → data-hovered="" data-theme="danger"
|
|
108
157
|
```
|
|
109
158
|
|
|
110
|
-
Modifiers can also be exposed as top-level component props via `modProps` — see [
|
|
159
|
+
Modifiers can also be exposed as top-level component props via `modProps` — see [React API — Mod Props](react-api.md#mod-props).
|
|
111
160
|
|
|
112
161
|
---
|
|
113
162
|
|
|
@@ -117,25 +166,176 @@ Modifiers can also be exposed as top-level component props via `modProps` — se
|
|
|
117
166
|
color: '#purple', // Full opacity
|
|
118
167
|
color: '#purple.5', // 50% opacity
|
|
119
168
|
color: '#purple.05', // 5% opacity
|
|
169
|
+
color: '#purple.$fade', // Opacity from a custom property
|
|
120
170
|
fill: '#current', // → currentcolor
|
|
121
|
-
fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
|
|
122
171
|
color: '(#primary, #secondary)', // Fallback syntax
|
|
123
172
|
```
|
|
124
173
|
|
|
174
|
+
`#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.
|
|
175
|
+
|
|
176
|
+
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 `oklch(from var(--ddd-color, #ddd) l c h / .5)`. A `#ddd` token, if you define one, wins over the literal.
|
|
177
|
+
|
|
178
|
+
The suffix sets the alpha on the token's color with CSS relative color syntax:
|
|
179
|
+
|
|
180
|
+
```jsx
|
|
181
|
+
fill: '#purple.5';
|
|
182
|
+
// → oklch(from var(--purple-color) l c h / .5)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
The channels are copied over and the alpha slot is written, which asks nothing of
|
|
186
|
+
the color beyond _being_ a color. That means the suffix works on every one of
|
|
187
|
+
these:
|
|
188
|
+
|
|
189
|
+
- a token holding a `color-mix()`, a `light-dark()`, or a `color()` in a space
|
|
190
|
+
Tasty cannot convert — none of which have channels to decompose
|
|
191
|
+
- `#current`, which resolves to the color the element inherits
|
|
192
|
+
- a `--name-color` variable declared in your own CSS, with no Tasty token
|
|
193
|
+
definition behind it
|
|
194
|
+
|
|
195
|
+
Two properties follow from writing the alpha slot rather than compositing:
|
|
196
|
+
|
|
197
|
+
- **Alpha is replaced, not multiplied.** A token holding `rgb(255 0 0 / .8)`
|
|
198
|
+
faded to `.5` is alpha `.5`, not `.4`.
|
|
199
|
+
- **The alpha may be a number or a percentage.** `#purple.$fade` emits
|
|
200
|
+
`/ var(--fade)` unchanged, so it works whether `$fade` holds `.5` or `50%` —
|
|
201
|
+
which is what `--*-opacity` properties are registered to accept.
|
|
202
|
+
|
|
203
|
+
### `#clear` is transparent
|
|
204
|
+
|
|
205
|
+
`#clear` is a built-in [replace token](#replace-tokens) for `transparent`.
|
|
206
|
+
Opacity suffixes are ignored: `#clear.5` and `#clear.$fade` both emit
|
|
207
|
+
`transparent`. The same rule applies to user-defined replace tokens resolving
|
|
208
|
+
to `transparent`, including aliases of `#clear`.
|
|
209
|
+
|
|
210
|
+
It does not read `--clear-color` or require an `@property` registration.
|
|
211
|
+
An explicit `configure({ replaceTokens: { '#clear': ... } })` overrides the
|
|
212
|
+
default alias and uses the replacement's usual opacity behavior.
|
|
213
|
+
|
|
214
|
+
### `#current` is the keyword
|
|
215
|
+
|
|
216
|
+
`#current` emits the `currentcolor` keyword, so it resolves against the element
|
|
217
|
+
that reads it. That is what lets it follow a color an ancestor faded — a ramp
|
|
218
|
+
that expresses its disabled state once, in `color`, fades everything painted from
|
|
219
|
+
`#current` below it with no further declarations.
|
|
220
|
+
|
|
221
|
+
The `color` style also publishes `--current-color` beside every color it sets,
|
|
222
|
+
for anything that needs the inherited color _as a color_ rather than as the
|
|
223
|
+
keyword — hand-authored CSS, or a place the keyword will not do. Read it as
|
|
224
|
+
`$current-color`. It is registered with `initial-value: currentcolor`, so where
|
|
225
|
+
nothing published it, it still resolves against each element's own color:
|
|
226
|
+
|
|
227
|
+
```jsx
|
|
228
|
+
fill: '$current-color'; // → var(--current-color)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
A color that already reads the color it inherits — `#current`, a `#current` fade
|
|
232
|
+
— is not published into it: resolving such a value a second time at a descendant
|
|
233
|
+
would fade it twice.
|
|
234
|
+
|
|
235
|
+
One case needs the wider floor to be considered. A token _defined_ as `#current`
|
|
236
|
+
and then faded gives relative color syntax a `currentcolor` origin, which Safari
|
|
237
|
+
supports only from 18:
|
|
238
|
+
|
|
239
|
+
```jsx
|
|
240
|
+
{ '#ink': '#current', fill: '#ink.5' }
|
|
241
|
+
// --ink-color: currentcolor
|
|
242
|
+
// fill: oklch(from currentcolor l c h / .5) → Chrome, Firefox, Safari 18+
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Put the fade in the token instead — `{ '#ink': '#current.5' }` — and it goes
|
|
246
|
+
through `color-mix()`, which works from Safari 16.2 and composes like every other
|
|
247
|
+
`#current` fade.
|
|
248
|
+
|
|
249
|
+
### `#current` composes instead
|
|
250
|
+
|
|
251
|
+
`#current` composes alpha, and the difference is deliberate. A token _names_
|
|
252
|
+
a color, so fading it sets its alpha. `currentcolor` is the color an element
|
|
253
|
+
**inherits**, which an ancestor may already have faded — `#current.4` means "40%
|
|
254
|
+
of what reaches me":
|
|
255
|
+
|
|
256
|
+
```jsx
|
|
257
|
+
fill: '#current.4';
|
|
258
|
+
// → color-mix(in oklab, currentcolor 40%, transparent)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
So a `#current` fade nested inside another one composes: a label at `#current.4`
|
|
262
|
+
with a fill of `#current.18` under it lands at `.072`. Color ramps built on
|
|
263
|
+
`#current` depend on that — replacing would double the opacity of every nested
|
|
264
|
+
step. Because a `color-mix()` percentage cannot be a `<number>`, an opacity
|
|
265
|
+
custom property used as `#current.$fade` must hold a unitless number; a token
|
|
266
|
+
accepts either form.
|
|
267
|
+
|
|
268
|
+
Token fades always use `oklch(from …)`: it is unbounded, so a wide-gamut color
|
|
269
|
+
survives a round trip that a gamut-limited space would clamp. `#current` fades
|
|
270
|
+
mix `in oklab`. Nothing configures either — see
|
|
271
|
+
[Color space](configuration.md#color-space).
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## CSS Color Functions
|
|
276
|
+
|
|
277
|
+
Every CSS color function is recognized as a color, so it lands in the color slot
|
|
278
|
+
of whichever style property you use it in — and tokens inside it are expanded:
|
|
279
|
+
|
|
280
|
+
```jsx
|
|
281
|
+
fill: 'color-mix(in oklab, #primary 50%, #surface)',
|
|
282
|
+
color: 'light-dark(#dark, #light)',
|
|
283
|
+
color: 'contrast-color(#primary)',
|
|
284
|
+
fill: 'color(display-p3 1 .5 0)',
|
|
285
|
+
border: '1bw solid oklch(from #primary l c h / 50%)', // relative color syntax
|
|
286
|
+
shadow: '0 0 1x color-mix(in oklab, #dark 20%, transparent)',
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Tasty also ships `okhsl()` and `okhst()`, which compile to `rgb()` at parse
|
|
290
|
+
time: `fill: 'okhsl(280 80% 50%)'` → `rgb(40% 38.5% 88.2%)`.
|
|
291
|
+
|
|
292
|
+
`light-dark()` is the one exception to "always a color": CSS lets it pick between
|
|
293
|
+
values of any type, so it is treated as a color only when its arguments are
|
|
294
|
+
colors. `padding: 'light-dark(1x, 2x)'` still reaches the padding slot.
|
|
295
|
+
|
|
296
|
+
A color token defined as one of these functions takes the
|
|
297
|
+
[opacity suffix](#color-tokens--opacity) like any other:
|
|
298
|
+
|
|
299
|
+
```jsx
|
|
300
|
+
const Card = tasty({
|
|
301
|
+
styles: {
|
|
302
|
+
'#brand': 'color-mix(in oklab, #primary 50%, #surface)',
|
|
303
|
+
fill: '#brand.5',
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
A [replace token](configuration.md#replace-tokens-parse-time-substitution) is
|
|
309
|
+
substituted while parsing, so its color is right there to fade in place. A
|
|
310
|
+
channel function takes the alpha after a slash; a derived function has no alpha
|
|
311
|
+
channel, so it gets wrapped:
|
|
312
|
+
|
|
313
|
+
```jsx
|
|
314
|
+
configure({
|
|
315
|
+
replaceTokens: {
|
|
316
|
+
'#solid': 'hsl(220 90% 50%)',
|
|
317
|
+
'#adaptive': 'light-dark(#dark, #light)',
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
fill: '#solid.5'; // → hsl(220 90% 50% / .5)
|
|
322
|
+
fill: '#adaptive.5'; // → oklch(from light-dark(…) l c h / .5)
|
|
323
|
+
```
|
|
324
|
+
|
|
125
325
|
---
|
|
126
326
|
|
|
127
327
|
## Built-in Units
|
|
128
328
|
|
|
129
|
-
| Unit | Description | Example | CSS
|
|
130
|
-
|
|
131
|
-
| `x`
|
|
132
|
-
| `r`
|
|
133
|
-
| `cr` | Card border radius | `1cr`
|
|
134
|
-
| `bw` | Border width | `2bw`
|
|
135
|
-
| `ow` | Outline width | `1ow`
|
|
136
|
-
| `sf` | Stable fraction | `1sf`
|
|
329
|
+
| Unit | Description | Default | Example | CSS output |
|
|
330
|
+
| ---- | ------------------ | ---------------- | ------- | ---------------- |
|
|
331
|
+
| `x` | Spacing step | `8px` | `2x` | `16px` |
|
|
332
|
+
| `r` | Border radius | `6px` | `1r` | `6px` |
|
|
333
|
+
| `cr` | Card border radius | `10px` | `1cr` | `10px` |
|
|
334
|
+
| `bw` | Border width | `1px` | `2bw` | `2px` |
|
|
335
|
+
| `ow` | Outline width | `3px` | `1ow` | `3px` |
|
|
336
|
+
| `sf` | Stable fraction | `minmax(0, Nfr)` | `1sf` | `minmax(0, 1fr)` |
|
|
137
337
|
|
|
138
|
-
|
|
338
|
+
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).
|
|
139
339
|
|
|
140
340
|
---
|
|
141
341
|
|
|
@@ -176,9 +376,29 @@ const ElevatedCard = tasty({
|
|
|
176
376
|
});
|
|
177
377
|
```
|
|
178
378
|
|
|
379
|
+
**Where recipes resolve:**
|
|
380
|
+
|
|
381
|
+
The `recipe` property is resolved on the component root and independently inside each sub-element's styles:
|
|
382
|
+
|
|
383
|
+
```jsx
|
|
384
|
+
const CardWithPanel = tasty({
|
|
385
|
+
styles: {
|
|
386
|
+
recipe: 'card',
|
|
387
|
+
Panel: {
|
|
388
|
+
recipe: 'card elevated',
|
|
389
|
+
padding: '2x', // Overrides the panel's base recipe padding
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
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).
|
|
396
|
+
|
|
397
|
+
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.
|
|
398
|
+
|
|
179
399
|
**Post-merge recipes (`/` separator):**
|
|
180
400
|
|
|
181
|
-
Recipes listed after `/` are applied
|
|
401
|
+
Recipes listed after `/` are applied _after_ component styles using `mergeStyles`:
|
|
182
402
|
|
|
183
403
|
```jsx
|
|
184
404
|
const Input = tasty({
|
|
@@ -216,8 +436,8 @@ When a style property uses a state map, the merge behavior depends on whether th
|
|
|
216
436
|
const MyButton = tasty(Button, {
|
|
217
437
|
styles: {
|
|
218
438
|
fill: {
|
|
219
|
-
|
|
220
|
-
|
|
439
|
+
loading: '#yellow', // append new state
|
|
440
|
+
disabled: '#gray.20', // override existing state in place
|
|
221
441
|
},
|
|
222
442
|
},
|
|
223
443
|
});
|
|
@@ -227,7 +447,7 @@ const MyButton = tasty(Button, {
|
|
|
227
447
|
styles: {
|
|
228
448
|
fill: {
|
|
229
449
|
'': '#red',
|
|
230
|
-
|
|
450
|
+
hovered: '#blue',
|
|
231
451
|
},
|
|
232
452
|
},
|
|
233
453
|
});
|
|
@@ -252,8 +472,14 @@ fill: {
|
|
|
252
472
|
Use `null` inside a state map to remove a state, or `false` to block it entirely (tombstone):
|
|
253
473
|
|
|
254
474
|
```jsx
|
|
255
|
-
|
|
256
|
-
|
|
475
|
+
const MyButton = tasty(Button, {
|
|
476
|
+
styles: {
|
|
477
|
+
fill: {
|
|
478
|
+
hovered: null, // removes the parent's hovered state
|
|
479
|
+
disabled: false, // tombstone — no CSS for disabled, blocks recipe too
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
});
|
|
257
483
|
```
|
|
258
484
|
|
|
259
485
|
### Resetting Properties with `null` and `false`
|
|
@@ -261,44 +487,54 @@ fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe to
|
|
|
261
487
|
```jsx
|
|
262
488
|
const SimpleButton = tasty(Button, {
|
|
263
489
|
styles: {
|
|
264
|
-
fill: null,
|
|
490
|
+
fill: null, // discard parent's fill, let recipe fill in
|
|
265
491
|
border: false, // no border at all (tombstone — blocks recipe too)
|
|
266
492
|
},
|
|
267
493
|
});
|
|
268
494
|
```
|
|
269
495
|
|
|
270
|
-
| Value
|
|
271
|
-
|
|
272
|
-
| `undefined` | Not provided — parent preserved
|
|
273
|
-
| `null`
|
|
274
|
-
| `false`
|
|
496
|
+
| Value | Meaning | Recipe fills in? |
|
|
497
|
+
| ----------- | ------------------------------------ | ---------------- |
|
|
498
|
+
| `undefined` | Not provided — parent preserved | N/A |
|
|
499
|
+
| `null` | Intentional unset — parent discarded | Yes |
|
|
500
|
+
| `false` | Tombstone — blocks everything | No |
|
|
275
501
|
|
|
276
502
|
---
|
|
277
503
|
|
|
278
504
|
## Advanced States (`@` prefix)
|
|
279
505
|
|
|
280
|
-
| Prefix
|
|
281
|
-
|
|
282
|
-
| `@media`
|
|
283
|
-
| `@(...)`
|
|
284
|
-
| `@supports` | Feature/selector support
|
|
285
|
-
| `@root`
|
|
286
|
-
| `@parent`
|
|
287
|
-
| `@own`
|
|
288
|
-
| `@starting` | Entry animation
|
|
289
|
-
|
|
|
290
|
-
| `:
|
|
291
|
-
| `:
|
|
292
|
-
| `:
|
|
506
|
+
| Prefix | Purpose | Example |
|
|
507
|
+
| ----------- | ----------------------------------------- | -------------------------- |
|
|
508
|
+
| `@media` | Media queries | `@media(w < 768px)` |
|
|
509
|
+
| `@(...)` | Container queries | `@(panel, w >= 300px)` |
|
|
510
|
+
| `@supports` | Feature/selector support | `@supports(display: grid)` |
|
|
511
|
+
| `@root` | Root element states | `@root(schema=dark)` |
|
|
512
|
+
| `@parent` | Parent/ancestor element states | `@parent(hovered)` |
|
|
513
|
+
| `@own` | Sub-element's own state | `@own(hovered)` |
|
|
514
|
+
| `@starting` | Entry animation | `@starting` |
|
|
515
|
+
| `_` | Fallback floor (always-on, never negated) | `_` |
|
|
516
|
+
| `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
|
|
517
|
+
| `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
|
|
518
|
+
| `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
|
|
519
|
+
| `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
|
|
520
|
+
|
|
521
|
+
> **Specificity.** All state selectors Tasty generates (modifiers, pseudo-classes,
|
|
522
|
+
> `:is()`/`:not()` groups, and `@root` / `@parent` context) are wrapped in
|
|
523
|
+
> `:where(...)` so they carry **zero specificity**. The only specificity anchors
|
|
524
|
+
> are the doubled component class (`.t0.t0`) and sub-element `[data-element]`
|
|
525
|
+
> attributes. This means overlapping rules (e.g. a `_` fallback floor and the
|
|
526
|
+
> states layered over it) resolve purely by **source order** — Tasty emits
|
|
527
|
+
> lower-priority states first and higher-priority states last so the cascade
|
|
528
|
+
> produces the intended winner.
|
|
293
529
|
|
|
294
530
|
### `@media(...)` — Media Queries
|
|
295
531
|
|
|
296
|
-
Media queries support dimension shorthands
|
|
532
|
+
Media queries support dimension shorthands:
|
|
297
533
|
|
|
298
534
|
| Shorthand | Expands to |
|
|
299
|
-
|
|
300
|
-
| `w`
|
|
301
|
-
| `h`
|
|
535
|
+
| --------- | ---------- |
|
|
536
|
+
| `w` | `width` |
|
|
537
|
+
| `h` | `height` |
|
|
302
538
|
|
|
303
539
|
```jsx
|
|
304
540
|
fill: {
|
|
@@ -309,16 +545,23 @@ fill: {
|
|
|
309
545
|
}
|
|
310
546
|
```
|
|
311
547
|
|
|
312
|
-
| Tasty syntax
|
|
313
|
-
|
|
314
|
-
| `@media(w < 768px)`
|
|
315
|
-
| `@media(600px <= w < 1200px)`
|
|
316
|
-
| `@media:print`
|
|
317
|
-
| `@media:screen`
|
|
548
|
+
| Tasty syntax | CSS output |
|
|
549
|
+
| ------------------------------------ | ------------------------------------- |
|
|
550
|
+
| `@media(w < 768px)` | `@media (width < 768px)` |
|
|
551
|
+
| `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
|
|
552
|
+
| `@media:print` | `@media print` |
|
|
553
|
+
| `@media:screen` | `@media screen` |
|
|
554
|
+
| `@media:all` | `@media all` |
|
|
555
|
+
| `@media:speech` | `@media speech` |
|
|
318
556
|
| `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
|
|
319
|
-
| `@media(prefers-reduced-motion)`
|
|
557
|
+
| `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
|
|
558
|
+
| `@media(aspect-ratio > 16/9)` | `@media (aspect-ratio > 16/9)` |
|
|
320
559
|
|
|
321
|
-
|
|
560
|
+
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`.
|
|
561
|
+
|
|
562
|
+
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`.
|
|
563
|
+
|
|
564
|
+
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.
|
|
322
565
|
|
|
323
566
|
In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
|
|
324
567
|
|
|
@@ -326,12 +569,12 @@ In practice, define state aliases via `configure({ states })` and use `@mobile`
|
|
|
326
569
|
|
|
327
570
|
Container queries use the syntax `@(name, condition)` for named containers or `@(condition)` for the nearest ancestor container. Dimension shorthands (`w`, `h`, `is`, `bs`) are expanded the same way as `@media`.
|
|
328
571
|
|
|
329
|
-
| Shorthand | Expands to
|
|
330
|
-
|
|
331
|
-
| `w`
|
|
332
|
-
| `h`
|
|
333
|
-
| `is`
|
|
334
|
-
| `bs`
|
|
572
|
+
| Shorthand | Expands to |
|
|
573
|
+
| --------- | ------------- |
|
|
574
|
+
| `w` | `width` |
|
|
575
|
+
| `h` | `height` |
|
|
576
|
+
| `is` | `inline-size` |
|
|
577
|
+
| `bs` | `block-size` |
|
|
335
578
|
|
|
336
579
|
```jsx
|
|
337
580
|
const Panel = tasty({
|
|
@@ -344,26 +587,31 @@ const Panel = tasty({
|
|
|
344
587
|
});
|
|
345
588
|
```
|
|
346
589
|
|
|
347
|
-
| Tasty syntax
|
|
348
|
-
|
|
349
|
-
| `@(layout, w < 600px)`
|
|
350
|
-
| `@(w < 600px)`
|
|
351
|
-
| `@(layout, $variant=danger)`
|
|
352
|
-
| `@(layout, $compact)`
|
|
353
|
-
| `@(scroll-state(stuck: top))`
|
|
354
|
-
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)`
|
|
590
|
+
| Tasty syntax | CSS output |
|
|
591
|
+
| ---------------------------------- | -------------------------------------------- |
|
|
592
|
+
| `@(layout, w < 600px)` | `@container layout (width < 600px)` |
|
|
593
|
+
| `@(w < 600px)` | `@container (width < 600px)` |
|
|
594
|
+
| `@(layout, $variant=danger)` | `@container layout style(--variant: danger)` |
|
|
595
|
+
| `@(layout, $compact)` | `@container layout style(--compact)` |
|
|
596
|
+
| `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
|
|
597
|
+
| `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
|
|
355
598
|
|
|
356
|
-
Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop:
|
|
599
|
+
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"`.
|
|
600
|
+
|
|
601
|
+
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.
|
|
357
602
|
|
|
358
603
|
### `@supports(...)` — Feature Queries
|
|
359
604
|
|
|
360
|
-
Feature queries test CSS property support
|
|
605
|
+
Feature queries test CSS property support and accept CSS support functions such
|
|
606
|
+
as `at-rule()`. Use `$` as the first argument to test selector support:
|
|
361
607
|
|
|
362
|
-
| Tasty syntax
|
|
363
|
-
|
|
364
|
-
| `@supports(display: grid)`
|
|
365
|
-
| `@supports($, :has(*))`
|
|
366
|
-
|
|
|
608
|
+
| Tasty syntax | CSS output |
|
|
609
|
+
| ----------------------------- | ----------------------------------- |
|
|
610
|
+
| `@supports(display: grid)` | `@supports (display: grid)` |
|
|
611
|
+
| `@supports($, :has(*))` | `@supports selector(:has(*))` |
|
|
612
|
+
| `@supports(at-rule(@scope))` | `@supports (at-rule(@scope))` |
|
|
613
|
+
| `!@supports(display: grid)` | `@supports (not (display: grid))` |
|
|
614
|
+
| `!@supports(at-rule(@scope))` | `@supports (not (at-rule(@scope)))` |
|
|
367
615
|
|
|
368
616
|
```jsx
|
|
369
617
|
display: {
|
|
@@ -372,6 +620,114 @@ display: {
|
|
|
372
620
|
}
|
|
373
621
|
```
|
|
374
622
|
|
|
623
|
+
`at-rule()` tests whether the browser supports the named at-rule. Its surrounding
|
|
624
|
+
parentheses in Tasty's CSS output are valid CSS. Negation and combinations with
|
|
625
|
+
other states use the same syntax as property queries:
|
|
626
|
+
|
|
627
|
+
```jsx
|
|
628
|
+
color: {
|
|
629
|
+
_: 'red',
|
|
630
|
+
'@supports(at-rule(@scope)) & @supports(display: grid)': 'blue',
|
|
631
|
+
}
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
Use `_` to keep a base value when a browser cannot evaluate a query. A support
|
|
635
|
+
query only detects a browser feature; it does not add an API for authoring the
|
|
636
|
+
queried at-rule in a Tasty style object. For conditional stylesheet imports such
|
|
637
|
+
as `@import url("scoped.css") supports(at-rule(@scope));`, use an ordinary CSS
|
|
638
|
+
stylesheet or document-level `useRawCSS()`. Put imports before other rules in
|
|
639
|
+
that stylesheet. Imports cannot be used in constructable stylesheets, including
|
|
640
|
+
Tasty's adopted-sheet mode for Shadow DOM.
|
|
641
|
+
|
|
642
|
+
### `_` — Fallback Floor
|
|
643
|
+
|
|
644
|
+
By default Tasty makes states **mutually exclusive**: a higher-priority state
|
|
645
|
+
turns the lower-priority ones off via negation, so exactly one branch applies.
|
|
646
|
+
This relies on `A | !A` always being true. CSS feature/container queries break
|
|
647
|
+
that assumption: `@supports(...)` and `@(...)` queries can be **unknown** (not
|
|
648
|
+
just true/false), and `not(unknown)` is also unknown — so a negated default
|
|
649
|
+
branch silently never applies. The classic case is `scroll-state`: a browser can
|
|
650
|
+
support `container-type: scroll-state` while a specific `scroll-state(...)` query
|
|
651
|
+
is unknown, leaving _no_ branch active.
|
|
652
|
+
|
|
653
|
+
The `_` fallback floor solves this. Use `_` as a **standalone key** and its value
|
|
654
|
+
**always applies** as a guaranteed floor: it never receives negation, and
|
|
655
|
+
higher-priority states simply layer over it via the cascade.
|
|
656
|
+
|
|
657
|
+
```jsx
|
|
658
|
+
inset: {
|
|
659
|
+
_: '0 top',
|
|
660
|
+
'@supports(container-type: scroll-state) & @(scroll-state(scrolled: block-end))':
|
|
661
|
+
'-80x top',
|
|
662
|
+
}
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
```css
|
|
666
|
+
.t0.t0 {
|
|
667
|
+
inset: 0 auto auto auto;
|
|
668
|
+
}
|
|
669
|
+
@supports (container-type: scroll-state) {
|
|
670
|
+
@container scroll-state(scrolled: block-end) {
|
|
671
|
+
.t0.t0 {
|
|
672
|
+
inset: -640px auto auto auto;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
The floor is emitted as a bare rule (no negated `@supports` / container branches),
|
|
679
|
+
so it always applies. When the override matches it wins because it is emitted
|
|
680
|
+
later and all state selectors share the same specificity (see the note on
|
|
681
|
+
`:where()` above).
|
|
682
|
+
|
|
683
|
+
Notes:
|
|
684
|
+
|
|
685
|
+
- `_` is a **standalone key only** — it defines a single map-wide floor and
|
|
686
|
+
cannot be combined with state logic. Keys like `_ & hovered` or `_ | focused`
|
|
687
|
+
are ignored with an `INVALID_FALLBACK_KEY` dev warning.
|
|
688
|
+
- `_` can coexist with the bare `''` default when other states exist: `''` is the
|
|
689
|
+
negated default, `_` is the always-on floor. With only `_` and `''` (no other
|
|
690
|
+
states) the `''` default is redundant — Tasty keeps the `_` value and drops
|
|
691
|
+
`''` with a `REDUNDANT_DEFAULT_STATE` warning.
|
|
692
|
+
- `_` is position-independent: it is always placed at the lowest priority
|
|
693
|
+
regardless of where it appears in the map.
|
|
694
|
+
|
|
695
|
+
#### `_` vs the `''` default
|
|
696
|
+
|
|
697
|
+
In simple maps where every other state is a plain modifier (always cleanly
|
|
698
|
+
on/off), `_` and `''` produce the **same visible result** — the base value shows
|
|
699
|
+
whenever no other state wins. They diverge in three situations, and the root
|
|
700
|
+
cause is always the same: **`''` is mutually exclusive (turned off by negation),
|
|
701
|
+
while `_` is always on (layered underneath).**
|
|
702
|
+
|
|
703
|
+
- **Unknown / invalid branches.** If a higher-priority branch sits behind a query
|
|
704
|
+
that can be _unknown_ (`@supports`, container, `scroll-state`) or uses a
|
|
705
|
+
selector the browser drops, the negated `''` default disappears along with it
|
|
706
|
+
(`not(unknown) = unknown`), leaving the property with no rule. The `_` floor
|
|
707
|
+
survives because it is an unconditional bare rule. This is the case `_` exists
|
|
708
|
+
for.
|
|
709
|
+
|
|
710
|
+
- **Empty / "unset" states.** A state can intentionally produce _no_ output (an
|
|
711
|
+
empty value) to leave a property unset while that state is active. With `''`
|
|
712
|
+
this works — the default is negated away and nothing replaces it, so the
|
|
713
|
+
property unsets. With `_` the floor can never be turned off, so its value keeps
|
|
714
|
+
applying and the "unset on this state" intent is lost.
|
|
715
|
+
|
|
716
|
+
```jsx
|
|
717
|
+
// '' : color unsets while loading. '_' : color stays #text while loading.
|
|
718
|
+
color: { '': '#text', loading: '' }
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
- **States with different output shapes.** Because `_` layers additively, when
|
|
722
|
+
different states emit _different sets_ of declarations, the floor's
|
|
723
|
+
declarations bleed through wherever the winning state does not override the
|
|
724
|
+
same property — which can produce inconsistent combinations. A `''` default is
|
|
725
|
+
swapped out cleanly by its mutually-exclusive condition.
|
|
726
|
+
|
|
727
|
+
Rule of thumb: **use `''` for the normal default** (clean mutual exclusivity,
|
|
728
|
+
supports unsetting), and reach for `_` only when a value must survive an
|
|
729
|
+
_unknown_ higher-priority branch.
|
|
730
|
+
|
|
375
731
|
### `@root(...)` — Root Element States
|
|
376
732
|
|
|
377
733
|
Root states generate selectors on the `:root` element. They are useful for theme modes, feature flags, and other page-level conditions:
|
|
@@ -386,15 +742,15 @@ color: {
|
|
|
386
742
|
}
|
|
387
743
|
```
|
|
388
744
|
|
|
389
|
-
| Tasty syntax
|
|
390
|
-
|
|
391
|
-
| `@root(schema=dark)`
|
|
392
|
-
| `@root(hovered)`
|
|
393
|
-
| `@root(.premium-user)` | `:root.premium-user`
|
|
394
|
-
| `@root([lang="en"])`
|
|
395
|
-
| `!@root(schema=dark)`
|
|
745
|
+
| Tasty syntax | CSS selector |
|
|
746
|
+
| ---------------------- | --------------------------------- |
|
|
747
|
+
| `@root(schema=dark)` | `:root[data-schema="dark"]` |
|
|
748
|
+
| `@root(hovered)` | `:root[data-hovered]` |
|
|
749
|
+
| `@root(.premium-user)` | `:root.premium-user` |
|
|
750
|
+
| `@root([lang="en"])` | `:root[lang="en"]` |
|
|
751
|
+
| `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
|
|
396
752
|
|
|
397
|
-
Root conditions are prepended to the component selector
|
|
753
|
+
Root conditions are prepended to the component selector inside `:where()`: `:where(:root[data-schema="dark"]) .t0.t0 { ... }`.
|
|
398
754
|
|
|
399
755
|
### `@own(...)` — Sub-element's Own State
|
|
400
756
|
|
|
@@ -408,7 +764,7 @@ const Nav = tasty({
|
|
|
408
764
|
'': '#text',
|
|
409
765
|
'@own(:hover)': '#primary',
|
|
410
766
|
'@own(:focus-visible)': '#primary',
|
|
411
|
-
|
|
767
|
+
selected: '#primary', // root-level modifier
|
|
412
768
|
},
|
|
413
769
|
},
|
|
414
770
|
},
|
|
@@ -416,14 +772,28 @@ const Nav = tasty({
|
|
|
416
772
|
});
|
|
417
773
|
```
|
|
418
774
|
|
|
419
|
-
| Tasty syntax (inside sub-element) | CSS output
|
|
420
|
-
|
|
421
|
-
| `@own(:hover)`
|
|
422
|
-
| `@own(hovered)`
|
|
423
|
-
| `@own(theme=dark)`
|
|
775
|
+
| Tasty syntax (inside sub-element) | CSS output |
|
|
776
|
+
| --------------------------------- | ------------------------------------------------- |
|
|
777
|
+
| `@own(:hover)` | `:hover` on the sub-element selector |
|
|
778
|
+
| `@own(hovered)` | `[data-hovered]` on the sub-element selector |
|
|
779
|
+
| `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
|
|
424
780
|
|
|
425
781
|
`@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
|
|
426
782
|
|
|
783
|
+
When `$` ends in a pseudo-element, the condition attaches to the originating element, before the pseudo-element. Browsers accept at most a few user-action pseudo-classes after a pseudo-element, so a condition placed there would never match:
|
|
784
|
+
|
|
785
|
+
```jsx
|
|
786
|
+
Icon: {
|
|
787
|
+
$: 'a::before',
|
|
788
|
+
content: { '': 'none', '@own([rel="next"])': '"→"' },
|
|
789
|
+
},
|
|
790
|
+
// → .t0.t0 a:where([rel="next"])::before { content: "→"; }
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
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`. In a `$` list, each item gets the condition before its own pseudo-element.
|
|
794
|
+
|
|
795
|
+
So `@own(:hover)` on `$: '@::part(label)'` or `'@::-webkit-scrollbar-thumb'` means the element is hovered, not the part or the thumb. To style a state of the pseudo-element itself, write the pseudo-class after it in the selector, either in `$` (`'@::part(label):hover'`) or as a nested `'&:hover'` key. It stays after the pseudo-element.
|
|
796
|
+
|
|
427
797
|
### `@starting` — Entry Animation
|
|
428
798
|
|
|
429
799
|
Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
|
|
@@ -433,40 +803,40 @@ const FadeIn = tasty({
|
|
|
433
803
|
styles: {
|
|
434
804
|
opacity: { '': '1', '@starting': '0' },
|
|
435
805
|
transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
|
|
436
|
-
transition: 'opacity
|
|
806
|
+
transition: 'opacity, translate',
|
|
437
807
|
},
|
|
438
808
|
});
|
|
439
809
|
```
|
|
440
810
|
|
|
441
|
-
| Tasty syntax | CSS output
|
|
442
|
-
|
|
443
|
-
| `@starting`
|
|
811
|
+
| Tasty syntax | CSS output |
|
|
812
|
+
| ------------ | ------------------------------------ |
|
|
813
|
+
| `@starting` | `.t0.t0 { @starting-style { ... } }` |
|
|
444
814
|
|
|
445
815
|
### `@parent(...)` — Parent Element States
|
|
446
816
|
|
|
447
|
-
Style based on ancestor element attributes. Uses `:
|
|
817
|
+
Style based on ancestor element attributes. Uses `:where([selector] *)` / `:where(:not([selector] *))` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
|
|
448
818
|
|
|
449
819
|
```jsx
|
|
450
820
|
const Highlight = tasty({
|
|
451
821
|
styles: {
|
|
452
822
|
fill: {
|
|
453
823
|
'': '#white',
|
|
454
|
-
'@parent(hovered)': '#gray.05',
|
|
455
|
-
'@parent(theme=dark, >)': '#dark-02',
|
|
824
|
+
'@parent(hovered)': '#gray.05', // Any ancestor has [data-hovered]
|
|
825
|
+
'@parent(theme=dark, >)': '#dark-02', // Direct parent has [data-theme="dark"]
|
|
456
826
|
},
|
|
457
827
|
},
|
|
458
828
|
});
|
|
459
829
|
```
|
|
460
830
|
|
|
461
|
-
| Syntax
|
|
462
|
-
|
|
463
|
-
| `@parent(hovered)`
|
|
464
|
-
| `!@parent(hovered)`
|
|
465
|
-
| `@parent(hovered, >)`
|
|
466
|
-
| `@parent(.active)`
|
|
467
|
-
| `@parent(hovered & focused)`
|
|
468
|
-
| `@parent(hovered) & @parent(focused)` | `:
|
|
469
|
-
| `@parent(hovered \| focused)`
|
|
831
|
+
| Syntax | CSS Output |
|
|
832
|
+
| ------------------------------------- | -------------------------------------------------------------------------- |
|
|
833
|
+
| `@parent(hovered)` | `:where([data-hovered] *)` |
|
|
834
|
+
| `!@parent(hovered)` | `:where(:not([data-hovered] *))` |
|
|
835
|
+
| `@parent(hovered, >)` | `:where([data-hovered] > *)` (direct parent) |
|
|
836
|
+
| `@parent(.active)` | `:where(.active *)` |
|
|
837
|
+
| `@parent(hovered & focused)` | `:where([data-hovered][data-focused] *)` (same ancestor) |
|
|
838
|
+
| `@parent(hovered) & @parent(focused)` | `:where([data-hovered] *):where([data-focused] *)` (independent ancestors) |
|
|
839
|
+
| `@parent(hovered \| focused)` | `:where([data-hovered] *, [data-focused] *)` (OR inside single wrapper) |
|
|
470
840
|
|
|
471
841
|
For sub-elements, the parent check applies to the root element's ancestors:
|
|
472
842
|
|
|
@@ -481,12 +851,12 @@ const Card = tasty({
|
|
|
481
851
|
},
|
|
482
852
|
},
|
|
483
853
|
});
|
|
484
|
-
// → .t0.t0:
|
|
854
|
+
// → .t0.t0:where([data-hovered] *) [data-element="Label"]
|
|
485
855
|
```
|
|
486
856
|
|
|
487
857
|
### `:is()`, `:has()` — CSS Structural Pseudo-classes
|
|
488
858
|
|
|
489
|
-
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 `*`.
|
|
859
|
+
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()`.
|
|
490
860
|
|
|
491
861
|
`:where()` and `:not()` are also supported but rarely needed — use `:is()` and `!` negation instead.
|
|
492
862
|
|
|
@@ -497,38 +867,38 @@ const Card = tasty({
|
|
|
497
867
|
styles: {
|
|
498
868
|
display: {
|
|
499
869
|
'': 'block',
|
|
500
|
-
':has(> Icon)': 'grid',
|
|
501
|
-
':has(+ Icon)': 'grid',
|
|
502
|
-
':has(~ Icon)': 'grid',
|
|
503
|
-
':has(Icon +)': 'grid',
|
|
504
|
-
':has(Icon ~)': 'grid',
|
|
505
|
-
':is(fieldset > label)': 'inline',
|
|
506
|
-
'!:has(> Icon)': 'flex',
|
|
870
|
+
':has(> Icon)': 'grid', // has Icon as direct child
|
|
871
|
+
':has(+ Icon)': 'grid', // immediately followed by an Icon sibling
|
|
872
|
+
':has(~ Icon)': 'grid', // has an Icon sibling somewhere after
|
|
873
|
+
':has(Icon +)': 'grid', // immediately preceded by an Icon sibling (auto-completes to `Icon + *`)
|
|
874
|
+
':has(Icon ~)': 'grid', // has an Icon sibling somewhere before (auto-completes to `Icon ~ *`)
|
|
875
|
+
':is(fieldset > label)': 'inline', // is a label inside a fieldset (HTML tags)
|
|
876
|
+
'!:has(> Icon)': 'flex', // negation: no Icon child
|
|
507
877
|
},
|
|
508
878
|
},
|
|
509
879
|
});
|
|
510
880
|
```
|
|
511
881
|
|
|
512
|
-
| Syntax
|
|
513
|
-
|
|
514
|
-
| `:has(> Icon)`
|
|
515
|
-
| `:has(+ Icon)`
|
|
516
|
-
| `:has(~ Icon)`
|
|
517
|
-
| `:has(Icon +)`
|
|
518
|
-
| `:has(Icon ~)`
|
|
519
|
-
| `:has(>)`
|
|
520
|
-
| `:is(
|
|
521
|
-
| `:has(button)`
|
|
522
|
-
| `!:has(> Icon)`
|
|
523
|
-
| `!:is(Panel)`
|
|
882
|
+
| Syntax | CSS Output | Meaning |
|
|
883
|
+
| -------------------- | ------------------------------------- | --------------------------------------- |
|
|
884
|
+
| `:has(> Icon)` | `:has(> [data-element="Icon"])` | Has Icon as direct child |
|
|
885
|
+
| `:has(+ Icon)` | `:has(+ [data-element="Icon"])` | Immediately followed by an Icon sibling |
|
|
886
|
+
| `:has(~ Icon)` | `:has(~ [data-element="Icon"])` | Has an Icon sibling somewhere after |
|
|
887
|
+
| `:has(Icon +)` | `:has([data-element="Icon"] + *)` | Immediately preceded by an Icon sibling |
|
|
888
|
+
| `:has(Icon ~)` | `:has([data-element="Icon"] ~ *)` | Has an Icon sibling somewhere before |
|
|
889
|
+
| `:has(>)` | `:has(> *)` | Has any direct child |
|
|
890
|
+
| `:is(Field + input)` | `:is([data-element="Field"] + input)` | Is an input right after a Field sibling |
|
|
891
|
+
| `:has(button)` | `:has(button)` | HTML tag (lowercase, unchanged) |
|
|
892
|
+
| `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
|
|
893
|
+
| `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
|
|
524
894
|
|
|
525
895
|
Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
|
|
526
896
|
|
|
527
897
|
```jsx
|
|
528
|
-
':has(> Icon) & hovered'
|
|
529
|
-
'@parent(hovered) & :has(> Icon)'
|
|
530
|
-
':has(> Icon) | :has(> Button)'
|
|
531
|
-
':has(> Icon) ^ :has(> Button)'
|
|
898
|
+
':has(> Icon) & hovered'; // AND: structural + data attribute
|
|
899
|
+
'@parent(hovered) & :has(> Icon)'; // AND: parent check + structural
|
|
900
|
+
':has(> Icon) | :has(> Button)'; // OR: either sub-element present
|
|
901
|
+
':has(> Icon) ^ :has(> Button)'; // XOR: exactly one present
|
|
532
902
|
```
|
|
533
903
|
|
|
534
904
|
> **Nesting limit:** The state key parser supports up to 2 levels of nested parentheses inside `:is()`, `:has()`, `:not()`, and `:where()` — e.g. `:has(Input:not(:disabled))` works, but 3+ levels like `:has(:is(:not(:hover)))` will not be tokenized correctly. This covers virtually all practical use cases.
|
|
@@ -553,6 +923,8 @@ const Pulse = tasty({
|
|
|
553
923
|
});
|
|
554
924
|
```
|
|
555
925
|
|
|
926
|
+
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.
|
|
927
|
+
|
|
556
928
|
---
|
|
557
929
|
|
|
558
930
|
## Properties (`@property`)
|
|
@@ -563,39 +935,59 @@ CSS cannot transition or animate custom properties unless the browser knows thei
|
|
|
563
935
|
const AnimatedGradient = tasty({
|
|
564
936
|
styles: {
|
|
565
937
|
'$gradient-angle': '0deg',
|
|
566
|
-
'#theme': '
|
|
567
|
-
|
|
568
|
-
transition: '$$gradient-angle
|
|
938
|
+
'#theme': 'okhst(280 80% 50%)',
|
|
939
|
+
image: 'linear-gradient($gradient-angle, #theme, #clear)',
|
|
940
|
+
transition: '$$gradient-angle, ##theme',
|
|
569
941
|
},
|
|
570
942
|
});
|
|
571
943
|
```
|
|
572
944
|
|
|
573
945
|
Here `$gradient-angle: '0deg'` is detected as `<angle>` and `#theme` as `<color>` (via the `#name` naming convention), so both transitions work without any manual `@property` declarations. Numeric types (`<number>`, `<length>`, `<percentage>`, `<angle>`, `<time>`) are inferred from values; `<color>` is inferred from `#name` tokens.
|
|
574
946
|
|
|
575
|
-
Use explicit `@
|
|
947
|
+
Use explicit `@property` when you need non-default settings like `inherits: false`:
|
|
576
948
|
|
|
577
949
|
```jsx
|
|
578
|
-
'@
|
|
950
|
+
'@property': {
|
|
579
951
|
'$gradient-angle': { syntax: '<angle>', inherits: false, initialValue: '0deg' },
|
|
580
952
|
},
|
|
581
953
|
```
|
|
582
954
|
|
|
955
|
+
### Default properties
|
|
956
|
+
|
|
957
|
+
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.
|
|
958
|
+
|
|
959
|
+
| Token | Initial value | Read by |
|
|
960
|
+
| ---------------------------------------------------- | ---------------------------------------- | -------------------------------------------------------------- |
|
|
961
|
+
| `#current` | `currentcolor` | anything reading `$current-color`, which `color` sets |
|
|
962
|
+
| `#white`, `#black` | `rgb(255 255 255)`, `rgb(0 0 0)` | your styles |
|
|
963
|
+
| `#border` | `currentcolor` | `border` with no color |
|
|
964
|
+
| `#outline` | `currentcolor` | `outline` with no color |
|
|
965
|
+
| `$gap`, `$radius`, `$border-width`, `$outline-width` | `8px`, `6px`, `1px`, `3px` | units you point at them, as in `units: { x: 'var(--gap)' }` |
|
|
966
|
+
| `$transition` | `80ms` | `transition` with no duration |
|
|
967
|
+
| `$sharp-radius` | `0px` | the sharp corners of `radius: 'leaf'` and `radius: 'backleaf'` |
|
|
968
|
+
| `$bold-font-weight` | `700` | `preset: 'name / strong'` |
|
|
969
|
+
| `$font-sans-fallback`, `$font-mono-fallback` | a `system-ui` and a `ui-monospace` stack | `font` and presets, after `$font-sans` / `$font-mono` |
|
|
970
|
+
|
|
971
|
+
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.
|
|
972
|
+
|
|
973
|
+
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 })`.
|
|
974
|
+
|
|
583
975
|
---
|
|
584
976
|
|
|
585
|
-
## Font Face (`@
|
|
977
|
+
## Font Face (`@font-face`)
|
|
586
978
|
|
|
587
979
|
Register custom fonts directly inside a `styles` object. Keys are font-family names, values are descriptor objects (or arrays of them for multiple weights/styles).
|
|
588
980
|
|
|
589
981
|
```ts
|
|
590
982
|
const Heading = tasty({
|
|
591
983
|
styles: {
|
|
592
|
-
'@
|
|
984
|
+
'@font-face': {
|
|
593
985
|
'Brand Sans': {
|
|
594
986
|
src: 'url("/fonts/brand-sans.woff2") format("woff2")',
|
|
595
987
|
fontDisplay: 'swap',
|
|
596
988
|
},
|
|
597
989
|
},
|
|
598
|
-
|
|
990
|
+
font: '"Brand Sans", sans-serif',
|
|
599
991
|
},
|
|
600
992
|
});
|
|
601
993
|
```
|
|
@@ -605,7 +997,7 @@ const Heading = tasty({
|
|
|
605
997
|
Supply an array to register several variants of the same family:
|
|
606
998
|
|
|
607
999
|
```ts
|
|
608
|
-
'@
|
|
1000
|
+
'@font-face': {
|
|
609
1001
|
'Brand Sans': [
|
|
610
1002
|
{ src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
|
|
611
1003
|
{ src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
|
|
@@ -615,34 +1007,34 @@ Supply an array to register several variants of the same family:
|
|
|
615
1007
|
|
|
616
1008
|
### Supported descriptors
|
|
617
1009
|
|
|
618
|
-
| Descriptor
|
|
619
|
-
|
|
620
|
-
| `src` (required)
|
|
621
|
-
| `fontWeight`
|
|
622
|
-
| `fontStyle`
|
|
623
|
-
| `fontStretch`
|
|
624
|
-
| `fontDisplay`
|
|
625
|
-
| `unicodeRange`
|
|
626
|
-
| `ascentOverride`
|
|
627
|
-
| `descentOverride`
|
|
628
|
-
| `lineGapOverride`
|
|
629
|
-
| `sizeAdjust`
|
|
630
|
-
| `fontFeatureSettings`
|
|
631
|
-
| `fontVariationSettings` | `font-variation-settings` | `string`
|
|
1010
|
+
| Descriptor | CSS property | Type |
|
|
1011
|
+
| ----------------------- | ------------------------- | --------------------------------------------------------- |
|
|
1012
|
+
| `src` (required) | `src` | `string` |
|
|
1013
|
+
| `fontWeight` | `font-weight` | `string \| number` |
|
|
1014
|
+
| `fontStyle` | `font-style` | `string` |
|
|
1015
|
+
| `fontStretch` | `font-stretch` | `string` |
|
|
1016
|
+
| `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
|
|
1017
|
+
| `unicodeRange` | `unicode-range` | `string` |
|
|
1018
|
+
| `ascentOverride` | `ascent-override` | `string` |
|
|
1019
|
+
| `descentOverride` | `descent-override` | `string` |
|
|
1020
|
+
| `lineGapOverride` | `line-gap-override` | `string` |
|
|
1021
|
+
| `sizeAdjust` | `size-adjust` | `string` |
|
|
1022
|
+
| `fontFeatureSettings` | `font-feature-settings` | `string` |
|
|
1023
|
+
| `fontVariationSettings` | `font-variation-settings` | `string` |
|
|
632
1024
|
|
|
633
1025
|
> Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
|
|
634
1026
|
|
|
635
1027
|
---
|
|
636
1028
|
|
|
637
|
-
## Counter Style (`@
|
|
1029
|
+
## Counter Style (`@counter-style`)
|
|
638
1030
|
|
|
639
1031
|
Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
|
|
640
1032
|
|
|
641
1033
|
```ts
|
|
642
1034
|
const EmojiList = tasty({
|
|
643
|
-
|
|
1035
|
+
as: 'ol',
|
|
644
1036
|
styles: {
|
|
645
|
-
'@
|
|
1037
|
+
'@counter-style': {
|
|
646
1038
|
thumbs: {
|
|
647
1039
|
system: 'cyclic',
|
|
648
1040
|
symbols: '"👍"',
|
|
@@ -656,23 +1048,88 @@ const EmojiList = tasty({
|
|
|
656
1048
|
|
|
657
1049
|
### Supported descriptors
|
|
658
1050
|
|
|
659
|
-
| Descriptor
|
|
660
|
-
|
|
661
|
-
| `system` (required) | `system`
|
|
662
|
-
| `symbols`
|
|
663
|
-
| `additiveSymbols`
|
|
664
|
-
| `prefix`
|
|
665
|
-
| `suffix`
|
|
666
|
-
| `negative`
|
|
667
|
-
| `range`
|
|
668
|
-
| `pad`
|
|
669
|
-
| `fallback`
|
|
670
|
-
| `speakAs`
|
|
1051
|
+
| Descriptor | CSS property | Type |
|
|
1052
|
+
| ------------------- | ------------------ | ---------------------------------------------------------------------------------------- |
|
|
1053
|
+
| `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
|
|
1054
|
+
| `symbols` | `symbols` | `string` |
|
|
1055
|
+
| `additiveSymbols` | `additive-symbols` | `string` |
|
|
1056
|
+
| `prefix` | `prefix` | `string` |
|
|
1057
|
+
| `suffix` | `suffix` | `string` |
|
|
1058
|
+
| `negative` | `negative` | `string` |
|
|
1059
|
+
| `range` | `range` | `string` |
|
|
1060
|
+
| `pad` | `pad` | `string` |
|
|
1061
|
+
| `fallback` | `fallback` | `string` |
|
|
1062
|
+
| `speakAs` | `speak-as` | `string` |
|
|
671
1063
|
|
|
672
1064
|
> Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
|
|
673
1065
|
|
|
674
1066
|
---
|
|
675
1067
|
|
|
1068
|
+
## Functions (`@function`)
|
|
1069
|
+
|
|
1070
|
+
Define reusable, parameterized CSS [custom functions](https://developer.mozilla.org/en-US/docs/Web/CSS/@function) via the CSS `@function` at-rule. A custom function takes parameters and returns a single value — like a dynamic custom property.
|
|
1071
|
+
|
|
1072
|
+
The token convention follows Tasty's `$` vs `$$` distinction:
|
|
1073
|
+
|
|
1074
|
+
- **`$$name`** — the literal callable name (`--name`). Used for the **definition key** and for **invocation** `$$name(...)`, mirroring the existing `$$gradient-angle` → `--gradient-angle` sugar. The definition key matches the call site.
|
|
1075
|
+
- **`$name`** — a custom-property declaration/reference (`var(--name)`). Used for **parameters** and **local variables**, exactly like declaring custom props in a styles object.
|
|
1076
|
+
- **Local variables** are declared directly as `$name` keys on the descriptor — the body reads like a mini styles object.
|
|
1077
|
+
- `result`, local-variable values, and parameter `default` values flow through the full Tasty DSL, so units (`2x`), color tokens (`#theme`), auto-calc (`(-1 * $value)` → `calc(-1 * var(--value))`), and fallbacks (`($shadow-color, black)` → `var(--shadow-color, black)`) all work.
|
|
1078
|
+
|
|
1079
|
+
```ts
|
|
1080
|
+
const Box = tasty({
|
|
1081
|
+
styles: {
|
|
1082
|
+
'@function': {
|
|
1083
|
+
// simplest: one bare param + result (auto-calc, no explicit calc())
|
|
1084
|
+
$$negative: { args: ['$value'], result: '(-1 * $value)' },
|
|
1085
|
+
|
|
1086
|
+
// typed param + default + return type + local variable
|
|
1087
|
+
$$shadow: {
|
|
1088
|
+
args: { '$shadow-color': { syntax: '<color>', default: 'inherit' } },
|
|
1089
|
+
returns: '<color>',
|
|
1090
|
+
$offset: '2px', // local variable
|
|
1091
|
+
result: '$offset $offset ($shadow-color, black)',
|
|
1092
|
+
},
|
|
1093
|
+
},
|
|
1094
|
+
margin: '$$negative(10px) top', // → margin: --negative(10px) 0 0 0
|
|
1095
|
+
shadow: '$$shadow(#accent)', // → box-shadow: --shadow(var(--accent-color))
|
|
1096
|
+
},
|
|
1097
|
+
});
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
Generated CSS:
|
|
1101
|
+
|
|
1102
|
+
```css
|
|
1103
|
+
@function --negative(--value) {
|
|
1104
|
+
result: calc(-1 * var(--value));
|
|
1105
|
+
}
|
|
1106
|
+
@function --shadow(--shadow-color <color>: inherit) returns <color> {
|
|
1107
|
+
--offset: 2px;
|
|
1108
|
+
result: var(--offset) var(--offset) var(--shadow-color, black);
|
|
1109
|
+
}
|
|
1110
|
+
.t0 {
|
|
1111
|
+
margin: --negative(10px) 0 0 0;
|
|
1112
|
+
box-shadow: --shadow(var(--accent-color));
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
### Descriptor shape
|
|
1117
|
+
|
|
1118
|
+
| Field | Type | Notes |
|
|
1119
|
+
| ------------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
1120
|
+
| `result` (required) | `string` | The `result:` value, parsed through the Tasty DSL. |
|
|
1121
|
+
| `args` | `string[]` \| `Record<string, FunctionParameter>` | Ordered parameters. Array form lists bare names; object form maps names to type/default. |
|
|
1122
|
+
| `returns` | `string` | Optional return type, e.g. `'<color>'`. |
|
|
1123
|
+
| `$name` keys | `string \| number` | Any `$name` key declares a local variable `--name` (value parsed). |
|
|
1124
|
+
|
|
1125
|
+
A `FunctionParameter` is one of: `true` (bare param), a string CSS type shorthand (`'<length>'`), or `{ syntax?: string; default?: string | number }`.
|
|
1126
|
+
|
|
1127
|
+
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).
|
|
1128
|
+
|
|
1129
|
+
> `@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.
|
|
1130
|
+
|
|
1131
|
+
---
|
|
1132
|
+
|
|
676
1133
|
## Style Properties
|
|
677
1134
|
|
|
678
1135
|
For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
|
|
@@ -685,4 +1142,4 @@ For a complete reference of all enhanced style properties — syntax, values, mo
|
|
|
685
1142
|
- **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
|
|
686
1143
|
- **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
|
|
687
1144
|
- **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
|
|
688
|
-
- **[
|
|
1145
|
+
- **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
|