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,286 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "@utility"
|
|
3
|
+
description: "Define a utility, or add declarations to a built-in utility with the same name."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @utility
|
|
7
|
+
|
|
8
|
+
```css
|
|
9
|
+
@utility name { ... }
|
|
10
|
+
@utility name-* { ... }
|
|
11
|
+
@utility name (implementation) { ... }
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`@utility` defines a utility for `style()`, `@apply`, and the other places that
|
|
15
|
+
accept utilities. Write it at the top level of the stylesheet.
|
|
16
|
+
|
|
17
|
+
## Static and functional utilities
|
|
18
|
+
|
|
19
|
+
A name without `*` defines a static utility. A name that ends in `-*` defines a
|
|
20
|
+
functional utility, and `--value()` reads the rest of the candidate.
|
|
21
|
+
|
|
22
|
+
### Stylesheet
|
|
23
|
+
|
|
24
|
+
```css
|
|
25
|
+
@utility content-auto {
|
|
26
|
+
content-visibility: auto;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@utility stack-* {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: --spacing(--value(integer));
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Source
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { style } from "stillwind/react";
|
|
40
|
+
|
|
41
|
+
export const list = style("content-auto stack-3");
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Compiled code
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
export const list = {className:"sw_70m3s"};
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Generated stylesheet without preflight
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */
|
|
54
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
55
|
+
@layer properties, theme, base, components, utilities;
|
|
56
|
+
|
|
57
|
+
@layer theme {
|
|
58
|
+
:root, :host {
|
|
59
|
+
--spacing: .25rem;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@layer utilities {
|
|
64
|
+
.sw_70m3s {
|
|
65
|
+
content-visibility: auto;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex-direction: column;
|
|
68
|
+
gap: calc(var(--spacing) * 3);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Values and modifiers
|
|
74
|
+
|
|
75
|
+
`--value()` lists the accepted forms of the value, and the first matching form
|
|
76
|
+
decides. `--modifier()` reads the part after `/` in the same way.
|
|
77
|
+
|
|
78
|
+
| Form | Accepts | Example candidate |
|
|
79
|
+
| -------------- | ------------------------------ | ----------------- |
|
|
80
|
+
| `--tab-size-*` | A token of the namespace | `tab-width-wide` |
|
|
81
|
+
| `integer` | A bare value of the type | `tab-width-2` |
|
|
82
|
+
| `[integer]` | An arbitrary value of the type | `tab-width-[3]` |
|
|
83
|
+
|
|
84
|
+
### Stylesheet
|
|
85
|
+
|
|
86
|
+
```css
|
|
87
|
+
@theme {
|
|
88
|
+
--tab-size-wide: 8;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@utility tab-width-* {
|
|
92
|
+
tab-size: --value(--tab-size-*, integer, [integer]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@utility text-fluid-* {
|
|
96
|
+
font-size: --value(--text-*);
|
|
97
|
+
line-height: --modifier(--leading-*, [length]);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Source
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { style } from "stillwind/react";
|
|
105
|
+
|
|
106
|
+
export const code = style("tab-width-wide text-fluid-lg/tight");
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Compiled code
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
export const code = {className:"sw_9jkuo"};
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Generated stylesheet without preflight
|
|
116
|
+
|
|
117
|
+
```css
|
|
118
|
+
/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */
|
|
119
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
120
|
+
@layer properties, theme, base, components, utilities;
|
|
121
|
+
|
|
122
|
+
@layer theme {
|
|
123
|
+
:root, :host {
|
|
124
|
+
--text-lg: 1.125rem;
|
|
125
|
+
--leading-tight: 1.25;
|
|
126
|
+
--tab-size-wide: 8;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@layer utilities {
|
|
131
|
+
.sw_9jkuo {
|
|
132
|
+
tab-size: var(--tab-size-wide);
|
|
133
|
+
font-size: var(--text-lg);
|
|
134
|
+
line-height: var(--leading-tight);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
A declaration whose `--value()` matches no form is left out. A candidate that
|
|
140
|
+
matches no declaration produces no CSS, and
|
|
141
|
+
[unknown-utility](../lints/unknown-utility.md) reports it.
|
|
142
|
+
|
|
143
|
+
## Definitions with the same name
|
|
144
|
+
|
|
145
|
+
A definition with an existing name adds its declarations to the existing
|
|
146
|
+
utility. It does not replace it. Every definition that accepts the candidate
|
|
147
|
+
contributes, and a later definition wins in the cascade.
|
|
148
|
+
|
|
149
|
+
### Stylesheet
|
|
150
|
+
|
|
151
|
+
```css
|
|
152
|
+
@utility container {
|
|
153
|
+
padding-inline: 1rem;
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Source
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import { style } from "stillwind/react";
|
|
161
|
+
|
|
162
|
+
export const page = style("container");
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Compiled code
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
export const page = {className:"sw_5yksj"};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Generated stylesheet without preflight
|
|
172
|
+
|
|
173
|
+
```css
|
|
174
|
+
/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */
|
|
175
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
176
|
+
@layer properties, theme, base, components, utilities;
|
|
177
|
+
|
|
178
|
+
@layer utilities {
|
|
179
|
+
.sw_5yksj {
|
|
180
|
+
width: 100%;
|
|
181
|
+
padding-inline: 1rem;
|
|
182
|
+
|
|
183
|
+
@media (width >= 40rem) {
|
|
184
|
+
max-width: 40rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
@media (width >= 48rem) {
|
|
188
|
+
max-width: 48rem;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@media (width >= 64rem) {
|
|
192
|
+
max-width: 64rem;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
@media (width >= 80rem) {
|
|
196
|
+
max-width: 80rem;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
@media (width >= 96rem) {
|
|
200
|
+
max-width: 96rem;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
A static definition replaces a functional one for its exact name:
|
|
207
|
+
`@utility shadow-lg { ... }` replaces the built-in `shadow-*` for `shadow-lg`
|
|
208
|
+
only. To remove built-in definitions, use
|
|
209
|
+
[@stillwind-undef-utility](stillwind-undef-utility.md).
|
|
210
|
+
|
|
211
|
+
## Body
|
|
212
|
+
|
|
213
|
+
A body can contain nested rules, `@apply`, `@keyframes`, and `@property`. A
|
|
214
|
+
nested selector without `&` selects descendants: `[data-icon]` means
|
|
215
|
+
`& [data-icon]`. Variants select the utility element, and the nested selector
|
|
216
|
+
applies inside them.
|
|
217
|
+
|
|
218
|
+
The compiler moves `@keyframes` and `@property` rules of a used utility to the
|
|
219
|
+
`keyframes` slot, because browsers ignore them inside a style rule. An unused
|
|
220
|
+
utility adds no such rules.
|
|
221
|
+
|
|
222
|
+
To use a registered custom property, register it with
|
|
223
|
+
[@stillwind-property](stillwind-property.md) and require it with
|
|
224
|
+
[@stillwind-require-properties](stillwind-require-properties.md).
|
|
225
|
+
|
|
226
|
+
## The implementation descriptor
|
|
227
|
+
|
|
228
|
+
`(implementation)` marks the fixed declarations of the body as part of the
|
|
229
|
+
utility's implementation. The `checkImplementation` option of a lint rule decides
|
|
230
|
+
whether the rule checks them:
|
|
231
|
+
|
|
232
|
+
- [prefer-logical-properties](../lints/prefer-logical-properties.md) and
|
|
233
|
+
[no-restricted-length-units](../lints/no-restricted-length-units.md) skip them
|
|
234
|
+
unless the option is `true`. The `em` values below are skipped.
|
|
235
|
+
- [no-important](../lints/no-important.md),
|
|
236
|
+
[no-restricted-declarations](../lints/no-restricted-declarations.md), and
|
|
237
|
+
[no-restricted-theme-tokens](../lints/no-restricted-theme-tokens.md) check them
|
|
238
|
+
unless the option is `false`.
|
|
239
|
+
|
|
240
|
+
### Stylesheet
|
|
241
|
+
|
|
242
|
+
```css
|
|
243
|
+
@utility icon-box (implementation) {
|
|
244
|
+
width: 1em;
|
|
245
|
+
height: 1em;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Source
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { style } from "stillwind/react";
|
|
253
|
+
|
|
254
|
+
export const icon = style("icon-box");
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### Compiled code
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
export const icon = {className:"sw_smxmp"};
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Generated stylesheet without preflight
|
|
264
|
+
|
|
265
|
+
```css
|
|
266
|
+
/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */
|
|
267
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
268
|
+
@layer properties, theme, base, components, utilities;
|
|
269
|
+
|
|
270
|
+
@layer utilities {
|
|
271
|
+
.sw_smxmp {
|
|
272
|
+
width: 1em;
|
|
273
|
+
height: 1em;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Declarations that read the candidate through `--value()` or `--modifier()` are
|
|
279
|
+
still checked.
|
|
280
|
+
|
|
281
|
+
## Conditions
|
|
282
|
+
|
|
283
|
+
A definition inside `@media` or another conditional at-rule keeps its
|
|
284
|
+
declarations, and the compiler ignores the condition.
|
|
285
|
+
[ignored-definition-condition](../lints/ignored-definition-condition.md)
|
|
286
|
+
reports it. Write the condition inside the body instead, or use a variant.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "@variant"
|
|
3
|
+
description: "Apply variants, such as hover or dark, to a block of declarations in a rule of your stylesheet."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @variant
|
|
7
|
+
|
|
8
|
+
```css
|
|
9
|
+
selector {
|
|
10
|
+
@variant variant:sequence, alternative {
|
|
11
|
+
declarations
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`@variant` wraps its block in the rules of the listed variants. Write it inside
|
|
17
|
+
a style rule.
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
### Stylesheet
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
.card {
|
|
25
|
+
background-color: white;
|
|
26
|
+
|
|
27
|
+
@variant hover, focus-within {
|
|
28
|
+
background-color: var(--color-gray-50);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@variant dark:hover {
|
|
32
|
+
background-color: var(--color-gray-800);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Generated stylesheet without preflight
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */
|
|
41
|
+
/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
|
|
42
|
+
@layer properties, theme, base, components, utilities;
|
|
43
|
+
|
|
44
|
+
@layer theme {
|
|
45
|
+
:root, :host {
|
|
46
|
+
--color-gray-50: oklch(98.5% .002 247.839);
|
|
47
|
+
--color-gray-800: oklch(27.8% .033 256.848);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.card {
|
|
52
|
+
background-color: #fff;
|
|
53
|
+
|
|
54
|
+
&:hover {
|
|
55
|
+
@media (hover: hover) {
|
|
56
|
+
background-color: var(--color-gray-50);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
&:focus-within {
|
|
61
|
+
background-color: var(--color-gray-50);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (prefers-color-scheme: dark) {
|
|
65
|
+
&:hover {
|
|
66
|
+
@media (hover: hover) {
|
|
67
|
+
background-color: var(--color-gray-800);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Rules
|
|
75
|
+
|
|
76
|
+
- Each comma-separated sequence receives its own copy of the block.
|
|
77
|
+
- In a sequence, the leftmost variant is the outermost one. `dark:hover` puts
|
|
78
|
+
the `dark` media query around the `:hover` rule.
|
|
79
|
+
- A sequence that does not resolve contributes nothing.
|
|
80
|
+
`@variant nope, print { ... }` keeps only the `print` copy.
|
|
81
|
+
- Nested blocks expand inside the rules of the enclosing sequences.
|
|
82
|
+
- A `@variant` statement without a block stays in the output unchanged.
|
|
83
|
+
|
|
84
|
+
[prefer-variant-directive](../lints/prefer-variant-directive.md) reports an
|
|
85
|
+
`@media` query that a variant of your theme can replace, such as a breakpoint.
|
|
86
|
+
|
|
87
|
+
## Variant definitions
|
|
88
|
+
|
|
89
|
+
At the top level of the stylesheet, a `@variant` block that contains `@slot`
|
|
90
|
+
defines a variant, for compatibility with older Tailwind CSS stylesheets. Use
|
|
91
|
+
[@custom-variant](custom-variant.md) for new definitions.
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "CSS ordering"
|
|
3
|
+
description: "See how Stillwind orders CSS from different files, calls, conditions, variants, and utilities, and how the browser decides which value wins."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CSS ordering
|
|
7
|
+
|
|
8
|
+
This page explains Stillwind's detailed CSS ordering rules for developers debugging
|
|
9
|
+
style conflicts or defining custom utilities and variants. It assumes you already
|
|
10
|
+
use [`style()`](../guides/style.md) and [reusable styles](../guides/reusable-styles.md),
|
|
11
|
+
and know how the CSS cascade works.
|
|
12
|
+
|
|
13
|
+
> **Prefer styles that do not depend on order**
|
|
14
|
+
>
|
|
15
|
+
> Avoid relying on which unrelated rule comes last to make your styles work.
|
|
16
|
+
> When rules do compete, Stillwind tries to put them in the order that authors
|
|
17
|
+
> are most likely to expect.
|
|
18
|
+
|
|
19
|
+
Stillwind chooses the order of generated CSS at build time. A later declaration
|
|
20
|
+
can override an earlier one. The browser can still prefer an earlier declaration
|
|
21
|
+
because of `!important`, cascade layers, or selector specificity.
|
|
22
|
+
|
|
23
|
+
## What affects CSS order
|
|
24
|
+
|
|
25
|
+
In `style(base, "bg-red-600")`, `base` is the result of another `style()` call.
|
|
26
|
+
The new call reuses its classes and adds CSS for the new utilities. Stillwind puts
|
|
27
|
+
the base's CSS first.
|
|
28
|
+
|
|
29
|
+
Read the following table from top to bottom. Stillwind orders files first, then
|
|
30
|
+
calls within each file, then the rules that each call produces:
|
|
31
|
+
|
|
32
|
+
| Step | What Stillwind orders | Which CSS comes first |
|
|
33
|
+
| ---- | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
+
| 1 | Different files | A file that defines a base comes before a file that uses it in `style(base, ...)`. For files without this relationship, Stillwind uses a stable order based on their paths. |
|
|
35
|
+
| 2 | `style()` calls in one file | The base's CSS comes before CSS added by `style(base, ...)`. Other calls follow the order in which they appear in the file. |
|
|
36
|
+
| 3 | JavaScript conditions in one call | CSS without a JavaScript condition comes first. CSS for conditions follows in the order the conditions are written. If conditions are nested, CSS for the outer condition comes before CSS for the inner one. |
|
|
37
|
+
| 4 | CSS variants on one generated class | Rules without variants come first. The stylesheet sets the order of variants, such as `hover:` before `disabled:` or `sm:` before `md:` in the default stylesheet. |
|
|
38
|
+
| 5 | Utilities with the same variants | By default, utilities follow the order of their definitions in the stylesheet, regardless of their order in `style()`. |
|
|
39
|
+
|
|
40
|
+
For example, the variant order in step 4 only applies to rules for the same
|
|
41
|
+
class. It does not move a rule ahead of CSS from an earlier file or call.
|
|
42
|
+
|
|
43
|
+
The default `utilityOrder` setting is `"authored"`. In this mode, utilities from
|
|
44
|
+
plugins come before utilities defined in the stylesheet. Set `utilityOrder` to
|
|
45
|
+
`"tailwind"` to use Tailwind's property order instead. See
|
|
46
|
+
[Configuration](../configuration.md#generated-css).
|
|
47
|
+
|
|
48
|
+
### A base's rules come before the new call's rules
|
|
49
|
+
|
|
50
|
+
Step 2 comes before step 3. All of the base's CSS comes first, including its
|
|
51
|
+
conditional rules. The new call's CSS follows, even if it has no condition:
|
|
52
|
+
|
|
53
|
+
### Source
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { style } from "stillwind/react";
|
|
57
|
+
|
|
58
|
+
declare const active: boolean;
|
|
59
|
+
const base = style("bg-gray-100", active && "bg-blue-600");
|
|
60
|
+
export const danger = style(base, "bg-red-600");
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Compiled code
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { stillwindClassKey, stillwindClsx, stillwindMerge, stillwindToFragment } from "stillwind/runtime/class-name-object";
|
|
67
|
+
|
|
68
|
+
declare const active: boolean;
|
|
69
|
+
const base = {className:stillwindClsx("sw_fnaqw",(active) && ("sw_numny"))};
|
|
70
|
+
export const danger = stillwindMerge({[stillwindClassKey]:"sw_r65in"},stillwindToFragment((base)));
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Generated CSS
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
```css
|
|
77
|
+
.sw_fnaqw {
|
|
78
|
+
background-color: var(--color-gray-100);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.sw_numny {
|
|
82
|
+
background-color: var(--color-blue-600);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.sw_r65in {
|
|
86
|
+
background-color: var(--color-red-600);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The background is red whether `active` is true or false. All three selectors are
|
|
91
|
+
plain classes, and none of the declarations uses `!important`. The red rule wins
|
|
92
|
+
because it comes last. The same rule applies when you import `base` from another
|
|
93
|
+
file.
|
|
94
|
+
|
|
95
|
+
### Within one call, conditional rules come last
|
|
96
|
+
|
|
97
|
+
In this call, the red utility has a JavaScript condition and the blue utility
|
|
98
|
+
does not. Stillwind puts the blue rule first, even though it is written last:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
declare const active: boolean;
|
|
102
|
+
const props = style(active && "bg-red-600", "bg-blue-600");
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
When `active` is false, the element only has the class for blue. When `active`
|
|
106
|
+
is true, it also has the class for red, whose rule comes later. With several
|
|
107
|
+
conditions, a condition written later can override an earlier one when both
|
|
108
|
+
apply, unless specificity or `!important` decides otherwise.
|
|
109
|
+
|
|
110
|
+
### Within one class, the stylesheet orders variants
|
|
111
|
+
|
|
112
|
+
The built-in stylesheet defines the `hover` variant before the `disabled`
|
|
113
|
+
variant. Stillwind follows that definition order when it emits their CSS rules,
|
|
114
|
+
even when the hover utility is written last:
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
const props = style("disabled:bg-gray-300 hover:bg-blue-600");
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
When the element is both hovered and disabled, the disabled background wins.
|
|
121
|
+
Both selectors have the same specificity, and the disabled rule comes last.
|
|
122
|
+
|
|
123
|
+
That variant order does not apply across separate calls. Here the new call's
|
|
124
|
+
hover rule follows the base's disabled rule:
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
const base = style("disabled:bg-gray-300");
|
|
128
|
+
const props = style(base, "hover:bg-blue-600");
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
When both states match, the background is blue. The selectors still have the
|
|
132
|
+
same specificity, but the rule for the second call comes last.
|
|
133
|
+
|
|
134
|
+
## What does not affect CSS order
|
|
135
|
+
|
|
136
|
+
| What you change | What happens |
|
|
137
|
+
| ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
138
|
+
| Reorder utility strings that have no JavaScript condition | Stillwind uses the configured utility order. Splitting a string into arguments does not make the last argument win. |
|
|
139
|
+
| Reorder existing bases in `style(first, second)` | The last argument does not become the winning base. Stillwind orders the calls that defined those bases using steps 1 and 2 above. |
|
|
140
|
+
| Reorder class names on an element | The browser uses the order of declarations in the stylesheet, regardless of the class attribute's order. |
|
|
141
|
+
| Change JavaScript import order, component render order, or which stylesheet finishes downloading first | For the same set of files, the integration keeps the same CSS order. |
|
|
142
|
+
|
|
143
|
+
For example, with the default stylesheet, both calls below produce the same
|
|
144
|
+
padding declarations, and `p-4` wins:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
style("p-2 p-4");
|
|
148
|
+
style("p-4", "p-2");
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
[conflicting-utilities](../lints/conflicting-utilities.md) reports this
|
|
152
|
+
conflict. Remove the unwanted utility instead of rearranging the input.
|
|
153
|
+
|
|
154
|
+
If two base styles set the same property, do not use their argument order to
|
|
155
|
+
choose the winner. Define the overriding style by passing the other style as
|
|
156
|
+
its base:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
const blue = style("bg-blue-600");
|
|
160
|
+
const red = style(blue, "bg-red-600");
|
|
161
|
+
const props = style(red);
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
[ambiguous-style-base-order](../lints/ambiguous-style-base-order.md) and
|
|
165
|
+
[interfering-imported-style-base](../lints/interfering-imported-style-base.md)
|
|
166
|
+
report calls that combine conflicting bases without saying which is built on
|
|
167
|
+
which.
|
|
168
|
+
|
|
169
|
+
## Specificity and `!important`
|
|
170
|
+
|
|
171
|
+
Putting a rule later does not make its selector more specific. For example,
|
|
172
|
+
a base's class with `:hover` is more specific than the new call's plain class:
|
|
173
|
+
|
|
174
|
+
### Source
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import { style } from "stillwind/react";
|
|
178
|
+
|
|
179
|
+
const base = style("bg-blue-600 hover:bg-blue-800");
|
|
180
|
+
export const danger = style(base, "bg-red-600");
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Compiled code
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { stillwindClassKey, stillwindMerge, stillwindToFragment } from "stillwind/runtime/class-name-object";
|
|
187
|
+
|
|
188
|
+
const base = {className:"sw_221vg"};
|
|
189
|
+
export const danger = stillwindMerge({[stillwindClassKey]:"sw_crw5t"},stillwindToFragment((base)));
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Generated CSS
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
```css
|
|
196
|
+
.sw_221vg {
|
|
197
|
+
background-color: var(--color-blue-600);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@media (hover: hover) {
|
|
201
|
+
.sw_221vg:hover {
|
|
202
|
+
background-color: var(--color-blue-800);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.sw_crw5t {
|
|
207
|
+
background-color: var(--color-red-600);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The background is red at rest. On a device that supports hover, it becomes
|
|
212
|
+
blue-800 while hovered: the earlier class with `:hover` beats the later plain
|
|
213
|
+
class. To make the hovered background red too, give the new call its own hover
|
|
214
|
+
rule:
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
export const danger = style(base, "bg-red-600 hover:bg-red-800");
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
A declaration with `!important` beats a normal declaration, even if the normal
|
|
221
|
+
one has a more specific selector. Here the base's blue background wins both at
|
|
222
|
+
rest and on hover, despite the red rules coming later:
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
const base = style("bg-blue-600!");
|
|
226
|
+
const danger = style(base, "bg-red-600 hover:bg-red-800");
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Layer order also comes before specificity. Among layers, the last layer wins
|
|
230
|
+
for normal declarations, and the first layer wins for important declarations.
|
|
231
|
+
The browser uses declaration order only when the earlier rules of the
|
|
232
|
+
[CSS cascade](https://www.w3.org/TR/css-cascade-5/#cascade-sort) leave a tie.
|
|
233
|
+
|
|
234
|
+
To override a shared style, use `style(base, ...)` with the matching variants
|
|
235
|
+
instead of adding `!important`. See [no-important](../lints/no-important.md).
|
|
236
|
+
|
|
237
|
+
## Stylesheet placement
|
|
238
|
+
|
|
239
|
+
The integration keeps this order during development, in production, and in
|
|
240
|
+
server-rendered pages. A production build may combine or move CSS rules when
|
|
241
|
+
doing so does not change which declaration wins.
|
|
242
|
+
|
|
243
|
+
If you combine CSS from separate builds, or place the CSS strings returned by
|
|
244
|
+
[`style.css()`](../macros/css.md) yourself, you choose which stylesheet comes
|
|
245
|
+
first.
|