@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/react-api.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# React API
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use `tasty()` to turn state-aware style definitions into normal React components, extend existing Tasty components, and expose typed styling APIs to consumers.
|
|
4
|
+
|
|
5
|
+
Every Tasty style function — `tasty()` components, `computeStyles()`, `useStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, `useCounterStyle()`, and `useFunction()` — works in React Server Components with no `'use client'` directive. All of them except `useStyles()` are hook-free. `useStyles()` reads the `TastyRegistry` collector from React context on the client, so it is a real hook there; outside React, call `computeStyles()` instead. For state maps, tokens, units, and extension semantics, see [Style DSL](dsl.md). For global configuration, see [Configuration](configuration.md). For the broader docs map, see the [Docs Hub](README.md).
|
|
4
6
|
|
|
5
7
|
> **Note:** This file was previously named `runtime.md`. All functionality documented here works in both server and client contexts — "runtime" referred to style computation during React rendering, not to client-side JavaScript.
|
|
6
8
|
|
|
@@ -42,6 +44,58 @@ const PrimaryButton = tasty(Button, {
|
|
|
42
44
|
|
|
43
45
|
Style maps merge intelligently — see [Style DSL — Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps) for extend mode, replace mode, `@inherit`, `null`, and `false` tombstones.
|
|
44
46
|
|
|
47
|
+
The extension form takes the same component options as `tasty({ … })`:
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
const ActionCard = tasty(Card, {
|
|
51
|
+
styles: { fill: { '': '#surface', isRaised: '#surface-raised' } },
|
|
52
|
+
styleProps: ['gap'] as const, // gap="2x" becomes a style
|
|
53
|
+
modProps: ['isRaised'] as const, // isRaised becomes a mod (data-is-raised)
|
|
54
|
+
tokenProps: ['accentColor'] as const, // accentColor sets the #accent token
|
|
55
|
+
variants: {
|
|
56
|
+
plain: { border: 0 },
|
|
57
|
+
framed: { border: '2bw #accent' },
|
|
58
|
+
},
|
|
59
|
+
variant: 'framed', // applied when no variant prop is passed
|
|
60
|
+
elements: { Footer: 'footer' },
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
<ActionCard gap="2x" isRaised accentColor="#purple">
|
|
64
|
+
<ActionCard.Title>Kept from Card</ActionCard.Title>
|
|
65
|
+
<ActionCard.Footer>Added here</ActionCard.Footer>
|
|
66
|
+
</ActionCard>;
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The extension turns its own `styleProps`, `modProps`, and `tokenProps` into the `styles`, `mods`, and `tokens` it passes to the base, which renders them as usual: mods as `data-*` attributes, tokens as inline custom properties. Its `variants` merge over its `styles`, and the `variant` prop is still forwarded, so it selects the base's own variants too and accepts either set's names. Both sets share that one prop, so a name only one of them defines leaves the other at its fallback: if `Card` had an `accent` variant, `variant="accent"` would apply it together with `framed`, and `variant="plain"` would leave `Card` on its default. For two independent choices, give one of them its own prop, such as a `modProps` value list. `elements` adds sub-components, and the base's are kept: `ActionCard.Title` is `Card.Title`. The returned component is typed with all of these props and sub-components.
|
|
70
|
+
|
|
71
|
+
`tasty(Component, ...)` always wraps `Component` and forwards every prop to it, so `Component` must be Tasty-aware (i.e. it accepts `styles`, `mods`, `qa`, etc. and renders them through its own Tasty pipeline). To apply styles to a third-party component or a string DOM tag via `className`, use the options-only form with `as`:
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
import NextLink from 'next/link';
|
|
75
|
+
|
|
76
|
+
const Link = tasty({
|
|
77
|
+
as: NextLink,
|
|
78
|
+
styles: {
|
|
79
|
+
color: { '': '#accent-text', ':hover': '#text' },
|
|
80
|
+
textDecoration: 'underline',
|
|
81
|
+
},
|
|
82
|
+
styleProps: ['padding'],
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const Span = tasty({
|
|
86
|
+
as: 'span',
|
|
87
|
+
styles: { preset: 'strong' },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
<Link href="/blog" padding="1x">
|
|
91
|
+
Blog
|
|
92
|
+
</Link>;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The wrapped component only needs to forward `className` (and ideally `style`/`ref`). Tasty's own props (`styles`, `mods`, `tokens`, `qa`, `qaVal`, `theme`, `element`, the `is*` props) and the props you declared with `styleProps`, `modProps`, or `tokenProps` are consumed by Tasty; mods, `qa`, `qaVal`, `theme`, and `element` reach the DOM only as `data-*` attributes.
|
|
96
|
+
|
|
97
|
+
Props forwarded to the `as` component keep their declared types and requiredness. For example, a component with `position: 'top-right' | 'bottom-left'` accepts those values through `tasty({ as: Component })`; CSS positioning can still be set through `styles.position`. A prop explicitly listed in `styleProps` is consumed as a style value instead. The always-available base style props below are also consumed by Tasty, so keep component-specific prop names separate from those reserved names.
|
|
98
|
+
|
|
45
99
|
---
|
|
46
100
|
|
|
47
101
|
## Style Props
|
|
@@ -60,7 +114,7 @@ const FlexibleBox = tasty({
|
|
|
60
114
|
|
|
61
115
|
<FlexibleBox gap="2x" align="center" fill="#surface">
|
|
62
116
|
Content
|
|
63
|
-
</FlexibleBox
|
|
117
|
+
</FlexibleBox>;
|
|
64
118
|
```
|
|
65
119
|
|
|
66
120
|
Style props accept state maps, so responsive values work through the same API:
|
|
@@ -74,6 +128,26 @@ Style props accept state maps, so responsive values work through the same API:
|
|
|
74
128
|
|
|
75
129
|
For predefined style prop lists (`FLOW_STYLES`, `POSITION_STYLES`, `DIMENSION_STYLES`, etc.) and guidance on which props to expose per component category, see [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api).
|
|
76
130
|
|
|
131
|
+
### Always-available style props
|
|
132
|
+
|
|
133
|
+
A small set of style properties — `display`, `font`, `preset`, `hide`, `whiteSpace`, `opacity`, and `transition` — are always harvested as style props on every `tasty()` component, even when `styleProps` is omitted. This means you can pass `<Card display="grid" />` or `<Text preset="h1" />` without declaring them. When you do declare `styleProps`, these base props are unioned with your list (not replaced).
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## `Element`
|
|
138
|
+
|
|
139
|
+
`Element` is the unstyled base component exported from the main entry — equivalent to `tasty({})` (a `div` with no default styles). It accepts the props every Tasty component has (`as`, `styles`, `mods`, `tokens`, `qa`, `theme`, the `is*` props) plus the [always-available style props](#always-available-style-props), and is useful as a generic box or as a building block for layout primitives. Other style names, such as `padding`, are not props on it: create a component with `styleProps` for those, or pass them through `styles`.
|
|
140
|
+
|
|
141
|
+
```jsx
|
|
142
|
+
import { Element } from '@tenphi/tasty';
|
|
143
|
+
|
|
144
|
+
<Element as="section" display="grid" preset="t2" styles={{ padding: '4x' }}>
|
|
145
|
+
Content
|
|
146
|
+
</Element>;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> Note: `Element` shadows the global DOM `Element` type when imported from `@tenphi/tasty`. In files that need the DOM type, alias the import: `import { Element as TastyElement } from '@tenphi/tasty'`.
|
|
150
|
+
|
|
77
151
|
---
|
|
78
152
|
|
|
79
153
|
## Mod Props
|
|
@@ -94,6 +168,7 @@ List modifier key names. Types default to `ModValue` (`boolean | string | number
|
|
|
94
168
|
|
|
95
169
|
```jsx
|
|
96
170
|
const Button = tasty({
|
|
171
|
+
as: 'button',
|
|
97
172
|
modProps: ['isLoading', 'isSelected'] as const,
|
|
98
173
|
styles: {
|
|
99
174
|
fill: { '': '#surface', isLoading: '#surface.5' },
|
|
@@ -111,10 +186,11 @@ Map modifier names to type descriptors for precise TypeScript types:
|
|
|
111
186
|
|
|
112
187
|
```tsx
|
|
113
188
|
const Button = tasty({
|
|
189
|
+
as: 'button',
|
|
114
190
|
modProps: {
|
|
115
|
-
isLoading: Boolean,
|
|
116
|
-
isSelected: Boolean,
|
|
117
|
-
size: ['small', 'medium', 'large'] as const,
|
|
191
|
+
isLoading: Boolean, // isLoading?: boolean
|
|
192
|
+
isSelected: Boolean, // isSelected?: boolean
|
|
193
|
+
size: ['small', 'medium', 'large'] as const, // size?: 'small' | 'medium' | 'large'
|
|
118
194
|
},
|
|
119
195
|
styles: {
|
|
120
196
|
padding: { '': '2x 4x', 'size=small': '1x 2x', 'size=large': '3x 6x' },
|
|
@@ -122,18 +198,20 @@ const Button = tasty({
|
|
|
122
198
|
},
|
|
123
199
|
});
|
|
124
200
|
|
|
125
|
-
<Button isLoading size="large">
|
|
201
|
+
<Button isLoading size="large">
|
|
202
|
+
Submit
|
|
203
|
+
</Button>;
|
|
126
204
|
// Renders: <button data-is-loading="" data-size="large">Submit</button>
|
|
127
205
|
```
|
|
128
206
|
|
|
129
207
|
Available type descriptors:
|
|
130
208
|
|
|
131
|
-
| Descriptor
|
|
132
|
-
|
|
133
|
-
| `Boolean`
|
|
134
|
-
| `String`
|
|
135
|
-
| `Number`
|
|
136
|
-
| `['a', 'b'] as const` | `'a' \| 'b'`
|
|
209
|
+
| Descriptor | TypeScript type | Example |
|
|
210
|
+
| --------------------- | --------------- | ----------------------------------- |
|
|
211
|
+
| `Boolean` | `boolean` | `isLoading: Boolean` |
|
|
212
|
+
| `String` | `string` | `label: String` |
|
|
213
|
+
| `Number` | `number` | `count: Number` |
|
|
214
|
+
| `['a', 'b'] as const` | `'a' \| 'b'` | `size: ['sm', 'md', 'lg'] as const` |
|
|
137
215
|
|
|
138
216
|
### Merge with `mods`
|
|
139
217
|
|
|
@@ -146,11 +224,11 @@ Mod props and the `mods` object can be used together. Mod props take precedence:
|
|
|
146
224
|
|
|
147
225
|
### When to use `modProps` vs `mods`
|
|
148
226
|
|
|
149
|
-
| Use case
|
|
150
|
-
|
|
227
|
+
| Use case | Recommendation |
|
|
228
|
+
| -------------------------------------------- | -------------------------------------------------------- |
|
|
151
229
|
| Component has a fixed set of known modifiers | `modProps` — cleaner API, better TypeScript autocomplete |
|
|
152
|
-
| Component needs arbitrary/dynamic modifiers
|
|
153
|
-
| Both fixed and dynamic
|
|
230
|
+
| Component needs arbitrary/dynamic modifiers | `mods` — open-ended `Record<string, ModValue>` |
|
|
231
|
+
| Both fixed and dynamic | Combine: `modProps` for known keys, `mods` for ad-hoc |
|
|
154
232
|
|
|
155
233
|
For architecture guidance on when to use modifiers vs `styleProps`, see [Methodology — modProps and mods](methodology.md#modprops-and-mods).
|
|
156
234
|
|
|
@@ -180,7 +258,7 @@ const ProgressBar = tasty({
|
|
|
180
258
|
|
|
181
259
|
<ProgressBar progress="75%" accentColor="#purple" />
|
|
182
260
|
// 'progress' → $progress → --progress
|
|
183
|
-
// 'accentColor' → #accent → --accent-color
|
|
261
|
+
// 'accentColor' → #accent → --accent-color
|
|
184
262
|
```
|
|
185
263
|
|
|
186
264
|
### Object form
|
|
@@ -196,7 +274,7 @@ const Card = tasty({
|
|
|
196
274
|
styles: { padding: '$card-size', fill: '#card-accent' },
|
|
197
275
|
});
|
|
198
276
|
|
|
199
|
-
<Card size="4x" color="#purple"
|
|
277
|
+
<Card size="4x" color="#purple" />;
|
|
200
278
|
```
|
|
201
279
|
|
|
202
280
|
### Merge with `tokens`
|
|
@@ -215,11 +293,11 @@ const Bar = tasty({
|
|
|
215
293
|
|
|
216
294
|
### When to use `tokenProps` vs `tokens`
|
|
217
295
|
|
|
218
|
-
| Use case
|
|
219
|
-
|
|
220
|
-
| Component has a fixed set of known token keys
|
|
221
|
-
| Component needs arbitrary/dynamic token values | `tokens` — open-ended `Record<string, TokenValue>`
|
|
222
|
-
| Both fixed and dynamic
|
|
296
|
+
| Use case | Recommendation |
|
|
297
|
+
| ---------------------------------------------- | ---------------------------------------------------------- |
|
|
298
|
+
| Component has a fixed set of known token keys | `tokenProps` — cleaner API, better TypeScript autocomplete |
|
|
299
|
+
| Component needs arbitrary/dynamic token values | `tokens` — open-ended `Record<string, TokenValue>` |
|
|
300
|
+
| Both fixed and dynamic | Combine: `tokenProps` for known keys, `tokens` for ad-hoc |
|
|
223
301
|
|
|
224
302
|
For architecture guidance, see [Methodology — tokenProps](methodology.md#tokenprops).
|
|
225
303
|
|
|
@@ -238,11 +316,29 @@ const Button = tasty({
|
|
|
238
316
|
variants: {
|
|
239
317
|
default: { fill: '#blue', color: '#white' },
|
|
240
318
|
danger: { fill: '#red', color: '#white' },
|
|
241
|
-
outline: { fill: '
|
|
319
|
+
outline: { fill: '#clear', color: '#blue', border: '1bw solid #blue' },
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
<Button variant="danger">Delete</Button>;
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
With `variant` omitted, or set to a key `variants` does not define, the `default` variant applies; without a `default` key only the base `styles` apply. `variant` is typed from the variant keys.
|
|
327
|
+
|
|
328
|
+
To fall back to another variant instead, name it in the `variant` option:
|
|
329
|
+
|
|
330
|
+
```jsx
|
|
331
|
+
const Button = tasty({
|
|
332
|
+
styles: { padding: '2x 4x' },
|
|
333
|
+
variants: {
|
|
334
|
+
primary: { fill: '#blue', color: '#white' },
|
|
335
|
+
danger: { fill: '#red', color: '#white' },
|
|
242
336
|
},
|
|
337
|
+
variant: 'primary',
|
|
243
338
|
});
|
|
244
339
|
|
|
245
|
-
<Button
|
|
340
|
+
<Button>Save</Button>; // primary
|
|
341
|
+
<Button variant="danger">Delete</Button>;
|
|
246
342
|
```
|
|
247
343
|
|
|
248
344
|
### Extending Variants with Base State Maps
|
|
@@ -298,7 +394,7 @@ const Card = tasty({
|
|
|
298
394
|
<Card>
|
|
299
395
|
<Card.Title>Card Title</Card.Title>
|
|
300
396
|
<Card.Content>Card content</Card.Content>
|
|
301
|
-
</Card
|
|
397
|
+
</Card>;
|
|
302
398
|
```
|
|
303
399
|
|
|
304
400
|
Each entry in `elements` can be a tag name string or a config object:
|
|
@@ -324,7 +420,7 @@ const Card = tasty({
|
|
|
324
420
|
|
|
325
421
|
<Card>
|
|
326
422
|
<div data-element="Title">Card Title</div>
|
|
327
|
-
</Card
|
|
423
|
+
</Card>;
|
|
328
424
|
```
|
|
329
425
|
|
|
330
426
|
### Selector Affix (`$`)
|
|
@@ -349,19 +445,19 @@ const { className } = computeStyles({
|
|
|
349
445
|
});
|
|
350
446
|
```
|
|
351
447
|
|
|
352
|
-
On the client, CSS is injected synchronously into the DOM (idempotent via the injector cache). On the server, CSS
|
|
448
|
+
On the client, CSS is injected synchronously into the DOM (idempotent via the injector cache). On the server with an SSR collector (from `runWithCollector()` or `TastyRegistry`), the CSS goes to the collector. With neither a collector nor a `document` — a React Server Component — nothing is injected: the CSS comes back as `css`, and you render it in a `style` tag yourself, as `tasty()` components do. This is the same function that `tasty()` components use internally.
|
|
353
449
|
|
|
354
450
|
---
|
|
355
451
|
|
|
356
452
|
## Style Functions
|
|
357
453
|
|
|
358
|
-
All style functions below
|
|
454
|
+
All style functions below work in client components, SSR with a `ServerStyleCollector`, and React Server Components. All except `useStyles()` are plain functions, not React hooks; they keep the `use` prefix for backward compatibility.
|
|
359
455
|
|
|
360
|
-
In server-only contexts
|
|
456
|
+
In server-only contexts, components that use only Tasty style functions ship no Tasty styling runtime. Astro without `client:*` directives produces no client JavaScript; server-only Next.js RSC follows the same Tasty architecture, while final output depends on the application deployment. Tasty never forces the `'use client'` boundary — that decision belongs to your component when it needs React interactivity (state, effects, event handlers).
|
|
361
457
|
|
|
362
458
|
### useStyles
|
|
363
459
|
|
|
364
|
-
Generate a className from a style object.
|
|
460
|
+
Generate a className from a style object. A thin wrapper around `computeStyles()` that also picks up the `TastyRegistry` collector through React context. That makes it a hook on the client: call it inside a component, and use `computeStyles()` outside React. It also works in a Server Component, where it skips the context lookup; like the other style functions there, it cannot emit CSS itself, so the next `tasty()` element in the tree emits it.
|
|
365
461
|
|
|
366
462
|
```tsx
|
|
367
463
|
import { useStyles } from '@tenphi/tasty';
|
|
@@ -395,6 +491,24 @@ function ThemeStyles() {
|
|
|
395
491
|
}
|
|
396
492
|
```
|
|
397
493
|
|
|
494
|
+
The selector can be a list (`'.uni-checkbox, uni-checkbox'`) — every item gets
|
|
495
|
+
the states and sub-elements, with no `:is()` wrapping needed. Root states
|
|
496
|
+
(`@root(...)`) on a selector that is the root itself (`:root`, `html`) apply to
|
|
497
|
+
that element. A selector that ends in a pseudo-element takes its states on the
|
|
498
|
+
originating element: `'.card::before'` with a `:hover` state gives
|
|
499
|
+
`.card:where(:hover)::before`. Local `@keyframes` are injected with the rules,
|
|
500
|
+
under the same resolved names `tasty()` components use, and `@starting` states
|
|
501
|
+
emit `@starting-style`.
|
|
502
|
+
|
|
503
|
+
A slot — the `id`, or the selector when no `id` is given — holds exactly one
|
|
504
|
+
injection **per `root`**. So:
|
|
505
|
+
|
|
506
|
+
- Changing the styles replaces the previous CSS rather than adding to it.
|
|
507
|
+
- Passing styles that produce no CSS (for example `{}`) clears the slot.
|
|
508
|
+
- The same selector used in two shadow roots keeps a separate injection in each.
|
|
509
|
+
- Two independent call sites that share a selector share a slot, and the last
|
|
510
|
+
render wins. Give them distinct `id`s if they should coexist.
|
|
511
|
+
|
|
398
512
|
### useRawCSS
|
|
399
513
|
|
|
400
514
|
Inject raw CSS strings. Accepts an optional `id` in the options for update tracking — when the CSS changes for the same id, the previous injection is replaced:
|
|
@@ -411,6 +525,11 @@ function GlobalReset() {
|
|
|
411
525
|
}
|
|
412
526
|
```
|
|
413
527
|
|
|
528
|
+
An `id` slot holds one injection per `root`. Without an `id` the CSS is deduped
|
|
529
|
+
by content and permanent — there is nothing to replace it with later.
|
|
530
|
+
|
|
531
|
+
It also accepts a factory and deps — `useRawCSS(() => css, [deps], { id })` — and skips the factory while the deps for that `id` are unchanged.
|
|
532
|
+
|
|
414
533
|
### useKeyframes
|
|
415
534
|
|
|
416
535
|
Inject `@keyframes` rules and return the generated animation name:
|
|
@@ -424,14 +543,14 @@ function Spinner() {
|
|
|
424
543
|
from: { transform: 'rotate(0deg)' },
|
|
425
544
|
to: { transform: 'rotate(360deg)' },
|
|
426
545
|
},
|
|
427
|
-
{ name: 'spin' }
|
|
546
|
+
{ name: 'spin' },
|
|
428
547
|
);
|
|
429
548
|
|
|
430
549
|
return <div style={{ animation: `${spin} 1s linear infinite` }} />;
|
|
431
550
|
}
|
|
432
551
|
```
|
|
433
552
|
|
|
434
|
-
`useKeyframes()` also supports a factory function.
|
|
553
|
+
`useKeyframes()` also supports a factory function. Without a `name` the factory runs on every invocation and deduplication is handled internally by content hash; with a `name`, matching deps skip the factory entirely:
|
|
435
554
|
|
|
436
555
|
```tsx
|
|
437
556
|
function Pulse({ scale }: { scale: number }) {
|
|
@@ -440,13 +559,24 @@ function Pulse({ scale }: { scale: number }) {
|
|
|
440
559
|
'0%': { transform: 'scale(1)' },
|
|
441
560
|
'100%': { transform: `scale(${scale})` },
|
|
442
561
|
}),
|
|
443
|
-
[scale]
|
|
562
|
+
[scale],
|
|
563
|
+
{ name: 'pulse' },
|
|
444
564
|
);
|
|
445
565
|
|
|
446
|
-
return
|
|
566
|
+
return (
|
|
567
|
+
<div
|
|
568
|
+
style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }}
|
|
569
|
+
/>
|
|
570
|
+
);
|
|
447
571
|
}
|
|
448
572
|
```
|
|
449
573
|
|
|
574
|
+
Passing `name` claims a slot owned by that one call site, per `root` — much like
|
|
575
|
+
`id` in `useGlobalStyles()` and `useRawCSS()`. When the steps change the previous
|
|
576
|
+
`@keyframes` rule is disposed and the name is reused, so the rules don't
|
|
577
|
+
accumulate and the returned name stays stable. Anonymous keyframes are permanent
|
|
578
|
+
and shared by content.
|
|
579
|
+
|
|
450
580
|
### useProperty
|
|
451
581
|
|
|
452
582
|
Register a CSS `@property` rule so a custom property can animate smoothly:
|
|
@@ -493,15 +623,27 @@ For multiple weights/styles, pass an array:
|
|
|
493
623
|
|
|
494
624
|
```tsx
|
|
495
625
|
useFontFace('Brand Sans', [
|
|
496
|
-
{
|
|
497
|
-
|
|
626
|
+
{
|
|
627
|
+
src: 'url("/fonts/brand-regular.woff2") format("woff2")',
|
|
628
|
+
fontWeight: 400,
|
|
629
|
+
fontDisplay: 'swap',
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
src: 'url("/fonts/brand-bold.woff2") format("woff2")',
|
|
633
|
+
fontWeight: 700,
|
|
634
|
+
fontDisplay: 'swap',
|
|
635
|
+
},
|
|
498
636
|
]);
|
|
499
637
|
```
|
|
500
638
|
|
|
501
639
|
Signature:
|
|
502
640
|
|
|
503
641
|
```ts
|
|
504
|
-
function useFontFace(
|
|
642
|
+
function useFontFace(
|
|
643
|
+
family: string,
|
|
644
|
+
input: FontFaceInput,
|
|
645
|
+
options?: { root?: Document | ShadowRoot },
|
|
646
|
+
): void;
|
|
505
647
|
```
|
|
506
648
|
|
|
507
649
|
### useCounterStyle
|
|
@@ -512,11 +654,14 @@ Inject a `@counter-style` rule and get back the counter style name. Permanent
|
|
|
512
654
|
import { useCounterStyle } from '@tenphi/tasty';
|
|
513
655
|
|
|
514
656
|
function EmojiList() {
|
|
515
|
-
const styleName = useCounterStyle(
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
657
|
+
const styleName = useCounterStyle(
|
|
658
|
+
{
|
|
659
|
+
system: 'cyclic',
|
|
660
|
+
symbols: '"👍"',
|
|
661
|
+
suffix: '" "',
|
|
662
|
+
},
|
|
663
|
+
{ name: 'thumbs' },
|
|
664
|
+
);
|
|
520
665
|
|
|
521
666
|
return (
|
|
522
667
|
<ol style={{ listStyleType: styleName }}>
|
|
@@ -536,13 +681,54 @@ function useCounterStyle(
|
|
|
536
681
|
): string;
|
|
537
682
|
```
|
|
538
683
|
|
|
684
|
+
### useFunction
|
|
685
|
+
|
|
686
|
+
Register a CSS `@function` (custom function). Permanent — no cleanup on unmount. Deduplicates by function name. The function name accepts `$$name` (matching the call site `$$name(...)`), `$name`, or `--name`.
|
|
687
|
+
|
|
688
|
+
```tsx
|
|
689
|
+
import { tasty, useFunction } from '@tenphi/tasty';
|
|
690
|
+
|
|
691
|
+
const Box = tasty({ styles: { margin: '$$negative(10px) top' } });
|
|
692
|
+
|
|
693
|
+
function Layout() {
|
|
694
|
+
useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
|
|
695
|
+
return <Box />;
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
Call the function through the Tasty DSL rather than a raw `style` prop. An inline `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never expanded — and under `configure({ polyfills: { functions: true } })` it silently does nothing, because the polyfill rewrites calls at parse time.
|
|
700
|
+
|
|
701
|
+
Inside a `tasty()` component you call functions with the same `$$name(...)` sugar:
|
|
702
|
+
|
|
703
|
+
```tsx
|
|
704
|
+
const Box = tasty({
|
|
705
|
+
styles: {
|
|
706
|
+
'@function': { $$negative: { args: ['$value'], result: '(-1 * $value)' } },
|
|
707
|
+
margin: '$$negative(10px) top',
|
|
708
|
+
},
|
|
709
|
+
});
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
Signature:
|
|
713
|
+
|
|
714
|
+
```ts
|
|
715
|
+
function useFunction(
|
|
716
|
+
name: string,
|
|
717
|
+
definition: FunctionDefinition,
|
|
718
|
+
options?: { root?: Document | ShadowRoot },
|
|
719
|
+
): void;
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
See the [Functions section of the DSL reference](dsl.md#functions-function) for the full descriptor shape, token conventions, and value-sugar support. `@function` is an experimental CSS feature — unsupported browsers safely ignore the native rule, or enable the [`polyfills.functions`](configuration.md#polyfills) inline polyfill for full cross-browser support.
|
|
723
|
+
|
|
539
724
|
### Troubleshooting
|
|
540
725
|
|
|
541
726
|
- Styles are not updating: make sure `configure()` runs before first render, and verify the generated class name or global rule with [Debug Utilities](debug.md).
|
|
542
727
|
- SSR output looks wrong: check the [SSR guide](ssr.md) for collector setup. All style functions discover the SSR collector via `AsyncLocalStorage` or the global getter registered by `TastyRegistry`.
|
|
728
|
+
- "Server rendering without a style collector" in development: the server render has no request scope, so each `tasty()` element inlines its own CSS and configured globals are not emitted. Add `tastyIntegration()` (Astro), `TastyRegistry` (Next.js), or `runWithCollector()` — see the [SSR guide](ssr.md).
|
|
543
729
|
- Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
|
|
544
730
|
- For dynamic styles that change over the component lifecycle, use the `id` option in `useGlobalStyles()` and `useRawCSS()` to enable update tracking.
|
|
545
|
-
- RSC inline mode: CSS accumulated by standalone style functions (`useGlobalStyles`, `useRawCSS`, etc.) is flushed into inline `<style>` tags by the next `tasty()` component in the render tree. If your page uses only standalone style functions without any `tasty()` component, the CSS will not be emitted. Ensure at least one `tasty()` component is present in each RSC render tree.
|
|
731
|
+
- RSC inline mode: CSS accumulated by standalone style functions (`useStyles`, `useGlobalStyles`, `useRawCSS`, etc.) is flushed into inline `<style>` tags by the next `tasty()` component in the render tree. If your page uses only standalone style functions without any `tasty()` component, the CSS will not be emitted. Ensure at least one `tasty()` component is present in each RSC render tree.
|
|
546
732
|
|
|
547
733
|
---
|
|
548
734
|
|
|
@@ -551,7 +737,8 @@ function useCounterStyle(
|
|
|
551
737
|
- **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
|
|
552
738
|
- **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
|
|
553
739
|
- **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
|
|
740
|
+
- **[Configuration → TypeScript](configuration.md#typescript)** — How props are typed and how to register your names
|
|
554
741
|
- **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
|
|
555
|
-
- **[
|
|
742
|
+
- **[Build-Time Extraction (`tastyStatic`)](tasty-static.md)** — Static styling with the Babel plugin
|
|
556
743
|
- **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
|
|
557
744
|
- **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime
|