stillwind 0.0.0 → 0.1.0-rc.0
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/AGENTS_TEMPLATE.md +5 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/TAILWINDCSS-MIT-LICENSE +21 -0
- package/css/builtin-metadata/sw-motion-properties.css +186 -0
- package/css/builtin-metadata/tw-legacy-metadata.css +36 -0
- package/css/builtin-metadata/tw-properties.css +944 -0
- package/css/builtin-metadata/tw-registry-metadata.css +52 -0
- package/css/builtin-metadata/tw-relationship-metadata.css +10 -0
- package/css/builtin-utilities/sw-motion-contexts.css +1043 -0
- package/css/builtin-utilities/tw-backgrounds.css +606 -0
- package/css/builtin-utilities/tw-borders.css +954 -0
- package/css/builtin-utilities/tw-effects.css +1209 -0
- package/css/builtin-utilities/tw-flex-grid.css +749 -0
- package/css/builtin-utilities/tw-interactivity.css +680 -0
- package/css/builtin-utilities/tw-layout.css +943 -0
- package/css/builtin-utilities/tw-masks.css +1268 -0
- package/css/builtin-utilities/tw-motion.css +142 -0
- package/css/builtin-utilities/tw-spacing-sizing.css +621 -0
- package/css/builtin-utilities/tw-svg.css +50 -0
- package/css/builtin-utilities/tw-transforms.css +652 -0
- package/css/builtin-utilities/tw-typography.css +720 -0
- package/css/builtin-variants/sw-conditional.css +5 -0
- package/css/builtin-variants/sw-document.css +13 -0
- package/css/builtin-variants/tw-conditional.css +187 -0
- package/css/builtin-variants/tw-dynamic-selector.css +49 -0
- package/css/builtin-variants/tw-relationship.css +41 -0
- package/css/builtin-variants/tw-state.css +159 -0
- package/css/builtin-variants/tw-structural.css +121 -0
- package/css/builtins.css +111 -0
- package/css/preflight.css +401 -0
- package/css/templates.css +40 -0
- package/css/theme.css +546 -0
- package/css/utilities.css +9 -0
- package/dist/class-object-D24FFYqO.js +6 -0
- package/dist/class-object-D24FFYqO.js.map +1 -0
- package/dist/class-object-D7ZGJOf_.d.ts +9 -0
- package/dist/class-string-CQHnc9GN.d.ts +9 -0
- package/dist/class-string-Db8-oI4q.js +6 -0
- package/dist/class-string-Db8-oI4q.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/css.d.ts +100 -0
- package/dist/css.js +143 -0
- package/dist/css.js.map +1 -0
- package/dist/cva-BwX07CFw.js +204 -0
- package/dist/cva-BwX07CFw.js.map +1 -0
- package/dist/cva-DSpDNBYi.d.ts +9 -0
- package/dist/development-DttPQc71.d.ts +27 -0
- package/dist/development-J-JCSIm0.js +111 -0
- package/dist/development-J-JCSIm0.js.map +1 -0
- package/dist/frameworks/alpine.d.ts +20 -0
- package/dist/frameworks/alpine.js +18 -0
- package/dist/frameworks/alpine.js.map +1 -0
- package/dist/frameworks/astro.d.ts +3 -0
- package/dist/frameworks/astro.js +1 -0
- package/dist/frameworks/lit.d.ts +21 -0
- package/dist/frameworks/lit.js +38 -0
- package/dist/frameworks/lit.js.map +1 -0
- package/dist/frameworks/preact.d.ts +3 -0
- package/dist/frameworks/preact.js +1 -0
- package/dist/frameworks/qwik.d.ts +3 -0
- package/dist/frameworks/qwik.js +1 -0
- package/dist/frameworks/react.d.ts +10 -0
- package/dist/frameworks/react.js +6 -0
- package/dist/frameworks/react.js.map +1 -0
- package/dist/frameworks/solid.d.ts +3 -0
- package/dist/frameworks/solid.js +1 -0
- package/dist/frameworks/svelte.d.ts +3 -0
- package/dist/frameworks/svelte.js +1 -0
- package/dist/frameworks/vanilla.d.ts +27 -0
- package/dist/frameworks/vanilla.js +3 -0
- package/dist/frameworks/vue.d.ts +3 -0
- package/dist/frameworks/vue.js +1 -0
- package/dist/index-RwVFpxhE.d.ts +815 -0
- package/dist/macro/index.d.ts +2 -0
- package/dist/macro/index.js +1 -0
- package/dist/module-css.d.ts +30 -0
- package/dist/module-css.js +23 -0
- package/dist/module-css.js.map +1 -0
- package/dist/runtime/class-name-object-development.d.ts +10 -0
- package/dist/runtime/class-name-object-development.js +18 -0
- package/dist/runtime/class-name-object-development.js.map +1 -0
- package/dist/runtime/class-name-object.d.ts +16 -0
- package/dist/runtime/class-name-object.js +31 -0
- package/dist/runtime/class-name-object.js.map +1 -0
- package/dist/runtime/class-object-development.d.ts +10 -0
- package/dist/runtime/class-object-development.js +18 -0
- package/dist/runtime/class-object-development.js.map +1 -0
- package/dist/runtime/class-object.d.ts +16 -0
- package/dist/runtime/class-object.js +31 -0
- package/dist/runtime/class-object.js.map +1 -0
- package/dist/runtime/class-string-development.d.ts +10 -0
- package/dist/runtime/class-string-development.js +18 -0
- package/dist/runtime/class-string-development.js.map +1 -0
- package/dist/runtime/class-string.d.ts +16 -0
- package/dist/runtime/class-string.js +31 -0
- package/dist/runtime/class-string.js.map +1 -0
- package/dist/shared-B9IQXU6P.d.ts +32 -0
- package/dist/style-BV4ctkni.js +78 -0
- package/dist/style-BV4ctkni.js.map +1 -0
- package/dist/style-fTQbsVWZ.js +41 -0
- package/dist/style-fTQbsVWZ.js.map +1 -0
- package/docs/agents.md +76 -0
- package/docs/at-rules/apply.md +93 -0
- package/docs/at-rules/custom-variant.md +127 -0
- package/docs/at-rules/index.md +75 -0
- package/docs/at-rules/plugin.md +71 -0
- package/docs/at-rules/registry-directives.md +181 -0
- package/docs/at-rules/slot.md +58 -0
- package/docs/at-rules/stillwind-css-template.md +126 -0
- package/docs/at-rules/stillwind-property.md +133 -0
- package/docs/at-rules/stillwind-registry.md +115 -0
- package/docs/at-rules/stillwind-require-properties.md +91 -0
- package/docs/at-rules/stillwind-slot.md +85 -0
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +75 -0
- package/docs/at-rules/stillwind-undef-utility.md +87 -0
- package/docs/at-rules/stillwind-undef-variant.md +55 -0
- package/docs/at-rules/theme.md +304 -0
- package/docs/at-rules/utility.md +286 -0
- package/docs/at-rules/variant.md +91 -0
- package/docs/concepts/css-ordering.md +245 -0
- package/docs/concepts/how-styles-compile.md +132 -0
- package/docs/configuration.md +298 -0
- package/docs/errors/SW01001.md +51 -0
- package/docs/errors/SW01002.md +52 -0
- package/docs/errors/SW01003.md +69 -0
- package/docs/errors/SW02001.md +23 -0
- package/docs/errors/SW02002.md +51 -0
- package/docs/errors/SW03001.md +71 -0
- package/docs/errors/SW03002.md +79 -0
- package/docs/errors/SW03003.md +36 -0
- package/docs/errors/SW10001.md +34 -0
- package/docs/errors/SW10002.md +36 -0
- package/docs/errors/SW10003.md +30 -0
- package/docs/errors/SW10004.md +39 -0
- package/docs/errors/SW10005.md +35 -0
- package/docs/errors/SW11001.md +37 -0
- package/docs/errors/SW11002.md +65 -0
- package/docs/errors/SW11003.md +20 -0
- package/docs/errors/SW12001.md +43 -0
- package/docs/errors/SW12002.md +42 -0
- package/docs/errors/SW13001.md +35 -0
- package/docs/errors/SW13002.md +33 -0
- package/docs/errors/SW13003.md +18 -0
- package/docs/errors/SW13004.md +45 -0
- package/docs/errors/SW14001.md +44 -0
- package/docs/errors/SW14002.md +47 -0
- package/docs/errors/SW14003.md +38 -0
- package/docs/errors/SW14004.md +48 -0
- package/docs/errors/SW14005.md +51 -0
- package/docs/errors/SW14006.md +19 -0
- package/docs/errors/SW14007.md +35 -0
- package/docs/errors/SW14008.md +41 -0
- package/docs/errors/SW15001.md +18 -0
- package/docs/errors/SW15002.md +19 -0
- package/docs/errors/SW15003.md +16 -0
- package/docs/errors/SW30001.md +21 -0
- package/docs/errors/SW30002.md +18 -0
- package/docs/errors/SW30003.md +17 -0
- package/docs/errors/SW30004.md +18 -0
- package/docs/errors/SW31001.md +20 -0
- package/docs/errors/SW31002.md +17 -0
- package/docs/errors/SW31003.md +18 -0
- package/docs/errors/SW31004.md +20 -0
- package/docs/errors/SW31005.md +18 -0
- package/docs/errors/SW31006.md +17 -0
- package/docs/errors/SW31007.md +18 -0
- package/docs/errors/SW31008.md +16 -0
- package/docs/errors/SW31009.md +18 -0
- package/docs/errors/SW31010.md +16 -0
- package/docs/errors/SW31011.md +17 -0
- package/docs/errors/SW32001.md +18 -0
- package/docs/errors/SW32002.md +45 -0
- package/docs/errors/SW32003.md +43 -0
- package/docs/errors/SW32004.md +17 -0
- package/docs/errors/SW32005.md +40 -0
- package/docs/errors/SW32006.md +18 -0
- package/docs/errors/SW32007.md +20 -0
- package/docs/errors/SW33001.md +17 -0
- package/docs/errors/SW33002.md +17 -0
- package/docs/errors/SW33003.md +17 -0
- package/docs/errors/SW33004.md +17 -0
- package/docs/errors/SW33005.md +20 -0
- package/docs/errors/SW34001.md +18 -0
- package/docs/errors/SW34002.md +17 -0
- package/docs/errors/SW34003.md +18 -0
- package/docs/errors/SW90001.md +17 -0
- package/docs/errors/SW90002.md +18 -0
- package/docs/errors/SW90003.md +17 -0
- package/docs/errors/SW90004.md +17 -0
- package/docs/errors/SW90005.md +16 -0
- package/docs/errors/SW90006.md +17 -0
- package/docs/errors/SW90007.md +17 -0
- package/docs/errors/SW90008.md +17 -0
- package/docs/errors/index.md +125 -0
- package/docs/guides/animations.md +73 -0
- package/docs/guides/design-systems.md +119 -0
- package/docs/guides/element-relationships.md +136 -0
- package/docs/guides/lint-adoption.md +128 -0
- package/docs/guides/migrating-from-css.md +126 -0
- package/docs/guides/migrating-from-tailwind.md +179 -0
- package/docs/guides/recommended-practices.md +338 -0
- package/docs/guides/responsive-styles.md +103 -0
- package/docs/guides/reusable-styles.md +110 -0
- package/docs/guides/style.md +181 -0
- package/docs/guides/tailwind-compatibility.md +126 -0
- package/docs/guides/view-transitions.md +84 -0
- package/docs/guides/web-components.md +216 -0
- package/docs/index.md +136 -0
- package/docs/integrations.md +190 -0
- package/docs/lints/ambiguous-style-base-order.md +50 -0
- package/docs/lints/bypassed-undefinition.md +50 -0
- package/docs/lints/clamped-value.md +44 -0
- package/docs/lints/conflicting-provider-properties.md +47 -0
- package/docs/lints/conflicting-utilities.md +55 -0
- package/docs/lints/document-scoped-selector.md +45 -0
- package/docs/lints/duplicate-definition.md +44 -0
- package/docs/lints/duplicate-utility.md +44 -0
- package/docs/lints/duplicate-view-transition-name.md +45 -0
- package/docs/lints/ignored-definition-condition.md +51 -0
- package/docs/lints/ignored-tailwind-feature.md +62 -0
- package/docs/lints/incompatible-property-value.md +60 -0
- package/docs/lints/incompatible-theme-value.md +46 -0
- package/docs/lints/index.md +140 -0
- package/docs/lints/ineffective-anchor-scope.md +46 -0
- package/docs/lints/interfering-imported-style-base.md +57 -0
- package/docs/lints/invalid-animation-option.md +47 -0
- package/docs/lints/invalid-css-directive.md +43 -0
- package/docs/lints/invalid-css-import.md +43 -0
- package/docs/lints/invalid-css-input.md +45 -0
- package/docs/lints/invalid-cva-config.md +46 -0
- package/docs/lints/invalid-cva-input.md +50 -0
- package/docs/lints/invalid-keyframes-definition.md +47 -0
- package/docs/lints/invalid-keyframes-use.md +47 -0
- package/docs/lints/invalid-keyframes-variant.md +48 -0
- package/docs/lints/invalid-lint-suppression.md +47 -0
- package/docs/lints/invalid-marker-use.md +53 -0
- package/docs/lints/invalid-media-query.md +52 -0
- package/docs/lints/invalid-ref-input.md +49 -0
- package/docs/lints/invalid-rule-group-input.md +58 -0
- package/docs/lints/invalid-runtime-condition.md +67 -0
- package/docs/lints/invalid-style-composition.md +52 -0
- package/docs/lints/invalid-style-input.md +47 -0
- package/docs/lints/invalid-theme-reference.md +52 -0
- package/docs/lints/invalid-utility.md +44 -0
- package/docs/lints/invalid-variant.md +45 -0
- package/docs/lints/invalid-view-transition-definition.md +46 -0
- package/docs/lints/invalid-view-transition-use.md +46 -0
- package/docs/lints/invalid-view-transition-variant.md +51 -0
- package/docs/lints/mismatched-framework-import.md +47 -0
- package/docs/lints/missing-document-target.md +44 -0
- package/docs/lints/missing-ref-attachment.md +44 -0
- package/docs/lints/missing-view-transition-name.md +46 -0
- package/docs/lints/mutating-macro-argument.md +48 -0
- package/docs/lints/no-arbitrary-breakpoints.md +50 -0
- package/docs/lints/no-arbitrary-colors.md +51 -0
- package/docs/lints/no-arbitrary-spacing.md +57 -0
- package/docs/lints/no-class-property.md +58 -0
- package/docs/lints/no-important.md +50 -0
- package/docs/lints/no-restricted-declarations.md +76 -0
- package/docs/lints/no-restricted-length-units.md +73 -0
- package/docs/lints/no-restricted-theme-tokens.md +73 -0
- package/docs/lints/no-restricted-utilities.md +73 -0
- package/docs/lints/prefer-canonical-utilities.md +69 -0
- package/docs/lints/prefer-direct-styling.md +47 -0
- package/docs/lints/prefer-explicit-nesting-selector.md +42 -0
- package/docs/lints/prefer-logical-properties.md +49 -0
- package/docs/lints/prefer-sorted-utilities.md +46 -0
- package/docs/lints/prefer-typed-relationships.md +48 -0
- package/docs/lints/prefer-typed-variables.md +43 -0
- package/docs/lints/prefer-variant-directive.md +59 -0
- package/docs/lints/redundant-variant.md +50 -0
- package/docs/lints/repeated-nesting-selector.md +59 -0
- package/docs/lints/runtime-condition-requires-css-if.md +59 -0
- package/docs/lints/split-view-transition-class.md +47 -0
- package/docs/lints/suspending-macro-argument.md +46 -0
- package/docs/lints/unknown-utility.md +47 -0
- package/docs/lints/unknown-variant.md +42 -0
- package/docs/lints/unsatisfiable-variants.md +42 -0
- package/docs/lints/unused-lint-suppression.md +57 -0
- package/docs/lints/unverified-style-base.md +64 -0
- package/docs/macros/anchor-scope.md +90 -0
- package/docs/macros/css.md +68 -0
- package/docs/macros/cva.md +153 -0
- package/docs/macros/index.md +30 -0
- package/docs/macros/keyframes.md +98 -0
- package/docs/macros/media.md +65 -0
- package/docs/macros/ref/as-anchor.md +70 -0
- package/docs/macros/ref/as-container.md +64 -0
- package/docs/macros/ref/at.md +68 -0
- package/docs/macros/ref/condition.md +86 -0
- package/docs/macros/ref/in.md +81 -0
- package/docs/macros/ref/index.md +115 -0
- package/docs/macros/ref/position-anchor.md +64 -0
- package/docs/macros/style.md +185 -0
- package/docs/macros/view-transition.md +159 -0
- package/docs/utilities.md +35 -0
- package/docs/why.md +144 -0
- package/index.css +7 -0
- package/package.json +135 -8
- package/skills/migrate-to-stillwind/SKILL.md +81 -0
- package/skills/setup-stillwind/SKILL.md +51 -0
- package/skills/stillwind/SKILL.md +54 -0
- package/index.js +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "unknown-utility"
|
|
3
|
+
description: "Reports a utility or theme value that your stylesheet does not define."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# unknown-utility
|
|
7
|
+
|
|
8
|
+
This rule reports a utility that your stylesheet does not define. It also reports
|
|
9
|
+
a known utility with a theme value that does not exist, such as `bg-red-999`. The
|
|
10
|
+
utility produces no CSS.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
style("bg-red-95O");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> unknown-utility: `bg` has no value `red-95O`; did you mean `bg-red-950`?
|
|
19
|
+
>
|
|
20
|
+
> Example:1:11
|
|
21
|
+
|
|
22
|
+
## Fixed
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
style("bg-red-950");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## How to fix
|
|
29
|
+
|
|
30
|
+
- Check the spelling against the theme. In the example, the last character is
|
|
31
|
+
the letter `O` instead of zero. The intended token is `--color-red-950`.
|
|
32
|
+
- To use a value that the theme does not have, add a token to your stylesheet,
|
|
33
|
+
such as `--color-red-999` in `@theme`, or define the utility with `@utility`.
|
|
34
|
+
- For a class that another stylesheet defines, pass it in a `class` field, such as
|
|
35
|
+
`style({ class: "external-card" })`.
|
|
36
|
+
|
|
37
|
+
[Built-in utilities](../utilities.md) looks up the utilities of the default theme.
|
|
38
|
+
|
|
39
|
+
## Rule settings
|
|
40
|
+
|
|
41
|
+
| Preset | Severity |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `recommended` | warn |
|
|
44
|
+
| `strict` | deny |
|
|
45
|
+
| `stylistic` | off |
|
|
46
|
+
|
|
47
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "unknown-variant"
|
|
3
|
+
description: "Reports a variant that your stylesheet does not define."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# unknown-variant
|
|
7
|
+
|
|
8
|
+
This rule reports a variant that your stylesheet does not define, such as a
|
|
9
|
+
misspelled `hovr:`. The condition never matches, so the utilities under it never
|
|
10
|
+
apply.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
style("hovr:p-4");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> unknown-variant: unknown variant `hovr`; did you mean `hover:p-4`?
|
|
19
|
+
>
|
|
20
|
+
> Example:1:8
|
|
21
|
+
|
|
22
|
+
## Fixed
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
style("hover:p-4");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## How to fix
|
|
29
|
+
|
|
30
|
+
- Correct the spelling of the variant.
|
|
31
|
+
- To use a variant of your own, define it with `@custom-variant` in your
|
|
32
|
+
stylesheet.
|
|
33
|
+
|
|
34
|
+
## Rule settings
|
|
35
|
+
|
|
36
|
+
| Preset | Severity |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `recommended` | warn |
|
|
39
|
+
| `strict` | deny |
|
|
40
|
+
| `stylistic` | off |
|
|
41
|
+
|
|
42
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "unsatisfiable-variants"
|
|
3
|
+
description: "Reports variants that can never match together, such as portrait:landscape:."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# unsatisfiable-variants
|
|
7
|
+
|
|
8
|
+
This rule reports stacked variants that can never match at the same time.
|
|
9
|
+
Stacked variants must all match, and a viewport cannot be in portrait and
|
|
10
|
+
landscape orientation at once. The utility never applies.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
style("portrait:landscape:p-4");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> unsatisfiable-variants: variants `portrait:landscape` never match because `@media (orientation: portrait)` and `@media (orientation: landscape)` exclude each other
|
|
19
|
+
>
|
|
20
|
+
> Example:1:8
|
|
21
|
+
|
|
22
|
+
## Fixed
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
style("portrait:p-4 landscape:p-4");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## How to fix
|
|
29
|
+
|
|
30
|
+
- To apply the utility in either case, write one utility for each variant, as in
|
|
31
|
+
the example. When the cases cover every situation, drop the variants: `p-4`.
|
|
32
|
+
- To apply the utility in one case only, keep the variant for that case.
|
|
33
|
+
|
|
34
|
+
## Rule settings
|
|
35
|
+
|
|
36
|
+
| Preset | Severity |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `recommended` | warn |
|
|
39
|
+
| `strict` | deny |
|
|
40
|
+
| `stylistic` | off |
|
|
41
|
+
|
|
42
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "unused-lint-suppression"
|
|
3
|
+
description: "Reports a suppression comment that suppresses no finding."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# unused-lint-suppression
|
|
7
|
+
|
|
8
|
+
This rule reports a suppression comment that suppresses no finding, for example
|
|
9
|
+
because the code was fixed after the comment was added. The comment would hide a
|
|
10
|
+
future finding that nobody has reviewed. The `strict` preset enables this rule.
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"lint": {
|
|
17
|
+
"rules": {
|
|
18
|
+
"unknown-utility": "warn",
|
|
19
|
+
"unused-lint-suppression": "warn"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Reported
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
// swlint-disable-next-line unknown-utility
|
|
29
|
+
style("p-4");
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> unused-lint-suppression: lint suppression for `unknown-utility` suppresses no enabled findings
|
|
33
|
+
>
|
|
34
|
+
> Example:1:29
|
|
35
|
+
|
|
36
|
+
## Fixed
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
style("p-4");
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## How to fix
|
|
43
|
+
|
|
44
|
+
Remove the comment, as in the example. If the rule should still report the line,
|
|
45
|
+
check that the comment is on the right line and names the right rule.
|
|
46
|
+
|
|
47
|
+
## Rule settings
|
|
48
|
+
|
|
49
|
+
| Preset | Severity |
|
|
50
|
+
| --- | --- |
|
|
51
|
+
| `recommended` | off |
|
|
52
|
+
| `strict` | deny |
|
|
53
|
+
| `stylistic` | off |
|
|
54
|
+
|
|
55
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
56
|
+
|
|
57
|
+
The CLI and the editor report this rule only when they analyze the whole project.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "unverified-style-base"
|
|
3
|
+
description: "Reports a base style whose source the CLI cannot find from its type."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# unverified-style-base
|
|
7
|
+
|
|
8
|
+
This rule reports a base style whose type does not show which `style()` call
|
|
9
|
+
created it, such as a value declared as `ReturnType<typeof style>`. The compiler
|
|
10
|
+
cannot find the CSS of the base, so it cannot order the later utilities after it.
|
|
11
|
+
|
|
12
|
+
## Project files
|
|
13
|
+
|
|
14
|
+
```ts title="globals.d.ts"
|
|
15
|
+
declare module "virtual:styles" {
|
|
16
|
+
import { style } from "stillwind/react";
|
|
17
|
+
|
|
18
|
+
export const base: ReturnType<typeof style>;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts title="styles.ts"
|
|
23
|
+
import { style } from "stillwind/react";
|
|
24
|
+
|
|
25
|
+
export const base = style("rounded-md");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Reported
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { base } from "virtual:styles";
|
|
32
|
+
|
|
33
|
+
export const props = style(base, "p-4");
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> unverified-style-base: the style base cannot be identified, so its CSS may follow this call's CSS
|
|
37
|
+
>
|
|
38
|
+
> Example:3:28
|
|
39
|
+
|
|
40
|
+
## Fixed
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { base } from "./styles";
|
|
44
|
+
|
|
45
|
+
export const props = style(base, "p-4");
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## How to fix
|
|
49
|
+
|
|
50
|
+
- Import the base from the source module that calls `style()`, as in the example.
|
|
51
|
+
- Keep the type that TypeScript infers when you export a style. A type annotation
|
|
52
|
+
such as `ReturnType<typeof style>` hides the source.
|
|
53
|
+
|
|
54
|
+
## Rule settings
|
|
55
|
+
|
|
56
|
+
| Preset | Severity |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `recommended` | warn |
|
|
59
|
+
| `strict` | deny |
|
|
60
|
+
| `stylistic` | off |
|
|
61
|
+
|
|
62
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
63
|
+
|
|
64
|
+
The CLI and the editor report this rule only when they analyze the whole project.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.anchorScope()"
|
|
3
|
+
description: "Limit where an anchor name is visible, so that each component instance uses its own anchor."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.anchorScope()
|
|
7
|
+
|
|
8
|
+
`style.anchorScope(scope)` sets `anchor-scope` on an element. Inside that
|
|
9
|
+
element, a positioned element finds only the anchors that are also inside it.
|
|
10
|
+
Use it when a component with an anchor renders more than once on a page.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const trigger = style.ref("trigger");
|
|
20
|
+
export const provider = style(trigger, trigger.asAnchor());
|
|
21
|
+
export const scope = style(style.anchorScope([trigger]));
|
|
22
|
+
export const popover = style("absolute", trigger.positionAnchor(), "top-[anchor(bottom)]");
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Compiled code
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const trigger = undefined;
|
|
29
|
+
export const provider = {className:"sw_im2u7 sw_trigger_xnn7w"};
|
|
30
|
+
export const scope = {className:"sw_tcyj3"};
|
|
31
|
+
export const popover = {className:"sw_vqbik"};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Generated CSS
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
.sw_im2u7:where(.sw_trigger_xnn7w) {
|
|
39
|
+
anchor-name: --sw-a-trigger-xnn7w;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sw_tcyj3 {
|
|
43
|
+
anchor-scope: --sw-a-trigger-xnn7w;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sw_vqbik {
|
|
47
|
+
position-anchor: --sw-a-trigger-xnn7w;
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: anchor(bottom);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Three elements work together:
|
|
54
|
+
|
|
55
|
+
| Element | Call | Sets |
|
|
56
|
+
| ----------- | -------------------------------------- | ----------------- |
|
|
57
|
+
| The anchor | `style(trigger, trigger.asAnchor())` | `anchor-name` |
|
|
58
|
+
| An ancestor | `style(style.anchorScope([trigger]))` | `anchor-scope` |
|
|
59
|
+
| The popover | `style(trigger.positionAnchor(), ...)` | `position-anchor` |
|
|
60
|
+
|
|
61
|
+
Put the scope on the ancestor that contains one anchor and its popover.
|
|
62
|
+
|
|
63
|
+
## Inputs
|
|
64
|
+
|
|
65
|
+
| Scope | Effect |
|
|
66
|
+
| ---------------- | ------------------------------------- |
|
|
67
|
+
| An array of refs | Limits the anchor names of those refs |
|
|
68
|
+
| `"all"` | Limits every anchor name |
|
|
69
|
+
| `"none"` | Sets `anchor-scope: none` |
|
|
70
|
+
|
|
71
|
+
Write the array or keyword directly in the call. When a variable in the array
|
|
72
|
+
can hold one of several refs, the scope includes every ref that it can hold.
|
|
73
|
+
|
|
74
|
+
An empty array sets nothing, and repeated refs add nothing.
|
|
75
|
+
[ineffective-anchor-scope](../lints/ineffective-anchor-scope.md) reports both.
|
|
76
|
+
|
|
77
|
+
`style.anchorScope()` only sets the CSS property. It does not attach a ref, it
|
|
78
|
+
does not create an anchor name, and it does not affect `.in()` conditions.
|
|
79
|
+
|
|
80
|
+
You can also set the scope on the anchor itself with
|
|
81
|
+
`trigger.asAnchor(scope)`. See [ref.asAnchor()](ref/as-anchor.md).
|
|
82
|
+
|
|
83
|
+
## Generated code
|
|
84
|
+
|
|
85
|
+
The compiler turns the scope into generated anchor names or the keyword. When
|
|
86
|
+
it knows every ref, no JavaScript reads the refs at runtime. Stillwind does not
|
|
87
|
+
position elements with JavaScript; the browser's CSS anchor positioning does.
|
|
88
|
+
|
|
89
|
+
See [Element relationships](../guides/element-relationships.md#position-an-element-at-an-anchor)
|
|
90
|
+
for a complete example.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.css()"
|
|
3
|
+
description: "Compile utilities into a CSS string that you place yourself, such as in a shadow root."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.css()
|
|
7
|
+
|
|
8
|
+
`style.css(...rules, options?)` compiles utilities into a CSS string. Unlike
|
|
9
|
+
`style()`, it adds nothing to the page's stylesheet. You decide where the string
|
|
10
|
+
goes, such as a shadow root.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
export const css = style.css("p-4 text-blue-600", {
|
|
20
|
+
selector: ":host",
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Compiled code
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export const css = "/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n:where(:root, :host){--color-blue-600:oklch(54.6% 0.245 262.881);--spacing:0.25rem;}:host{padding:calc(var(--spacing) * 4);}:host{color:var(--color-blue-600);}";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Generated CSS
|
|
31
|
+
|
|
32
|
+
This macro adds no CSS to the stylesheet.
|
|
33
|
+
|
|
34
|
+
## Inputs
|
|
35
|
+
|
|
36
|
+
`rules` accepts utility strings, arrays, objects with variant keys, and `false`,
|
|
37
|
+
`null`, or `undefined`. All of them must be known at build time. Runtime
|
|
38
|
+
conditions, refs, `class` fields, custom properties, and stored `style()`
|
|
39
|
+
results are not accepted, and [invalid-css-input](../lints/invalid-css-input.md)
|
|
40
|
+
reports them.
|
|
41
|
+
|
|
42
|
+
The last argument can be an options object literal:
|
|
43
|
+
|
|
44
|
+
| Option | Value |
|
|
45
|
+
| ---------- | ---------------------------------------------------------------------------------- |
|
|
46
|
+
| `selector` | The selector that utilities without their own selector style, such as `:host` |
|
|
47
|
+
| `template` | The name of an `@stillwind-css-template` in your stylesheet; defaults to `default` |
|
|
48
|
+
|
|
49
|
+
A variant that sets its own selector, such as `host:` or `[button]:`, keeps that
|
|
50
|
+
selector. A utility without `selector` and without such a variant produces no
|
|
51
|
+
CSS, and [missing-document-target](../lints/missing-document-target.md) reports it.
|
|
52
|
+
|
|
53
|
+
## Output
|
|
54
|
+
|
|
55
|
+
The compiler replaces the call with a string literal at build time. No CSS
|
|
56
|
+
compiler runs in the browser.
|
|
57
|
+
|
|
58
|
+
The string contains the theme values, keyframes, and other supporting CSS that
|
|
59
|
+
the template and the utilities need. It never contains the preflight reset.
|
|
60
|
+
|
|
61
|
+
Add the string to the page yourself, for example with
|
|
62
|
+
`CSSStyleSheet.replaceSync()` and a shadow root's `adoptedStyleSheets`. The
|
|
63
|
+
results in [Built-in utilities](../utilities.md) leave out the supporting CSS,
|
|
64
|
+
so they cannot replace this string.
|
|
65
|
+
|
|
66
|
+
To add all styles of a module to a shadow root, including the preflight reset,
|
|
67
|
+
import them from `stillwind/module-css` instead. See
|
|
68
|
+
[Web Components](../guides/web-components.md).
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.cva()"
|
|
3
|
+
description: "Create a factory that selects compiled styles by option, with the configuration of class-variance-authority."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.cva()
|
|
7
|
+
|
|
8
|
+
`style.cva(base?, config?)` creates a factory with the configuration format of
|
|
9
|
+
`cva` from class-variance-authority. The compiler generates the CSS for every
|
|
10
|
+
option at build time. Calling the factory selects the compiled classes for the
|
|
11
|
+
chosen options and returns props for an element.
|
|
12
|
+
|
|
13
|
+
`style.cva()` exists mainly to migrate existing CVA components. For new
|
|
14
|
+
components, see [Reusable styles](../guides/reusable-styles.md).
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
### Source
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { style } from "stillwind/react";
|
|
22
|
+
|
|
23
|
+
export const button = style.cva("inline-flex rounded-md", {
|
|
24
|
+
variants: {
|
|
25
|
+
size: {
|
|
26
|
+
small: "px-2 py-1",
|
|
27
|
+
large: "px-4 py-2",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
size: "small",
|
|
32
|
+
},
|
|
33
|
+
compoundVariants: [
|
|
34
|
+
{
|
|
35
|
+
size: "large",
|
|
36
|
+
class: "font-medium",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const props = button({ size: "large" });
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Compiled code
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { stillwindCva } from "stillwind/runtime/class-name-object";
|
|
48
|
+
|
|
49
|
+
export const button = stillwindCva("sw_ilpwh", {
|
|
50
|
+
variants: {
|
|
51
|
+
size: {
|
|
52
|
+
small: "sw_h1m4c",
|
|
53
|
+
large: "sw_8bi9g",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
size: "small",
|
|
58
|
+
},
|
|
59
|
+
compoundVariants: [
|
|
60
|
+
{
|
|
61
|
+
size: "large",
|
|
62
|
+
class: "sw_xlk4i",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const props = button({ size: "large" });
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Generated CSS
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
```css
|
|
74
|
+
.sw_ilpwh {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
border-radius: var(--radius-md);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.sw_h1m4c {
|
|
80
|
+
padding-inline: calc(var(--spacing) * 2);
|
|
81
|
+
padding-block: calc(var(--spacing) * 1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sw_8bi9g {
|
|
85
|
+
padding-inline: calc(var(--spacing) * 4);
|
|
86
|
+
padding-block: calc(var(--spacing) * 2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sw_xlk4i {
|
|
90
|
+
--tw-font-weight: var(--font-weight-medium);
|
|
91
|
+
font-weight: var(--font-weight-medium);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Configuration
|
|
96
|
+
|
|
97
|
+
Write the configuration as an object literal in the call:
|
|
98
|
+
|
|
99
|
+
| Field | Value |
|
|
100
|
+
| ------------------ | ---------------------------------------------------------------- |
|
|
101
|
+
| `variants` | Each option name maps each value to a style |
|
|
102
|
+
| `defaultVariants` | The value that each option uses when the call passes `undefined` |
|
|
103
|
+
| `compoundVariants` | Entries that add `class` when every listed option matches |
|
|
104
|
+
|
|
105
|
+
`class` and `className` cannot be option names, because the factory uses them
|
|
106
|
+
for classes from other stylesheets. An option with the values `true` and
|
|
107
|
+
`false` accepts booleans.
|
|
108
|
+
|
|
109
|
+
Use `VariantProps<typeof button>` from your framework's entrypoint to type the
|
|
110
|
+
options.
|
|
111
|
+
|
|
112
|
+
## Style values
|
|
113
|
+
|
|
114
|
+
The base and each option value accept utility strings, arrays, objects with
|
|
115
|
+
variant keys, `true`, `false`, `null`, `undefined`, and custom properties.
|
|
116
|
+
|
|
117
|
+
They do not accept `&&`, ternaries, stored `style()` results, refs, animations,
|
|
118
|
+
or `class` fields. To choose a style at runtime, pass a different option to the
|
|
119
|
+
factory. [invalid-cva-input](../lints/invalid-cva-input.md) reports these
|
|
120
|
+
values, and [invalid-cva-config](../lints/invalid-cva-config.md) reports a
|
|
121
|
+
malformed configuration.
|
|
122
|
+
|
|
123
|
+
A custom property value can be an expression. The factory evaluates it once,
|
|
124
|
+
when the factory is created. Custom properties stay in the inline style, so a
|
|
125
|
+
later option can replace them.
|
|
126
|
+
|
|
127
|
+
## Calling the factory
|
|
128
|
+
|
|
129
|
+
| Option value | Result |
|
|
130
|
+
| ------------ | ------------------------------------- |
|
|
131
|
+
| `undefined` | Uses the value from `defaultVariants` |
|
|
132
|
+
| `null` | Adds nothing for that option |
|
|
133
|
+
| A value | Adds the style of that value |
|
|
134
|
+
|
|
135
|
+
The result combines, in order: the base, the selected values in the order of
|
|
136
|
+
the keys of `variants`, every matching compound variant in array order, and the
|
|
137
|
+
`class` or `className` from the call. The option values are not passed to the
|
|
138
|
+
element. Each call returns a new props object.
|
|
139
|
+
|
|
140
|
+
The factory does not merge utilities at runtime. When two selected styles set
|
|
141
|
+
the same property, the compiler's CSS order decides which one wins.
|
|
142
|
+
|
|
143
|
+
The props that the factory returns cannot be passed to `style()` as a base.
|
|
144
|
+
|
|
145
|
+
## Generated code
|
|
146
|
+
|
|
147
|
+
The compiler creates the factory with `stillwindCva` from the framework runtime,
|
|
148
|
+
together with the compiled class names. Factory calls stay ordinary JavaScript.
|
|
149
|
+
The development build checks the selected values and the classes from other
|
|
150
|
+
stylesheets.
|
|
151
|
+
|
|
152
|
+
See [Migrating from Tailwind CSS](../guides/migrating-from-tailwind.md#cva) to
|
|
153
|
+
convert existing `cva` calls.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Macro reference"
|
|
3
|
+
description: "Find the Stillwind API for a task, and read its accepted inputs and generated code."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Macro reference
|
|
7
|
+
|
|
8
|
+
Stillwind's API consists of macros: functions that the compiler replaces with
|
|
9
|
+
generated code at build time. Each page lists the inputs that the macro accepts,
|
|
10
|
+
and it shows the generated JavaScript and CSS for its examples.
|
|
11
|
+
|
|
12
|
+
| Macro | Use it to | Guide |
|
|
13
|
+
| ------------------------------------------------------ | ---------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
14
|
+
| [style()](style.md) | Style an element | [The basics of style()](../guides/style.md) |
|
|
15
|
+
| [style.ref()](ref/index.md) | Style an element from another element's state, size, or position | [Element relationships](../guides/element-relationships.md) |
|
|
16
|
+
| [style.anchorScope()](anchor-scope.md) | Limit where an anchor name is visible | [Element relationships](../guides/element-relationships.md) |
|
|
17
|
+
| [style.keyframes()](keyframes.md) | Define an animation in a component | [Animations](../guides/animations.md) |
|
|
18
|
+
| [style.viewTransition()](view-transition.md) | Style view transition snapshots and name each item | [View transitions](../guides/view-transitions.md) |
|
|
19
|
+
| [style.media()](media.md) | Use a named breakpoint as a media query in JavaScript | [Responsive styles](../guides/responsive-styles.md) |
|
|
20
|
+
| [style.css()](css.md) | Compile utilities into a CSS string for a shadow root | [Web Components](../guides/web-components.md) |
|
|
21
|
+
| [style.cva()](cva.md) | Migrate components that use `cva` | [Migrating from Tailwind CSS](../guides/migrating-from-tailwind.md) |
|
|
22
|
+
|
|
23
|
+
Import the macros from the entrypoint of your framework, such as
|
|
24
|
+
`stillwind/react`. The examples on these pages use React.
|
|
25
|
+
|
|
26
|
+
Each example shows the source, the compiled code, and the CSS that it adds to
|
|
27
|
+
the stylesheet. In development, Stillwind also adds checks that report invalid
|
|
28
|
+
values at runtime. The compiled code on these pages leaves them out.
|
|
29
|
+
[How styles compile](../concepts/how-styles-compile.md) explains the generated code in
|
|
30
|
+
general.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.keyframes()"
|
|
3
|
+
description: "Define keyframes in a component, and apply them with animation options in style()."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.keyframes()
|
|
7
|
+
|
|
8
|
+
`style.keyframes(definition)` defines an animation. Calling the result inside
|
|
9
|
+
`style()` applies the animation, and its argument sets the animation's options.
|
|
10
|
+
The compiler generates a unique animation name.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const fade = style.keyframes({
|
|
20
|
+
from: "opacity-0",
|
|
21
|
+
to: "opacity-100",
|
|
22
|
+
});
|
|
23
|
+
export const props = style(fade("duration-300 ease-in-out"));
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Compiled code
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const fade = undefined;
|
|
30
|
+
export const props = {className:"sw_4y7y6"};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Generated CSS
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
@keyframes sw-kf-74r1m {
|
|
38
|
+
from {
|
|
39
|
+
opacity: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
to {
|
|
43
|
+
opacity: 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sw_4y7y6 {
|
|
48
|
+
animation-name: sw-kf-74r1m;
|
|
49
|
+
animation-duration: .3s;
|
|
50
|
+
animation-timing-function: var(--ease-in-out);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Define the frames
|
|
55
|
+
|
|
56
|
+
Write `style.keyframes()` as the initial value of a variable, with an object
|
|
57
|
+
literal as its argument:
|
|
58
|
+
|
|
59
|
+
| Key | Value |
|
|
60
|
+
| ------------------------------------- | ---------------------------------------------------------------------------- |
|
|
61
|
+
| `from`, `to`, or a percentage | A utility string for that frame, without variants |
|
|
62
|
+
| A variant, such as `"motion-reduce:"` | A complete definition that replaces the whole animation under that condition |
|
|
63
|
+
| `label` | An optional string literal that appears in the generated name |
|
|
64
|
+
|
|
65
|
+
Under a variant, the definition replaces every frame. It does not inherit frames
|
|
66
|
+
from the ordinary definition. Use media and `supports-*` variants here. Selector
|
|
67
|
+
and container variants are not supported.
|
|
68
|
+
|
|
69
|
+
The declaration can be at the top level of a module, in a function, or in a
|
|
70
|
+
callback. Each `style.keyframes()` call in the source creates one name, and the
|
|
71
|
+
name stays the same in every render and function call. You can export the
|
|
72
|
+
definition and import it in other modules.
|
|
73
|
+
|
|
74
|
+
## Apply the animation
|
|
75
|
+
|
|
76
|
+
Call the definition inside `style()`, such as `fade("duration-300 ease-in-out")`.
|
|
77
|
+
The argument is a string literal of animation options. Timing utilities set
|
|
78
|
+
animation properties here: `duration-300` sets `animation-duration`, not
|
|
79
|
+
`transition-duration`. A utility that is not an animation option, such as
|
|
80
|
+
`p-4`, produces no CSS, and
|
|
81
|
+
[invalid-animation-option](../lints/invalid-animation-option.md) reports it.
|
|
82
|
+
|
|
83
|
+
Write the call directly in `style()`. Storing `fade("duration-300")` in a
|
|
84
|
+
variable causes [SW10004](../errors/SW10004.md).
|
|
85
|
+
|
|
86
|
+
To turn the animation on or off by condition, put the call under a variant, such
|
|
87
|
+
as `{ "motion-safe:": fade("duration-300") }`.
|
|
88
|
+
|
|
89
|
+
## Generated code
|
|
90
|
+
|
|
91
|
+
When the compiler knows which animation a call uses, the call becomes plain
|
|
92
|
+
class names, and the definition variable can become `undefined` in JavaScript.
|
|
93
|
+
The compiler writes every `@keyframes` rule that the calls need, together with
|
|
94
|
+
the theme values that the frames use.
|
|
95
|
+
|
|
96
|
+
See [Animations](../guides/animations.md) for task-based examples, and
|
|
97
|
+
[invalid-keyframes-variant](../lints/invalid-keyframes-variant.md) for
|
|
98
|
+
unsupported variants.
|