stillwind 0.0.0 → 0.1.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,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Web Components"
|
|
3
|
+
description: "Add the compiled styles of a component module to its shadow root."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Web Components
|
|
7
|
+
|
|
8
|
+
You want to style the elements inside the shadow root of a Web Component. The
|
|
9
|
+
build integration adds compiled CSS to the page's stylesheet, but the page's
|
|
10
|
+
stylesheet does not reach into a shadow root. Import the compiled CSS of the
|
|
11
|
+
component's module from `stillwind/module-css`, and add it to the shadow root.
|
|
12
|
+
|
|
13
|
+
## Keep the styles out of the page
|
|
14
|
+
|
|
15
|
+
```ts title="vite.config.ts"
|
|
16
|
+
import { stillwind } from "@stillwind/integration/vite";
|
|
17
|
+
import { defineConfig } from "vite";
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
20
|
+
plugins: [
|
|
21
|
+
stillwind({
|
|
22
|
+
automatic: false,
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
With `automatic: false`, modules do not add their styles to the page's
|
|
29
|
+
stylesheet. Each component adds its styles to its own shadow root instead. The
|
|
30
|
+
webpack and Rspack plugins accept the same option.
|
|
31
|
+
|
|
32
|
+
Keep the default when the application also styles elements outside shadow
|
|
33
|
+
roots. A module that imports `stillwind/module-css` never adds its styles to the
|
|
34
|
+
page. With the default, a module that only exports shared styles still adds them
|
|
35
|
+
to the page.
|
|
36
|
+
|
|
37
|
+
## Import the CSS of a module
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { css, parts } from "stillwind/module-css";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The compiler replaces this import in each module that contains it. The CSS
|
|
44
|
+
contains the styles of the `style()` calls in that module and the styles that
|
|
45
|
+
those calls compose from other modules. It also contains the theme values, the
|
|
46
|
+
preflight reset, and the other rules of your stylesheet.
|
|
47
|
+
|
|
48
|
+
The import provides the CSS in two forms:
|
|
49
|
+
|
|
50
|
+
- `css` is one string. Use it with an API that accepts stylesheet text, such as
|
|
51
|
+
Lit's `static styles`. The default export is the same string.
|
|
52
|
+
- `parts` lists the pieces of the CSS in order. Pass it to `styleSheets()` from
|
|
53
|
+
`stillwind/css`, which returns constructed stylesheets. Shadow roots in the
|
|
54
|
+
same document share the stylesheets for equal pieces, such as the preflight
|
|
55
|
+
reset.
|
|
56
|
+
|
|
57
|
+
## Add the CSS to the shadow root
|
|
58
|
+
|
|
59
|
+
Add the CSS where your framework sets up the shadow root.
|
|
60
|
+
|
|
61
|
+
### Lit
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { html, LitElement, unsafeCSS } from "lit";
|
|
65
|
+
import { applyStyle, style } from "stillwind/lit";
|
|
66
|
+
import { css } from "stillwind/module-css";
|
|
67
|
+
|
|
68
|
+
class SaveButton extends LitElement {
|
|
69
|
+
static styles = unsafeCSS(css);
|
|
70
|
+
|
|
71
|
+
render() {
|
|
72
|
+
return html`<button ${applyStyle(style("px-4 py-2"))}>Save</button>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
customElements.define("save-button", SaveButton);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Vue
|
|
80
|
+
|
|
81
|
+
Export `styles` from a plain `<script>` block of a `.ce.vue` file.
|
|
82
|
+
`defineCustomElement()` adds these styles to the shadow root:
|
|
83
|
+
|
|
84
|
+
```vue title="SaveButton.ce.vue"
|
|
85
|
+
<script lang="ts">
|
|
86
|
+
import { css } from "stillwind/module-css";
|
|
87
|
+
|
|
88
|
+
export default {
|
|
89
|
+
styles: [css],
|
|
90
|
+
};
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<script setup lang="ts">
|
|
94
|
+
import { style } from "stillwind/vue";
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<template>
|
|
98
|
+
<button v-bind="style('px-4 py-2')">Save</button>
|
|
99
|
+
</template>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { defineCustomElement } from "vue";
|
|
104
|
+
|
|
105
|
+
import SaveButton from "./SaveButton.ce.vue";
|
|
106
|
+
|
|
107
|
+
customElements.define("save-button", defineCustomElement(SaveButton));
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Svelte
|
|
111
|
+
|
|
112
|
+
Set `compilerOptions.customElement` to `true` in `svelte.config.js`. Then adopt
|
|
113
|
+
the stylesheets after the component mounts:
|
|
114
|
+
|
|
115
|
+
```svelte
|
|
116
|
+
<svelte:options customElement="save-button" />
|
|
117
|
+
|
|
118
|
+
<script lang="ts">
|
|
119
|
+
import { styleSheets } from "stillwind/css";
|
|
120
|
+
import { parts } from "stillwind/module-css";
|
|
121
|
+
import { style } from "stillwind/svelte";
|
|
122
|
+
import { onMount } from "svelte";
|
|
123
|
+
|
|
124
|
+
const host = $host();
|
|
125
|
+
|
|
126
|
+
onMount(() => {
|
|
127
|
+
host.shadowRoot!.adoptedStyleSheets = styleSheets(parts, host.ownerDocument);
|
|
128
|
+
});
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<button {...style("px-4 py-2")}>Save</button>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Solid
|
|
135
|
+
|
|
136
|
+
With `solid-element`, adopt the stylesheets in the component function:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { customElement } from "solid-element";
|
|
140
|
+
import { styleSheets } from "stillwind/css";
|
|
141
|
+
import { parts } from "stillwind/module-css";
|
|
142
|
+
import { style } from "stillwind/solid";
|
|
143
|
+
|
|
144
|
+
customElement("save-button", {}, (_props, { element }) => {
|
|
145
|
+
const root = element.renderRoot as ShadowRoot;
|
|
146
|
+
root.adoptedStyleSheets = styleSheets(parts, element.ownerDocument);
|
|
147
|
+
|
|
148
|
+
return <button {...style("px-4 py-2")}>Save</button>;
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Vanilla JavaScript
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { styleSheets } from "stillwind/css";
|
|
156
|
+
import { parts } from "stillwind/module-css";
|
|
157
|
+
import { applyStyle, clearStyle, style } from "stillwind/vanilla";
|
|
158
|
+
|
|
159
|
+
class SaveButton extends HTMLElement {
|
|
160
|
+
readonly #root = this.attachShadow({
|
|
161
|
+
mode: "open",
|
|
162
|
+
});
|
|
163
|
+
readonly #button = document.createElement("button");
|
|
164
|
+
|
|
165
|
+
constructor() {
|
|
166
|
+
super();
|
|
167
|
+
this.#button.textContent = "Save";
|
|
168
|
+
this.#root.append(this.#button);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
connectedCallback(): void {
|
|
172
|
+
this.#root.adoptedStyleSheets = styleSheets(parts, this.ownerDocument);
|
|
173
|
+
applyStyle(this.#button, style("px-4 py-2"));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
disconnectedCallback(): void {
|
|
177
|
+
clearStyle(this.#button);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
customElements.define("save-button", SaveButton);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Compile a stylesheet for a few utilities
|
|
185
|
+
|
|
186
|
+
`style.css()` compiles the utilities that you pass into a CSS string. Use it for
|
|
187
|
+
a small stylesheet, such as styles for `:host`, when you do not need the
|
|
188
|
+
preflight reset or the other rules of your stylesheet:
|
|
189
|
+
|
|
190
|
+
```ts
|
|
191
|
+
import { style } from "stillwind/vanilla";
|
|
192
|
+
|
|
193
|
+
export const hostCss = style.css("block p-4", {
|
|
194
|
+
selector: ":host",
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
The `selector` option chooses the element that the utilities style. The string
|
|
199
|
+
contains the theme values and keyframes that its utilities need, and it adds
|
|
200
|
+
nothing to the page's stylesheet. Add it to the shadow root in the same way as
|
|
201
|
+
the `css` string from `stillwind/module-css`, or create a stylesheet from it with
|
|
202
|
+
`CSSStyleSheet.replaceSync()`. The [style.css() reference](../macros/css.md)
|
|
203
|
+
describes variants that choose their own element and the `template` option.
|
|
204
|
+
|
|
205
|
+
## Constraints
|
|
206
|
+
|
|
207
|
+
- The CSS of a module contains only the styles of that module and the styles
|
|
208
|
+
that it composes from other modules. The `style()` calls of a component in
|
|
209
|
+
another module belong to the CSS of that module, even when the component
|
|
210
|
+
renders into the same shadow root. Keep the `style()` calls for one shadow root
|
|
211
|
+
in the module that imports the CSS, or compose styles from other modules into
|
|
212
|
+
those calls.
|
|
213
|
+
- Shadow roots share the stylesheets that `styleSheets()` returns. Do not change
|
|
214
|
+
them: a change appears in every shadow root that adopts the same stylesheet.
|
|
215
|
+
- If a browser that you support lacks `adoptedStyleSheets`, add `css` in a
|
|
216
|
+
`<style>` element instead.
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Getting started"
|
|
3
|
+
description: "Add Stillwind to a Vite and React application, style a component, and check your styles."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Getting started
|
|
7
|
+
|
|
8
|
+
This guide adds Stillwind to a Vite application that uses React. At the end, a
|
|
9
|
+
button uses Stillwind styles, and the CLI checks them. For another framework or
|
|
10
|
+
build tool, follow the same steps and use the build setup from
|
|
11
|
+
[Framework integrations](integrations.md). To let a coding agent do the
|
|
12
|
+
setup, see [Coding agents](agents.md).
|
|
13
|
+
|
|
14
|
+
> **Early development**
|
|
15
|
+
>
|
|
16
|
+
> Stillwind is in early development. Test your application's build and pages before you release
|
|
17
|
+
> changes.
|
|
18
|
+
|
|
19
|
+
## Install the packages
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
vp i stillwind
|
|
23
|
+
vp i -D @stillwind/integration @stillwind/cli
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`stillwind` provides the style API. `@stillwind/integration` compiles your styles
|
|
27
|
+
during development and builds. `@stillwind/cli` checks your styles from the command line.
|
|
28
|
+
|
|
29
|
+
## Create a stylesheet
|
|
30
|
+
|
|
31
|
+
Create `src/stillwind.css`:
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@import "stillwind";
|
|
35
|
+
|
|
36
|
+
@theme {
|
|
37
|
+
--color-accent: oklch(0.6 0.2 250);
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`@import "stillwind"` loads the default Tailwind CSS v4 theme and utilities.
|
|
42
|
+
Each token in `@theme` adds utilities. For example, `--color-accent` adds
|
|
43
|
+
`bg-accent` and `text-accent`.
|
|
44
|
+
|
|
45
|
+
## Configure the project
|
|
46
|
+
|
|
47
|
+
Create `stillwind.config.ts` in the application root:
|
|
48
|
+
|
|
49
|
+
```ts title="stillwind.config.ts"
|
|
50
|
+
import { defineConfig } from "stillwind/config";
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
projects: [
|
|
54
|
+
{
|
|
55
|
+
css: "./src/stillwind.css",
|
|
56
|
+
files: ["src/**/*.{ts,tsx,vue,svelte,astro}"],
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`css` selects the stylesheet. `files` selects the files that the CLI and the
|
|
63
|
+
editor check.
|
|
64
|
+
|
|
65
|
+
> **Builds ignore files**
|
|
66
|
+
>
|
|
67
|
+
> The build compiles every module that your application imports, whether or not `files` matches it.
|
|
68
|
+
> The CLI and the language server (LSP) use `files` to find source files, including files that the
|
|
69
|
+
> application does not import.
|
|
70
|
+
|
|
71
|
+
Add Stillwind to `vite.config.ts`:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { stillwind } from "@stillwind/integration/vite";
|
|
75
|
+
import react from "@vitejs/plugin-react";
|
|
76
|
+
import { defineConfig } from "vite";
|
|
77
|
+
|
|
78
|
+
export default defineConfig({
|
|
79
|
+
plugins: [stillwind(), react()],
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Place `stillwind()` before `react()`. Stillwind must compile styles before React
|
|
84
|
+
compiles JSX. The plugin finds `stillwind.config.ts` in the application root.
|
|
85
|
+
|
|
86
|
+
## Style a component
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { style } from "stillwind/react";
|
|
90
|
+
|
|
91
|
+
export function SaveButton({ loading }: { loading: boolean }) {
|
|
92
|
+
return (
|
|
93
|
+
<button
|
|
94
|
+
disabled={loading}
|
|
95
|
+
{...style(
|
|
96
|
+
"rounded-md bg-accent px-4 py-2 text-white hover:opacity-90",
|
|
97
|
+
loading && "opacity-60",
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
Save changes
|
|
101
|
+
</button>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`style()` returns props, such as `className`, so you spread the result onto the
|
|
107
|
+
element. Each argument adds utilities. `loading && "opacity-60"` adds
|
|
108
|
+
`opacity-60` only while `loading` is true.
|
|
109
|
+
|
|
110
|
+
Start the development server. The button uses the accent color from your
|
|
111
|
+
stylesheet. The build writes the CSS for these utilities to a static CSS file.
|
|
112
|
+
|
|
113
|
+
## Check your styles
|
|
114
|
+
|
|
115
|
+
Change `bg-accent` to `bg-acent`, and run the CLI from the application root:
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
vp exec stillwind lint
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The CLI reports `bg-acent` as an unknown utility. The build does not report this
|
|
122
|
+
mistake: the misspelled utility produces no CSS, and the page still renders.
|
|
123
|
+
Run the CLI in CI to catch such mistakes before you merge them.
|
|
124
|
+
|
|
125
|
+
## Next steps
|
|
126
|
+
|
|
127
|
+
- [Why Stillwind](why.md) explains what Stillwind checks and why.
|
|
128
|
+
- [The basics of style()](guides/style.md) covers variants, conditions, and reusable styles.
|
|
129
|
+
- [Design systems](guides/design-systems.md) restricts colors, spacing, and breakpoints to your theme.
|
|
130
|
+
- [Checks in the editor and CI](guides/lint-adoption.md) adds the CLI to CI and the editor.
|
|
131
|
+
|
|
132
|
+
## Set up with an AI agent
|
|
133
|
+
|
|
134
|
+
[Coding agents](agents.md) gives a prompt that sets up Stillwind or migrates
|
|
135
|
+
an existing project. The `stillwind` package includes this documentation and
|
|
136
|
+
skills for the agent.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Framework integrations"
|
|
3
|
+
description: "Import style() for your framework, and add Stillwind to your build tool."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Framework integrations
|
|
7
|
+
|
|
8
|
+
Each application needs two things: the `style` import for its component framework,
|
|
9
|
+
and the Stillwind integration for its build tool. This page assumes that you have
|
|
10
|
+
created the stylesheet and `stillwind.config.ts` from [Getting started](index.md).
|
|
11
|
+
Each integration finds `stillwind.config.ts` in the application root.
|
|
12
|
+
|
|
13
|
+
## Import style() for your framework
|
|
14
|
+
|
|
15
|
+
Import `style` from the entrypoint of the framework that renders the element:
|
|
16
|
+
|
|
17
|
+
| Framework | Import | Class prop |
|
|
18
|
+
| ------------------ | ------------------- | ----------- |
|
|
19
|
+
| Alpine | `stillwind/alpine` | `class` |
|
|
20
|
+
| Astro | `stillwind/astro` | `class` |
|
|
21
|
+
| Lit | `stillwind/lit` | `class` |
|
|
22
|
+
| Preact | `stillwind/preact` | `class` |
|
|
23
|
+
| Qwik | `stillwind/qwik` | `class` |
|
|
24
|
+
| React | `stillwind/react` | `className` |
|
|
25
|
+
| Solid | `stillwind/solid` | `class` |
|
|
26
|
+
| Svelte | `stillwind/svelte` | `class` |
|
|
27
|
+
| Vanilla JavaScript | `stillwind/vanilla` | `class` |
|
|
28
|
+
| Vue | `stillwind/vue` | `class` |
|
|
29
|
+
|
|
30
|
+
Spread the result with your framework's syntax. In JSX, Svelte, and Astro, write
|
|
31
|
+
`{...style("...")}`. In Vue templates, write `v-bind="style('...')"`:
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { style } from "stillwind/vue";
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<button v-bind="style('rounded-md bg-accent px-4 py-2 text-white')">Save changes</button>
|
|
40
|
+
</template>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
A component uses the entrypoint of its own framework. For example, a React
|
|
44
|
+
island inside an Astro page imports `stillwind/react`.
|
|
45
|
+
|
|
46
|
+
Alpine uses the `stillwind` plugin from `stillwind/alpine`. Register it with
|
|
47
|
+
`Alpine.plugin(stillwind)` before `Alpine.start()`, then bind compiled props with
|
|
48
|
+
`x-sw="props"`. Write macro calls in JavaScript or TypeScript modules.
|
|
49
|
+
|
|
50
|
+
Lit uses `html` element bindings such as
|
|
51
|
+
`` html`<button ${applyStyle(style("px-4 py-2"))}>Save</button>` ``.
|
|
52
|
+
Import both helpers from `stillwind/lit`. To add the styles to a shadow root,
|
|
53
|
+
see [Web Components](guides/web-components.md). The Lit directive supports
|
|
54
|
+
browser rendering; Lit SSR is unsupported.
|
|
55
|
+
|
|
56
|
+
Gatsby uses `stillwind/react`, and Fresh 2 with Vite uses `stillwind/preact`.
|
|
57
|
+
For Fresh, use Deno 2.9 or newer and register `fresh()` before `stillwind()` from
|
|
58
|
+
`@stillwind/integration/fresh` in the Vite configuration. The adapter keeps server
|
|
59
|
+
and island classes consistent. Fresh's legacy Builder is unsupported.
|
|
60
|
+
|
|
61
|
+
## Vanilla JavaScript
|
|
62
|
+
|
|
63
|
+
Import the DOM helpers with the macro:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { applyStyle, clearStyle, style } from "stillwind/vanilla";
|
|
67
|
+
|
|
68
|
+
const button = document.querySelector("button")!;
|
|
69
|
+
applyStyle(button, style("rounded-md bg-accent px-4 py-2 text-white"));
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Call `applyStyle` again to update the element. Call `clearStyle(button)` to remove
|
|
73
|
+
its Stillwind contribution. The helpers preserve existing classes and unrelated
|
|
74
|
+
inline styles, and restore overwritten inline values unless another writer has
|
|
75
|
+
changed them. Use a build integration to compile the macros and deliver CSS.
|
|
76
|
+
|
|
77
|
+
Import framework macros under different names when one module styles both framework
|
|
78
|
+
elements and DOM elements. Each macro returns props for its own target.
|
|
79
|
+
|
|
80
|
+
## Vite
|
|
81
|
+
|
|
82
|
+
Use the Vite plugin for Alpine, Lit, Preact, Qwik, React, Solid, Svelte, vanilla
|
|
83
|
+
JavaScript, and Vue applications:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { stillwind } from "@stillwind/integration/vite";
|
|
87
|
+
import react from "@vitejs/plugin-react";
|
|
88
|
+
import { defineConfig } from "vite";
|
|
89
|
+
|
|
90
|
+
export default defineConfig({
|
|
91
|
+
plugins: [stillwind(), react()],
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Place `stillwind()` before the framework plugin, because Stillwind must compile
|
|
96
|
+
styles before the framework compiles JSX or templates.
|
|
97
|
+
|
|
98
|
+
Some plugins split routes or server functions before compilation, such as the
|
|
99
|
+
TanStack Start plugin. Place those plugins before `stillwind()`:
|
|
100
|
+
`[tanstackStart(), stillwind(), react()]`.
|
|
101
|
+
|
|
102
|
+
## Astro
|
|
103
|
+
|
|
104
|
+
Add the integration to `astro.config.ts`:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { stillwind } from "@stillwind/integration/astro";
|
|
108
|
+
import { defineConfig } from "astro/config";
|
|
109
|
+
|
|
110
|
+
export default defineConfig({
|
|
111
|
+
integrations: [stillwind()],
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
The integration also adds styles to server-rendered pages and islands. Keep your
|
|
116
|
+
other integrations, such as `@astrojs/react`.
|
|
117
|
+
|
|
118
|
+
## Next.js
|
|
119
|
+
|
|
120
|
+
Wrap your configuration in `next.config.mjs`:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
import { withStillwind } from "@stillwind/integration/next";
|
|
124
|
+
|
|
125
|
+
export default withStillwind({});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Pass your existing configuration to `withStillwind()`. The wrapper works with
|
|
129
|
+
both webpack and Turbopack, and it keeps `"use client"` and `"use server"`
|
|
130
|
+
directives.
|
|
131
|
+
|
|
132
|
+
The stylesheet includes the routes under `app/`, `pages/`, `src/app/`, and
|
|
133
|
+
`src/pages/`, and the modules
|
|
134
|
+
that they import with static import paths. A module that you import through a
|
|
135
|
+
computed path, or a route written in MDX, gets no styles. If Next.js runs from a
|
|
136
|
+
directory other than the application root, set the `root` option.
|
|
137
|
+
|
|
138
|
+
## SvelteKit
|
|
139
|
+
|
|
140
|
+
Add the Vite plugin before `sveltekit()`:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { stillwind } from "@stillwind/integration/vite";
|
|
144
|
+
import { sveltekit } from "@sveltejs/kit/vite";
|
|
145
|
+
import { defineConfig } from "vite";
|
|
146
|
+
|
|
147
|
+
export default defineConfig({
|
|
148
|
+
plugins: [stillwind(), sveltekit()],
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
In development, add the server hook so that server-rendered pages include their
|
|
153
|
+
styles before JavaScript runs. Create `src/hooks.server.ts`:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
export { handle } from "@stillwind/integration/sveltekit/handle";
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
If you already have a `handle`, combine both with `sequence()` from
|
|
160
|
+
`@sveltejs/kit/hooks`.
|
|
161
|
+
|
|
162
|
+
## Nuxt
|
|
163
|
+
|
|
164
|
+
Add the module to `nuxt.config.ts`:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
import { stillwind } from "@stillwind/integration/nuxt";
|
|
168
|
+
|
|
169
|
+
export default defineNuxtConfig({
|
|
170
|
+
modules: [stillwind()],
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The module sets up Vite and server rendering. Do not add the Vite plugin as well.
|
|
175
|
+
|
|
176
|
+
## Other build tools
|
|
177
|
+
|
|
178
|
+
| Build tool | Import | Registration |
|
|
179
|
+
| ---------- | ---------------------------------- | ---------------------------------- |
|
|
180
|
+
| webpack | `@stillwind/integration/webpack` | `plugins: [new StillwindPlugin()]` |
|
|
181
|
+
| Rspack | `@stillwind/integration/rspack` | `plugins: [new StillwindPlugin()]` |
|
|
182
|
+
| Rsbuild | `@stillwind/integration/rsbuild` | `plugins: [pluginStillwind()]` |
|
|
183
|
+
| Turbopack | `@stillwind/integration/turbopack` | Add `stillwindRules({ entries })` |
|
|
184
|
+
|
|
185
|
+
With webpack and Vue, place `StillwindPlugin` before `VueLoaderPlugin`. With
|
|
186
|
+
standalone Turbopack, list every entry module of the application in `entries`.
|
|
187
|
+
|
|
188
|
+
The [build integration reference](https://github.com/SegaraRai/stillwind/blob/main/docs/integrations.md)
|
|
189
|
+
describes every option.
|
|
190
|
+
[How styles compile](concepts/how-styles-compile.md) explains how the CSS reaches the page.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ambiguous-style-base-order"
|
|
3
|
+
description: "Reports two independent base styles in one call that set the same property."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ambiguous-style-base-order
|
|
7
|
+
|
|
8
|
+
This rule reports a `style()` call with two base styles that set the same
|
|
9
|
+
property, when neither base is built on the other. The order of the arguments
|
|
10
|
+
does not decide which base wins, so the result is not defined.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
const first = style("p-2");
|
|
16
|
+
const second = style("p-4");
|
|
17
|
+
export const props = style(first, second);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> ambiguous-style-base-order: two composition bases declare `padding`; neither base precedes the other, so which declaration wins is undefined
|
|
21
|
+
>
|
|
22
|
+
> Example:3:22
|
|
23
|
+
|
|
24
|
+
## Fixed
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
const first = style("p-2");
|
|
28
|
+
const second = style(first, "p-4");
|
|
29
|
+
export const props = style(second);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## How to fix
|
|
33
|
+
|
|
34
|
+
- Build the overriding base on the other one, as in the example. Then its
|
|
35
|
+
utilities always win.
|
|
36
|
+
- Or remove the property from one of the bases.
|
|
37
|
+
|
|
38
|
+
Bases that set different properties do not need this.
|
|
39
|
+
|
|
40
|
+
## Rule settings
|
|
41
|
+
|
|
42
|
+
| Preset | Severity |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| `recommended` | warn |
|
|
45
|
+
| `strict` | deny |
|
|
46
|
+
| `stylistic` | off |
|
|
47
|
+
|
|
48
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
49
|
+
|
|
50
|
+
The CLI and the editor report this rule only when they analyze the whole project.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "bypassed-undefinition"
|
|
3
|
+
description: "Reports a top-level utility definition that also applies where the built-in definitions remove it."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bypassed-undefinition
|
|
7
|
+
|
|
8
|
+
This rule reports a top-level `@utility` that also applies where Stillwind
|
|
9
|
+
removes the utility on purpose. Inside animation options, for example,
|
|
10
|
+
`duration-*` sets `animation-duration`, and the built-in definitions remove the
|
|
11
|
+
`transition-duration` meaning there. A top-level `duration-slow` would bring that
|
|
12
|
+
meaning back.
|
|
13
|
+
|
|
14
|
+
## Reported
|
|
15
|
+
|
|
16
|
+
```css
|
|
17
|
+
@utility duration-slow {
|
|
18
|
+
transition-duration: 1s;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> bypassed-undefinition: `@utility duration-slow` also defines `duration-slow` in the `keyframe` registry, where `@stillwind-undef-utility duration-*` removed the earlier definitions
|
|
23
|
+
>
|
|
24
|
+
> Example:1:10
|
|
25
|
+
|
|
26
|
+
## Fixed
|
|
27
|
+
|
|
28
|
+
```css
|
|
29
|
+
@stillwind-registry default {
|
|
30
|
+
@utility duration-slow {
|
|
31
|
+
transition-duration: 1s;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## How to fix
|
|
37
|
+
|
|
38
|
+
Define the utility inside `@stillwind-registry default`, as in the example. Then
|
|
39
|
+
it applies in ordinary `style()` calls, and animation options keep their own
|
|
40
|
+
meaning of `duration-*`.
|
|
41
|
+
|
|
42
|
+
## Rule settings
|
|
43
|
+
|
|
44
|
+
| Preset | Severity |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `recommended` | warn |
|
|
47
|
+
| `strict` | deny |
|
|
48
|
+
| `stylistic` | off |
|
|
49
|
+
|
|
50
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "clamped-value"
|
|
3
|
+
description: "Reports a value outside the range that the browser uses, such as opacity above 1."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# clamped-value
|
|
7
|
+
|
|
8
|
+
This rule reports a literal value outside the range that the browser uses for the
|
|
9
|
+
property. The browser clamps the value to the range, so the extra amount has no
|
|
10
|
+
effect. For example, `opacity-150` behaves the same as `opacity-100`.
|
|
11
|
+
|
|
12
|
+
## Reported
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
style("opacity-150");
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> clamped-value: browsers clamp `opacity: calc(150 * 1%)` to `opacity: 100%`
|
|
19
|
+
>
|
|
20
|
+
> Example:1:16
|
|
21
|
+
|
|
22
|
+
## Fixed
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
style("opacity-100");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## How to fix
|
|
29
|
+
|
|
30
|
+
Use the end of the range that the value reaches, as in the example, or a value
|
|
31
|
+
inside the range.
|
|
32
|
+
|
|
33
|
+
The rule checks values written in the code. It does not check values that a
|
|
34
|
+
custom property receives at runtime.
|
|
35
|
+
|
|
36
|
+
## Rule settings
|
|
37
|
+
|
|
38
|
+
| Preset | Severity |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `recommended` | warn |
|
|
41
|
+
| `strict` | deny |
|
|
42
|
+
| `stylistic` | off |
|
|
43
|
+
|
|
44
|
+
[Configure lint](../configuration.md#lint) to change the severity or options.
|