stillwind 0.1.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -19
- package/css/builtin-utilities/tw-layout.css +2 -2
- package/css/logical/divide.css +67 -0
- package/css/logical/overflow.css +57 -0
- package/css/logical/overscroll.css +40 -0
- package/css/logical/resize.css +19 -0
- package/css/logical/snap.css +20 -0
- package/docs/at-rules/apply.md +1 -1
- package/docs/at-rules/custom-variant.md +3 -3
- package/docs/at-rules/plugin.md +2 -3
- package/docs/at-rules/slot.md +1 -1
- package/docs/at-rules/stillwind-css-template.md +2 -2
- package/docs/at-rules/stillwind-property.md +1 -1
- package/docs/at-rules/stillwind-registry.md +1 -1
- package/docs/at-rules/stillwind-require-properties.md +1 -1
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +1 -1
- package/docs/at-rules/stillwind-undef-utility.md +8 -1
- package/docs/at-rules/stillwind-undef-variant.md +1 -1
- package/docs/at-rules/theme.md +5 -5
- package/docs/at-rules/utility.md +6 -5
- package/docs/at-rules/variant.md +1 -1
- package/docs/cli.md +375 -0
- package/docs/concepts/stylesheets.md +89 -0
- package/docs/configuration.md +44 -6
- package/docs/editors.md +110 -0
- package/docs/errors/SW10002.md +1 -1
- package/docs/formatters.md +87 -0
- package/docs/guides/lint-adoption.md +3 -12
- package/docs/guides/migrating-from-css.md +2 -0
- package/docs/guides/runtime-conditions.md +187 -0
- package/docs/guides/style.md +6 -5
- package/docs/guides/tailwind-compatibility.md +22 -1
- package/docs/guides/web-components.md +29 -0
- package/docs/index.md +6 -4
- package/docs/integrations.md +3 -0
- package/docs/lints/{prefer-explicit-nesting-selector.md → implicit-nesting-selector.md} +3 -3
- package/docs/lints/index.md +44 -43
- package/docs/lints/invalid-runtime-condition.md +2 -1
- package/docs/lints/invalid-utility.md +1 -1
- package/docs/lints/prefer-canonical-utilities.md +21 -4
- package/docs/lints/prefer-logical-properties.md +18 -0
- package/docs/lints/runtime-condition-requires-css-if.md +2 -1
- package/docs/lints/unknown-utility.md +3 -2
- package/docs/lints/unknown-variant.md +1 -1
- package/docs/lints/unmatched-host-selector.md +44 -0
- package/docs/macros/css.md +3 -3
- package/docs/plugins/iconify.md +270 -0
- package/docs/plugins/index.md +26 -0
- package/docs/utilities-and-variants.md +75 -0
- package/docs/why.md +1 -1
- package/package.json +11 -6
- package/skills/migrate-to-stillwind/SKILL.md +3 -1
- package/skills/stillwind/SKILL.md +34 -19
- package/docs/utilities.md +0 -35
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Formatters"
|
|
3
|
+
description: "Sort utilities together with Prettier, Oxfmt, or another document formatter."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Formatters
|
|
7
|
+
|
|
8
|
+
Stillwind sorts utilities, and a document formatter controls layout and whitespace.
|
|
9
|
+
How you combine them depends on the formatter:
|
|
10
|
+
|
|
11
|
+
| Formatter | Setup |
|
|
12
|
+
| ------------------ | ---------------------------------------------------------------------- |
|
|
13
|
+
| Prettier | [The Prettier plugin](#prettier) sorts during formatting |
|
|
14
|
+
| Oxfmt or another | [Run `stillwind fmt` first](#other-formatters), then run the formatter |
|
|
15
|
+
| Any, in the editor | [Code Actions](editors.md#sort-and-fix-on-save) sort on save |
|
|
16
|
+
|
|
17
|
+
All of them read the [`sort` field](configuration.md#sorting) of
|
|
18
|
+
`stillwind.config.ts` and use the same order. Sorting runs whatever the severity of
|
|
19
|
+
[prefer-sorted-utilities](lints/prefer-sorted-utilities.md) is. To stop all
|
|
20
|
+
sorting, set `sort: false`.
|
|
21
|
+
|
|
22
|
+
Create `stillwind.config.ts` with [Getting started](index.md) first.
|
|
23
|
+
|
|
24
|
+
## Prettier
|
|
25
|
+
|
|
26
|
+
`prettier-plugin-stillwind` sorts Stillwind inputs before Prettier formats a
|
|
27
|
+
document. Install it with Prettier 3.7 or a newer 3.x version:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
vp i -D prettier prettier-plugin-stillwind
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```js title="prettier.config.mjs"
|
|
34
|
+
export default {
|
|
35
|
+
plugins: ["prettier-plugin-stillwind"],
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
JavaScript, JSX, TypeScript, TSX, CSS, and Vue work without other plugins. For
|
|
40
|
+
Svelte and Astro, install their Prettier plugins, and load them before the
|
|
41
|
+
Stillwind plugin:
|
|
42
|
+
|
|
43
|
+
```js title="prettier.config.mjs"
|
|
44
|
+
export default {
|
|
45
|
+
plugins: ["prettier-plugin-svelte", "prettier-plugin-astro", "prettier-plugin-stillwind"],
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Configuration
|
|
50
|
+
|
|
51
|
+
The plugin uses the nearest `stillwind.config.*` above each file. The
|
|
52
|
+
`stillwindConfig` Prettier option selects another configuration, with a path
|
|
53
|
+
relative to the working directory. The plugin reloads the configuration for each
|
|
54
|
+
formatting request.
|
|
55
|
+
|
|
56
|
+
A file with no configuration, or outside the `files` of its project, keeps ordinary
|
|
57
|
+
Prettier formatting. An invalid explicit configuration fails the formatting
|
|
58
|
+
request, and so does incomplete or conflicting analysis.
|
|
59
|
+
|
|
60
|
+
### What the plugin changes
|
|
61
|
+
|
|
62
|
+
The plugin only sorts. To replace utilities with their canonical spellings, run
|
|
63
|
+
`stillwind lint --fix`.
|
|
64
|
+
|
|
65
|
+
- `prettier-ignore` protects the following syntax node from sorting.
|
|
66
|
+
- Range formatting protects the source outside the range.
|
|
67
|
+
- Suppression comments control lint findings and fixes, and they do not stop sorting.
|
|
68
|
+
- Sorting keeps the spelling of each token.
|
|
69
|
+
|
|
70
|
+
## Other formatters
|
|
71
|
+
|
|
72
|
+
Run `stillwind fmt` first. It sorts utilities and keeps the source layout, and the
|
|
73
|
+
formatter then controls whitespace:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
vp exec stillwind fmt
|
|
77
|
+
vp exec oxfmt
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
In CI, check both without saving files:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
vp exec stillwind fmt --check
|
|
84
|
+
vp exec oxfmt --check
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
See [the CLI reference](cli.md#stillwind-fmt) for the options of `fmt`.
|
|
@@ -99,18 +99,9 @@ agent or a script reads the results.
|
|
|
99
99
|
|
|
100
100
|
## Check while you edit
|
|
101
101
|
|
|
102
|
-
The
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
```json
|
|
107
|
-
{
|
|
108
|
-
"editor.codeActionsOnSave": {
|
|
109
|
-
"source.fixAll.stillwind": "explicit",
|
|
110
|
-
"source.sort.stillwind": "explicit"
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
```
|
|
102
|
+
The VS Code extension shows findings as you type, including in unsaved files. It also offers the
|
|
103
|
+
automatic fixes as Quick Fixes, and it can fix and sort on save. See [Editors](../editors.md) for
|
|
104
|
+
the setup.
|
|
114
105
|
|
|
115
106
|
## Allow an exception
|
|
116
107
|
|
|
@@ -29,6 +29,8 @@ the reset until the old styles are gone:
|
|
|
29
29
|
@import "stillwind/templates.css";
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
[Stylesheets](../concepts/stylesheets.md) describes each of these files.
|
|
33
|
+
|
|
32
34
|
Stillwind's CSS is in cascade layers. A declaration outside a layer wins over a
|
|
33
35
|
declaration in a layer, whatever their specificity. While an old rule matches an
|
|
34
36
|
element, it overrides the utilities on that element. Remove the old rule when
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Runtime conditions"
|
|
3
|
+
description: "Change utilities and values with a custom property, without changing the classes of an element."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Runtime conditions
|
|
7
|
+
|
|
8
|
+
A runtime condition reads a CSS custom property when the browser computes styles.
|
|
9
|
+
The class list of an element stays the same when the property changes, and the
|
|
10
|
+
property reaches descendants through ordinary CSS inheritance.
|
|
11
|
+
|
|
12
|
+
> **Experimental**
|
|
13
|
+
>
|
|
14
|
+
> Runtime conditions can change between releases. The `if()` variant needs a browser
|
|
15
|
+
> that supports the CSS keyword `revert-rule`, which became Baseline in 2026. Check
|
|
16
|
+
> [Browser support](#browser-support) before you use it.
|
|
17
|
+
|
|
18
|
+
## Write a condition
|
|
19
|
+
|
|
20
|
+
Stillwind has two forms:
|
|
21
|
+
|
|
22
|
+
- The `if()` variant applies a utility when the condition holds.
|
|
23
|
+
- The `--if()` function chooses between two values. It takes a condition, the
|
|
24
|
+
value for a true condition, and the value for a false condition.
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import { style } from "stillwind/react";
|
|
28
|
+
|
|
29
|
+
export function Sidebar({ compact }: { compact: boolean }) {
|
|
30
|
+
return (
|
|
31
|
+
<aside {...style("block w-[--if(--compact,4rem,16rem)]", { "--compact": compact })}>
|
|
32
|
+
<span {...style("if(--compact):hidden")}>Projects</span>
|
|
33
|
+
</aside>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`style()` writes `--compact` on the `<aside>`, and both elements read it. Neither
|
|
39
|
+
element needs a second set of classes for the compact state.
|
|
40
|
+
|
|
41
|
+
## Choose an approach
|
|
42
|
+
|
|
43
|
+
[Style states](style.md#style-states) shows the two approaches that most
|
|
44
|
+
states need:
|
|
45
|
+
|
|
46
|
+
- When an attribute represents the state, such as `disabled` or `aria-expanded`,
|
|
47
|
+
use a variant of that attribute.
|
|
48
|
+
- When one element changes and your component knows the state, pass a JavaScript
|
|
49
|
+
condition to `style()`.
|
|
50
|
+
|
|
51
|
+
Use a runtime condition when a state must reach several elements through CSS.
|
|
52
|
+
|
|
53
|
+
## Set the custom property
|
|
54
|
+
|
|
55
|
+
A condition without a comparison tests a boolean custom property. Pass a boolean in
|
|
56
|
+
`style()`, as in the first example. `true` becomes one space, and `false` becomes
|
|
57
|
+
`initial`. A custom property that no element sets is false.
|
|
58
|
+
|
|
59
|
+
In a stylesheet, write the same values yourself:
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
.compact {
|
|
63
|
+
--compact: ;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.wide {
|
|
67
|
+
--compact: initial;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Other values do not work as booleans. For example, `"true"` and `1` produce invalid
|
|
72
|
+
CSS without `useCssIf`. Do not register a boolean custom property with `@property`,
|
|
73
|
+
because the registration changes its initial value.
|
|
74
|
+
|
|
75
|
+
The browser evaluates the condition on the styled element. To test the state of
|
|
76
|
+
another element, pass that state down with the custom property. A condition inside a
|
|
77
|
+
[ref](../macros/ref/index.md) wrapper is rejected, so write `if()` outside the wrapper.
|
|
78
|
+
|
|
79
|
+
## Combine conditions
|
|
80
|
+
|
|
81
|
+
Variants combine as usual. Repeated `if()` variants must all hold:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
style("if(--compact):if(--docked):hidden hover:if(--compact):w-64");
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`--if()` can stand inside another `--if()` and inside a CSS function:
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
style("w-[--if(--a,--if(--b,30px,20px),10px)] h-[calc(--if(--wide,20,10)*1px)]");
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Each branch must suit the utility. When a utility accepts several types, name the
|
|
94
|
+
type as with other arbitrary values, such as
|
|
95
|
+
`bg-[image:--if(--on,var(--image),none)]`.
|
|
96
|
+
|
|
97
|
+
## Use conditions in CSS
|
|
98
|
+
|
|
99
|
+
The same forms work in your stylesheet:
|
|
100
|
+
|
|
101
|
+
```css
|
|
102
|
+
.panel {
|
|
103
|
+
width: --if(--compact, 4rem, 16rem);
|
|
104
|
+
|
|
105
|
+
@apply grid if(--compact):flex;
|
|
106
|
+
|
|
107
|
+
@variant if(--docked) {
|
|
108
|
+
position: sticky;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Put braces around a branch that contains a top-level comma:
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
.title {
|
|
117
|
+
font-family: --if(--brand, {Arial, sans-serif}, serif);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Enable native CSS if()
|
|
122
|
+
|
|
123
|
+
By default, the compiler expresses conditions with `var()`. The `useCssIf` option
|
|
124
|
+
makes it write the native CSS `if()` function instead, for values and variants:
|
|
125
|
+
|
|
126
|
+
```ts title="stillwind.config.ts"
|
|
127
|
+
import { defineConfig } from "stillwind/config";
|
|
128
|
+
|
|
129
|
+
export default defineConfig({
|
|
130
|
+
projects: [
|
|
131
|
+
{
|
|
132
|
+
css: "./src/stillwind.css",
|
|
133
|
+
files: ["src/**/*.{ts,tsx}"],
|
|
134
|
+
useCssIf: true,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Set this option only when the browsers that you support implement CSS `if()`. These
|
|
141
|
+
forms work only with it:
|
|
142
|
+
|
|
143
|
+
| Form | Example |
|
|
144
|
+
| ------------------------------------------ | ------------------------------------ |
|
|
145
|
+
| Negated variant | `if(!--compact):flex` |
|
|
146
|
+
| Comparison with a value | `if(--mode:compact):flex` |
|
|
147
|
+
| Comparison in `--if()` | `w-[--if(--mode:compact,20px,10px)]` |
|
|
148
|
+
| CSS-wide keyword for a set custom property | `w-[--if(--compact,inherit,10px)]` |
|
|
149
|
+
|
|
150
|
+
> **Negated values work without this option**
|
|
151
|
+
>
|
|
152
|
+
> The compiler swaps the branches of a negated `--if()`, so `--if(!--a,x,y)` does not
|
|
153
|
+
> need `useCssIf`. The restriction on CSS-wide keywords then applies to `y`.
|
|
154
|
+
|
|
155
|
+
A comparison follows the rules of CSS style queries, including any `@property`
|
|
156
|
+
registration of the custom property. A comparison value can contain a comma only
|
|
157
|
+
inside a CSS function or a quoted string.
|
|
158
|
+
|
|
159
|
+
The compiler leaves out a utility that it cannot express. Then
|
|
160
|
+
[runtime-condition-requires-css-if](../lints/runtime-condition-requires-css-if.md)
|
|
161
|
+
reports the utility. In a stylesheet,
|
|
162
|
+
[invalid-runtime-condition](../lints/invalid-runtime-condition.md) reports the
|
|
163
|
+
declaration. A malformed condition reports
|
|
164
|
+
[invalid-variant](../lints/invalid-variant.md) or
|
|
165
|
+
[invalid-utility](../lints/invalid-utility.md).
|
|
166
|
+
|
|
167
|
+
## Browser support
|
|
168
|
+
|
|
169
|
+
The `if()` variant needs `revert-rule`, with or without `useCssIf`. These versions
|
|
170
|
+
are the first to support it:
|
|
171
|
+
|
|
172
|
+
| Browser | Version |
|
|
173
|
+
| ------------ | ------- |
|
|
174
|
+
| Chrome, Edge | 148 |
|
|
175
|
+
| Firefox | 150 |
|
|
176
|
+
| Safari | 27 |
|
|
177
|
+
|
|
178
|
+
The compiler wraps the rule of the variant in `@supports (x:revert-rule)`. An older
|
|
179
|
+
browser skips the rule, and the styles without the variant stay. For example,
|
|
180
|
+
`grid if(--compact):flex` stays `grid` there. Make sure that these styles are usable.
|
|
181
|
+
|
|
182
|
+
`--if()` does not need `revert-rule`, unless a branch contains it. Without `useCssIf`,
|
|
183
|
+
it also works in browsers without CSS `if()`.
|
|
184
|
+
|
|
185
|
+
A custom CSS minifier must keep these `@supports` rules separate. Each rule has a
|
|
186
|
+
generated custom property in its condition, such as `(--iphw2:)`, and merging rules
|
|
187
|
+
with different conditions can remove styles from the page.
|
package/docs/guides/style.md
CHANGED
|
@@ -151,7 +151,8 @@ export function Progress({ value }: { value: number }) {
|
|
|
151
151
|
```
|
|
152
152
|
|
|
153
153
|
The utility `w-(--progress)` stays the same, so its CSS is generated at build
|
|
154
|
-
time. Only the value of `--progress` changes at runtime.
|
|
154
|
+
time. Only the value of `--progress` changes at runtime. To change utilities with
|
|
155
|
+
a custom property, see [Runtime conditions](runtime-conditions.md).
|
|
155
156
|
|
|
156
157
|
## Add classes from other stylesheets
|
|
157
158
|
|
|
@@ -175,7 +176,7 @@ such as state updates or I/O, before you call `style()`.
|
|
|
175
176
|
|
|
176
177
|
## Next steps
|
|
177
178
|
|
|
178
|
-
- [Reusable styles](reusable-styles.md)
|
|
179
|
-
- [Responsive styles](responsive-styles.md)
|
|
180
|
-
- [Checks in the editor and CI](lint-adoption.md)
|
|
181
|
-
- [The style() reference](../macros/style.md)
|
|
179
|
+
- [Reusable styles](reusable-styles.md): how to share styles and define component options
|
|
180
|
+
- [Responsive styles](responsive-styles.md): how to name breakpoints and use them in JavaScript
|
|
181
|
+
- [Checks in the editor and CI](lint-adoption.md): how to find misspelled utilities and other mistakes
|
|
182
|
+
- [The style() reference](../macros/style.md): every accepted input
|
|
@@ -8,7 +8,11 @@ description: "Check which Tailwind CSS v4 features, plugins, and CSS packages wo
|
|
|
8
8
|
Stillwind supports the utilities, variants, theme, CSS directives, and plugins of
|
|
9
9
|
Tailwind CSS v4. To move a project, follow
|
|
10
10
|
[Migrating from Tailwind CSS](migrating-from-tailwind.md). This page
|
|
11
|
-
lists what works, how Stillwind checks it, and where
|
|
11
|
+
lists what works, how Stillwind checks it, what Stillwind adds, and where it differs.
|
|
12
|
+
|
|
13
|
+
For the usage of Tailwind features, see the
|
|
14
|
+
[Tailwind CSS documentation](https://tailwindcss.com/docs). To check the CSS of a
|
|
15
|
+
utility or variant, use [Built-in utilities and variants](../utilities-and-variants.md).
|
|
12
16
|
|
|
13
17
|
## What works
|
|
14
18
|
|
|
@@ -59,6 +63,9 @@ Load these packages with `@plugin`:
|
|
|
59
63
|
| `@headlessui/tailwindcss` | `ui-open:` |
|
|
60
64
|
| `@iconify/tailwind4` | `icon-[lucide--home]` |
|
|
61
65
|
|
|
66
|
+
For Iconify icons, Stillwind also provides the
|
|
67
|
+
[`@stillwind/plugin-iconify`](../plugins/iconify.md) plugin.
|
|
68
|
+
|
|
62
69
|
Load these packages with `@import`:
|
|
63
70
|
|
|
64
71
|
| Package | Example |
|
|
@@ -86,6 +93,20 @@ A plugin can select an element by a fixed class name. For example, the rules of
|
|
|
86
93
|
keeps its name only without variants, so
|
|
87
94
|
[invalid-marker-use](../lints/invalid-marker-use.md) reports `hover:not-prose`.
|
|
88
95
|
|
|
96
|
+
## What Stillwind adds
|
|
97
|
+
|
|
98
|
+
These features have no equivalent in Tailwind CSS:
|
|
99
|
+
|
|
100
|
+
| Feature | Page |
|
|
101
|
+
| --------------------------------------- | --------------------------------------------------------------------------- |
|
|
102
|
+
| `if()` variant and `--if()` function | [Runtime conditions](runtime-conditions.md) |
|
|
103
|
+
| `host:` variant | [Style the shadow host](web-components.md#style-the-shadow-host) |
|
|
104
|
+
| Keyframes defined in a component | [Animations](animations.md) |
|
|
105
|
+
| View transitions defined in a component | [View transitions](view-transitions.md) |
|
|
106
|
+
| Refs to other elements | [Element relationships](element-relationships.md) |
|
|
107
|
+
| Logical properties for axis utilities | [Logical axis utilities](../concepts/stylesheets.md#logical-axis-utilities) |
|
|
108
|
+
| Lint rules | [Checks in the editor and CI](lint-adoption.md) |
|
|
109
|
+
|
|
89
110
|
## What Stillwind does not support
|
|
90
111
|
|
|
91
112
|
These differences come from the design of Stillwind. No setting changes them.
|
|
@@ -202,6 +202,35 @@ the `css` string from `stillwind/module-css`, or create a stylesheet from it wit
|
|
|
202
202
|
`CSSStyleSheet.replaceSync()`. The [style.css() reference](../macros/css.md)
|
|
203
203
|
describes variants that choose their own element and the `template` option.
|
|
204
204
|
|
|
205
|
+
## Style the shadow host
|
|
206
|
+
|
|
207
|
+
`host:` styles the shadow host with the `:host` selector. Use it in `style.css()` to
|
|
208
|
+
style the host and the elements of `selector` in one stylesheet:
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
import { style } from "stillwind/vanilla";
|
|
212
|
+
|
|
213
|
+
export const buttonCss = style.css("p-4 host:block host:hover:bg-gray-100", {
|
|
214
|
+
selector: "button",
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`p-4` styles `button`, and the other utilities style the host.
|
|
219
|
+
|
|
220
|
+
Inside its shadow tree, the host matches only `:host`, `:host()`, and
|
|
221
|
+
`:host-context()`. For this reason, the compiler moves conditions on the host into
|
|
222
|
+
`:host()`. `host:hover:` generates `:host(:hover)`, `hover:` with
|
|
223
|
+
`selector: ":host(.active)"` generates `:host(.active:hover)`, and `@apply hover:flex`
|
|
224
|
+
inside `:host` generates `&:host(:hover)`.
|
|
225
|
+
|
|
226
|
+
A selector in a shadow tree cannot read the elements around the host, so `host:in-*:`
|
|
227
|
+
and `host:group-*:` cannot match.
|
|
228
|
+
[unmatched-host-selector](../lints/unmatched-host-selector.md) reports them.
|
|
229
|
+
|
|
230
|
+
In `style()`, `host:` does not select the element that receives the classes. The
|
|
231
|
+
rule applies to the host of every shadow root that contains the CSS, and
|
|
232
|
+
[document-scoped-selector](../lints/document-scoped-selector.md) reports it.
|
|
233
|
+
|
|
205
234
|
## Constraints
|
|
206
235
|
|
|
207
236
|
- The CSS of a module contains only the styles of that module and the styles
|
package/docs/index.md
CHANGED
|
@@ -124,10 +124,12 @@ Run the CLI in CI to catch such mistakes before you merge them.
|
|
|
124
124
|
|
|
125
125
|
## Next steps
|
|
126
126
|
|
|
127
|
-
- [Why Stillwind](why.md)
|
|
128
|
-
- [The basics of style()](guides/style.md)
|
|
129
|
-
- [Design systems](guides/design-systems.md)
|
|
130
|
-
- [Checks in the editor and CI](guides/lint-adoption.md)
|
|
127
|
+
- [Why Stillwind](why.md): what Stillwind checks and why
|
|
128
|
+
- [The basics of style()](guides/style.md): variants, conditions, and reusable styles
|
|
129
|
+
- [Design systems](guides/design-systems.md): how to restrict colors, spacing, and breakpoints to your theme
|
|
130
|
+
- [Checks in the editor and CI](guides/lint-adoption.md): how to run the checks in CI and the editor
|
|
131
|
+
- [Editors](editors.md): how to install the extension
|
|
132
|
+
- [Formatters](formatters.md): how to sort utilities with your formatter
|
|
131
133
|
|
|
132
134
|
## Set up with an AI agent
|
|
133
135
|
|
package/docs/integrations.md
CHANGED
|
@@ -58,6 +58,9 @@ For Fresh, use Deno 2.9 or newer and register `fresh()` before `stillwind()` fro
|
|
|
58
58
|
`@stillwind/integration/fresh` in the Vite configuration. The adapter keeps server
|
|
59
59
|
and island classes consistent. Fresh's legacy Builder is unsupported.
|
|
60
60
|
|
|
61
|
+
On Linux, and possibly macOS, Fresh development and builds fail with `Bad file descriptor (os error 9)`
|
|
62
|
+
when Stillwind starts the TypeScript checker under Deno.
|
|
63
|
+
|
|
61
64
|
## Vanilla JavaScript
|
|
62
65
|
|
|
63
66
|
Import the DOM helpers with the macro:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
2
|
+
title: "implicit-nesting-selector"
|
|
3
3
|
description: "Reports a custom variant selector without &, which matches descendants."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# implicit-nesting-selector
|
|
7
7
|
|
|
8
8
|
This rule reports a `@custom-variant` selector without `&`. Without `&`, the
|
|
9
9
|
selector matches descendants of the element, not the element itself. In the
|
|
@@ -15,7 +15,7 @@ example, `hocus:` would match hovered elements inside the element.
|
|
|
15
15
|
@custom-variant hocus (:hover);
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
>
|
|
18
|
+
> implicit-nesting-selector: variant selector `:hover` is relative to `&` and means `& :hover`; write the `&`, or add `scope(document)` to the definition to select a document-level element
|
|
19
19
|
>
|
|
20
20
|
> Example:1:24
|
|
21
21
|
|
package/docs/lints/index.md
CHANGED
|
@@ -20,11 +20,11 @@ A utility or variant that these rules report produces no CSS.
|
|
|
20
20
|
|
|
21
21
|
| Rule | Reports | Default |
|
|
22
22
|
| ---------------------------------------------------- | ------------------------------------------------------------- | ------- |
|
|
23
|
-
| [
|
|
23
|
+
| [invalid-marker-use](invalid-marker-use.md) | A marker class such as `group` with a variant or `!` | warn |
|
|
24
24
|
| [invalid-utility](invalid-utility.md) | A known utility written in a form that it does not accept | deny |
|
|
25
|
-
| [unknown-variant](unknown-variant.md) | A variant that your stylesheet does not define | warn |
|
|
26
25
|
| [invalid-variant](invalid-variant.md) | A known variant with an invalid value, such as `min-[foo]:` | deny |
|
|
27
|
-
| [
|
|
26
|
+
| [unknown-utility](unknown-utility.md) | A utility or theme value that your stylesheet does not define | deny |
|
|
27
|
+
| [unknown-variant](unknown-variant.md) | A variant that your stylesheet does not define | deny |
|
|
28
28
|
|
|
29
29
|
## Invalid arguments to Stillwind APIs
|
|
30
30
|
|
|
@@ -33,41 +33,41 @@ report never matches.
|
|
|
33
33
|
|
|
34
34
|
| Rule | Reports | Default |
|
|
35
35
|
| ------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- | ------- |
|
|
36
|
-
| [invalid-
|
|
37
|
-
| [invalid-rule-group-input](invalid-rule-group-input.md) | A `class` field or ref inside a variant key of `style()` | deny |
|
|
38
|
-
| [invalid-style-composition](invalid-style-composition.md) | Inline styles or custom properties in a base style, which do not carry over | deny |
|
|
36
|
+
| [invalid-animation-option](invalid-animation-option.md) | A utility that is not an animation option, such as `p-4` | deny |
|
|
39
37
|
| [invalid-css-input](invalid-css-input.md) | A `style.css()` argument that is not a static utility | deny |
|
|
40
|
-
| [missing-document-target](missing-document-target.md) | A `style.css()` utility without a selector | deny |
|
|
41
|
-
| [invalid-ref-input](invalid-ref-input.md) | A `style.ref()` label or ref method argument that is not a literal | deny |
|
|
42
38
|
| [invalid-cva-config](invalid-cva-config.md) | An unknown or malformed field in a `style.cva()` configuration | deny |
|
|
43
39
|
| [invalid-cva-input](invalid-cva-input.md) | `&&` or a ternary inside a `style.cva()` value | deny |
|
|
44
40
|
| [invalid-keyframes-definition](invalid-keyframes-definition.md) | A frame key that is not a keyframe position, such as `middle` | deny |
|
|
45
|
-
| [invalid-keyframes-variant](invalid-keyframes-variant.md) | A selector or container variant around a keyframes definition | deny |
|
|
46
41
|
| [invalid-keyframes-use](invalid-keyframes-use.md) | An animation applied with an argument that is not an options string | deny |
|
|
47
|
-
| [invalid-
|
|
48
|
-
| [invalid-view-transition-definition](invalid-view-transition-definition.md) | An unknown field in a `style.viewTransition()` definition | deny |
|
|
49
|
-
| [invalid-view-transition-variant](invalid-view-transition-variant.md) | A state or container variant in a view transition definition | deny |
|
|
50
|
-
| [invalid-view-transition-use](invalid-view-transition-use.md) | Extra or invalid arguments to `.for()` | deny |
|
|
42
|
+
| [invalid-keyframes-variant](invalid-keyframes-variant.md) | A selector or container variant around a keyframes definition | deny |
|
|
51
43
|
| [invalid-media-query](invalid-media-query.md) | A condition in `style.media()` that is not a media query, such as `hover` | deny |
|
|
44
|
+
| [invalid-ref-input](invalid-ref-input.md) | A `style.ref()` label or ref method argument that is not a literal | deny |
|
|
45
|
+
| [invalid-rule-group-input](invalid-rule-group-input.md) | A `class` field or ref inside a variant key of `style()` | deny |
|
|
52
46
|
| [invalid-runtime-condition](invalid-runtime-condition.md) | A runtime CSS condition that Stillwind cannot compile | deny |
|
|
47
|
+
| [invalid-style-composition](invalid-style-composition.md) | Inline styles or custom properties in a base style, which do not carry over | deny |
|
|
48
|
+
| [invalid-style-input](invalid-style-input.md) | A `style()` argument that it cannot compile, such as a number | deny |
|
|
49
|
+
| [invalid-view-transition-definition](invalid-view-transition-definition.md) | An unknown field in a `style.viewTransition()` definition | deny |
|
|
50
|
+
| [invalid-view-transition-use](invalid-view-transition-use.md) | Extra or invalid arguments to `.for()` | deny |
|
|
51
|
+
| [invalid-view-transition-variant](invalid-view-transition-variant.md) | A state or container variant in a view transition definition | deny |
|
|
52
|
+
| [missing-document-target](missing-document-target.md) | A `style.css()` utility without a selector | deny |
|
|
53
53
|
| [runtime-condition-requires-css-if](runtime-condition-requires-css-if.md) | A runtime CSS condition that needs `useCssIf` | deny |
|
|
54
54
|
|
|
55
55
|
## Arguments and imports
|
|
56
56
|
|
|
57
57
|
| Rule | Reports | Default |
|
|
58
58
|
| ---------------------------------------------------------------------- | ----------------------------------------------------------- | ------- |
|
|
59
|
+
| [mismatched-framework-import](mismatched-framework-import.md) | An import from the entrypoint of another framework | warn |
|
|
59
60
|
| [mutating-macro-argument](mutating-macro-argument.md) | A state update inside a `style()` argument | deny |
|
|
60
61
|
| [suspending-macro-argument](suspending-macro-argument.md) | `await`, `yield`, or `import()` inside a `style()` argument | deny |
|
|
61
|
-
| [mismatched-framework-import](mismatched-framework-import.md) | An import from the entrypoint of another framework | warn |
|
|
62
62
|
|
|
63
63
|
## Conflicting or duplicated styles
|
|
64
64
|
|
|
65
65
|
| Rule | Reports | Default |
|
|
66
66
|
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------- | ------- |
|
|
67
|
+
| [ambiguous-style-base-order](ambiguous-style-base-order.md) | Two base styles in one call that set the same property | warn |
|
|
68
|
+
| [conflicting-provider-properties](conflicting-provider-properties.md) | A container or anchor property that a ref method and a utility both set | warn |
|
|
67
69
|
| [conflicting-utilities](conflicting-utilities.md) | Utilities that set the same property, such as `p-2 p-4` | warn |
|
|
68
70
|
| [duplicate-utility](duplicate-utility.md) | The same utility twice under the same conditions | warn |
|
|
69
|
-
| [conflicting-provider-properties](conflicting-provider-properties.md) | A container or anchor property that a ref method and a utility both set | warn |
|
|
70
|
-
| [ambiguous-style-base-order](ambiguous-style-base-order.md) | Two base styles in one call that set the same property | warn |
|
|
71
71
|
| [interfering-imported-style-base](interfering-imported-style-base.md) | An imported base style that sets the same property as another style | warn |
|
|
72
72
|
| [unverified-style-base](unverified-style-base.md) | A base style whose origin the CLI cannot determine from its type | warn |
|
|
73
73
|
|
|
@@ -75,29 +75,31 @@ report never matches.
|
|
|
75
75
|
|
|
76
76
|
| Rule | Reports | Default |
|
|
77
77
|
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------- |
|
|
78
|
-
| [
|
|
78
|
+
| [clamped-value](clamped-value.md) | A value outside the range that the browser uses, such as opacity above 1 | warn |
|
|
79
|
+
| [document-scoped-selector](document-scoped-selector.md) | A selector that styles the whole document instead of the element | deny |
|
|
80
|
+
| [duplicate-view-transition-name](duplicate-view-transition-name.md) | Two `.for()` calls in one `style()` call | warn |
|
|
81
|
+
| [incompatible-property-value](incompatible-property-value.md) | A value that the browser rejects for the property | deny |
|
|
79
82
|
| [ineffective-anchor-scope](ineffective-anchor-scope.md) | An empty or repeated ref list in an anchor scope | warn |
|
|
83
|
+
| [missing-ref-attachment](missing-ref-attachment.md) | `asContainer()` or `asAnchor()` in a call that does not attach the ref | warn |
|
|
80
84
|
| [missing-view-transition-name](missing-view-transition-name.md) | A view transition applied without `.for()` | warn |
|
|
81
|
-
| [duplicate-view-transition-name](duplicate-view-transition-name.md) | Two `.for()` calls in one `style()` call | warn |
|
|
82
|
-
| [split-view-transition-class](split-view-transition-class.md) | View transitions split across separate `style()` calls | warn |
|
|
83
|
-
| [document-scoped-selector](document-scoped-selector.md) | A selector that styles the whole document instead of the element | deny |
|
|
84
85
|
| [repeated-nesting-selector](repeated-nesting-selector.md) | A selector that repeats `&` to relate two elements | warn |
|
|
85
|
-
| [
|
|
86
|
-
| [
|
|
86
|
+
| [split-view-transition-class](split-view-transition-class.md) | View transitions split across separate `style()` calls | warn |
|
|
87
|
+
| [unmatched-host-selector](unmatched-host-selector.md) | A variant that tests a shadow host through the elements around it | warn |
|
|
87
88
|
| [unsatisfiable-variants](unsatisfiable-variants.md) | Variants that can never match together, such as `portrait:landscape:` | warn |
|
|
88
89
|
|
|
89
90
|
## Stylesheet definitions
|
|
90
91
|
|
|
91
92
|
| Rule | Reports | Default |
|
|
92
93
|
| ------------------------------------------------------------------------ | ---------------------------------------------------------------- | ------- |
|
|
93
|
-
| [invalid-css-import](invalid-css-import.md) | A stylesheet import that cannot be resolved | deny |
|
|
94
|
-
| [invalid-css-directive](invalid-css-directive.md) | A malformed or unsupported Stillwind directive | deny |
|
|
95
|
-
| [invalid-theme-reference](invalid-theme-reference.md) | A reference to a theme token that is not defined | deny |
|
|
96
|
-
| [incompatible-theme-value](incompatible-theme-value.md) | A theme value of the wrong type, such as a length for a color | deny |
|
|
97
|
-
| [duplicate-definition](duplicate-definition.md) | A utility or variant definition that replaces an earlier one | warn |
|
|
98
94
|
| [bypassed-undefinition](bypassed-undefinition.md) | A definition that bypasses an undefinition in another context | warn |
|
|
95
|
+
| [duplicate-definition](duplicate-definition.md) | A utility or variant definition that replaces an earlier one | warn |
|
|
99
96
|
| [ignored-definition-condition](ignored-definition-condition.md) | A media rule around a definition, which the compiler ignores | deny |
|
|
100
97
|
| [ignored-tailwind-feature](ignored-tailwind-feature.md) | Tailwind-only directives such as `@config`, which have no effect | warn |
|
|
98
|
+
| [implicit-nesting-selector](implicit-nesting-selector.md) | A custom variant selector without `&`, which selects descendants | warn |
|
|
99
|
+
| [incompatible-theme-value](incompatible-theme-value.md) | A theme value of the wrong type, such as a length for a color | deny |
|
|
100
|
+
| [invalid-css-directive](invalid-css-directive.md) | A malformed or unsupported Stillwind directive | deny |
|
|
101
|
+
| [invalid-css-import](invalid-css-import.md) | A stylesheet import that cannot be resolved | deny |
|
|
102
|
+
| [invalid-theme-reference](invalid-theme-reference.md) | A reference to a theme token that is not defined | deny |
|
|
101
103
|
|
|
102
104
|
## Project policies
|
|
103
105
|
|
|
@@ -105,32 +107,31 @@ These rules enforce choices of your project. No preset enables them.
|
|
|
105
107
|
|
|
106
108
|
| Rule | Reports | Default |
|
|
107
109
|
| -------------------------------------------------------------------- | ------------------------------------------------------------- | ------- |
|
|
110
|
+
| [no-arbitrary-breakpoints](no-arbitrary-breakpoints.md) | Viewport widths written as values, such as `min-[713px]:` | off |
|
|
108
111
|
| [no-arbitrary-colors](no-arbitrary-colors.md) | Colors written as values, such as `bg-[#123456]` | off |
|
|
109
112
|
| [no-arbitrary-spacing](no-arbitrary-spacing.md) | Spacing written as values, such as `p-[13px]` | off |
|
|
110
|
-
| [no-
|
|
111
|
-
| [no-
|
|
112
|
-
| [no-restricted-utilities](no-restricted-utilities.md) | The utilities that you list | off |
|
|
113
|
+
| [no-class-property](no-class-property.md) | The `class` field, which adds classes without generated CSS | off |
|
|
114
|
+
| [no-important](no-important.md) | The `!` modifier | off |
|
|
113
115
|
| [no-restricted-declarations](no-restricted-declarations.md) | Utilities that produce the CSS declarations that you list | off |
|
|
114
116
|
| [no-restricted-length-units](no-restricted-length-units.md) | Length units that you forbid for the properties that you list | off |
|
|
115
|
-
| [no-
|
|
116
|
-
| [no-
|
|
117
|
+
| [no-restricted-theme-tokens](no-restricted-theme-tokens.md) | Utilities that use the theme tokens that you list | off |
|
|
118
|
+
| [no-restricted-utilities](no-restricted-utilities.md) | The utilities that you list | off |
|
|
117
119
|
|
|
118
120
|
## Preferred spelling
|
|
119
121
|
|
|
120
122
|
These rules report code that works but has a clearer form. The `stylistic`
|
|
121
123
|
preset enables the rules that are off by default.
|
|
122
124
|
|
|
123
|
-
| Rule
|
|
124
|
-
|
|
|
125
|
-
| [prefer-canonical-utilities](prefer-canonical-utilities.md)
|
|
126
|
-
| [
|
|
127
|
-
| [prefer-
|
|
128
|
-
| [prefer-sorted-utilities](prefer-sorted-utilities.md)
|
|
129
|
-
| [prefer-typed-relationships](prefer-typed-relationships.md)
|
|
130
|
-
| [prefer-
|
|
131
|
-
| [prefer-
|
|
132
|
-
| [
|
|
133
|
-
| [prefer-variant-directive](prefer-variant-directive.md) | A media rule in your CSS that a named variant can replace | off |
|
|
125
|
+
| Rule | Reports | Default |
|
|
126
|
+
| -------------------------------------------------------------------- | ------------------------------------------------------------------------ | ------- |
|
|
127
|
+
| [prefer-canonical-utilities](prefer-canonical-utilities.md) | A utility with a shorter equivalent, such as `px-[16px]` for `px-4` | warn |
|
|
128
|
+
| [prefer-direct-styling](prefer-direct-styling.md) | A selector that styles another element, such as `[&_button]:` | off |
|
|
129
|
+
| [prefer-logical-properties](prefer-logical-properties.md) | A physical property with a logical form, such as `ml-4` | off |
|
|
130
|
+
| [prefer-sorted-utilities](prefer-sorted-utilities.md) | Utilities that are not in sorted order | off |
|
|
131
|
+
| [prefer-typed-relationships](prefer-typed-relationships.md) | `group-*` and `peer-*` variants that a ref can replace | off |
|
|
132
|
+
| [prefer-typed-variables](prefer-typed-variables.md) | A custom property without a type in a utility that accepts several types | off |
|
|
133
|
+
| [prefer-variant-directive](prefer-variant-directive.md) | A media rule in your CSS that a named variant can replace | off |
|
|
134
|
+
| [redundant-variant](redundant-variant.md) | A variant that adds no condition, such as `hover:hover:` | warn |
|
|
134
135
|
|
|
135
136
|
## Suppression comments
|
|
136
137
|
|
|
@@ -54,7 +54,8 @@ export default defineConfig({
|
|
|
54
54
|
|
|
55
55
|
A condition that only needs `useCssIf` is reported by
|
|
56
56
|
[runtime-condition-requires-css-if](runtime-condition-requires-css-if.md)
|
|
57
|
-
instead.
|
|
57
|
+
instead. See [Runtime conditions](../guides/runtime-conditions.md) for the supported
|
|
58
|
+
forms.
|
|
58
59
|
|
|
59
60
|
## Rule settings
|
|
60
61
|
|