stillwind 0.5.0 → 0.7.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/docs/at-rules/apply.md +3 -3
- package/docs/at-rules/custom-variant.md +7 -5
- package/docs/at-rules/index.md +28 -28
- package/docs/at-rules/plugin.md +12 -5
- package/docs/at-rules/registry-directives.md +13 -12
- package/docs/at-rules/slot.md +3 -3
- package/docs/at-rules/stillwind-css-template.md +8 -7
- package/docs/at-rules/stillwind-property.md +7 -6
- package/docs/at-rules/stillwind-registry.md +13 -12
- package/docs/at-rules/stillwind-require-properties.md +2 -2
- package/docs/at-rules/stillwind-slot.md +12 -12
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +3 -3
- package/docs/at-rules/stillwind-undef-utility.md +10 -9
- package/docs/at-rules/stillwind-undef-variant.md +5 -5
- package/docs/at-rules/theme.md +6 -6
- package/docs/at-rules/utility.md +17 -12
- package/docs/at-rules/variant.md +11 -7
- package/docs/cli.md +5 -5
- package/docs/concepts/how-styles-compile.md +3 -3
- package/docs/concepts/stylesheets.md +30 -1
- package/docs/configuration.md +8 -8
- package/docs/editors.md +2 -2
- package/docs/errors/SW10004.md +8 -7
- package/docs/errors/SW10005.md +4 -4
- package/docs/errors/SW14002.md +3 -2
- package/docs/errors/SW14003.md +5 -3
- package/docs/errors/SW14004.md +3 -3
- package/docs/errors/SW14005.md +5 -4
- package/docs/errors/SW14008.md +6 -4
- package/docs/errors/SW90001.md +1 -1
- package/docs/errors/SW90006.md +3 -1
- package/docs/errors/index.md +6 -6
- package/docs/guides/animations.md +10 -8
- package/docs/guides/design-systems.md +2 -1
- package/docs/guides/element-relationships.md +17 -15
- package/docs/guides/lint-adoption.md +2 -1
- package/docs/guides/migrating-from-css.md +8 -5
- package/docs/guides/migrating-from-tailwind.md +101 -13
- package/docs/guides/recommended-practices.md +20 -17
- package/docs/guides/responsive-styles.md +9 -6
- package/docs/guides/reusable-styles.md +3 -3
- package/docs/guides/runtime-conditions.md +10 -5
- package/docs/guides/style.md +3 -3
- package/docs/guides/tailwind-compatibility.md +15 -15
- package/docs/guides/view-transitions.md +17 -15
- package/docs/guides/web-components.md +4 -4
- package/docs/index.md +4 -2
- package/docs/integrations.md +64 -0
- package/docs/lints/ambiguous-style-base-order.md +3 -3
- package/docs/lints/bypassed-undefinition.md +4 -4
- package/docs/lints/conflicting-provider-properties.md +4 -3
- package/docs/lints/duplicate-definition.md +2 -1
- package/docs/lints/duplicate-view-transition-name.md +4 -2
- package/docs/lints/ignored-definition-condition.md +4 -3
- package/docs/lints/ignored-tailwind-feature.md +1 -1
- package/docs/lints/implicit-nesting-selector.md +4 -3
- package/docs/lints/index.md +38 -38
- package/docs/lints/ineffective-anchor-scope.md +4 -2
- package/docs/lints/invalid-animation-option.md +3 -3
- package/docs/lints/invalid-css-directive.md +10 -2
- package/docs/lints/invalid-css-import.md +8 -0
- package/docs/lints/invalid-css-input.md +5 -4
- package/docs/lints/invalid-cva-config.md +16 -4
- package/docs/lints/invalid-cva-input.md +11 -6
- package/docs/lints/invalid-keyframes-definition.md +1 -1
- package/docs/lints/invalid-keyframes-variant.md +17 -9
- package/docs/lints/invalid-marker-use.md +1 -1
- package/docs/lints/invalid-media-query.md +8 -6
- package/docs/lints/invalid-ref-input.md +6 -5
- package/docs/lints/invalid-rule-group-input.md +13 -6
- package/docs/lints/invalid-style-input.md +1 -1
- package/docs/lints/invalid-theme-reference.md +2 -2
- package/docs/lints/invalid-view-transition-definition.md +1 -1
- package/docs/lints/invalid-view-transition-use.md +1 -1
- package/docs/lints/invalid-view-transition-variant.md +3 -3
- package/docs/lints/mismatched-framework-import.md +4 -4
- package/docs/lints/missing-document-target.md +1 -1
- package/docs/lints/missing-ref-attachment.md +6 -4
- package/docs/lints/missing-view-transition-name.md +7 -5
- package/docs/lints/no-arbitrary-breakpoints.md +1 -1
- package/docs/lints/no-class-property.md +4 -3
- package/docs/lints/prefer-canonical-utilities.md +3 -2
- package/docs/lints/prefer-direct-styling.md +2 -2
- package/docs/lints/prefer-variant-directive.md +8 -8
- package/docs/lints/split-view-transition-class.md +5 -4
- package/docs/lints/suspending-macro-argument.md +2 -2
- package/docs/lints/unknown-utility.md +2 -1
- package/docs/lints/unknown-variant.md +2 -2
- package/docs/lints/unverified-style-base.md +4 -3
- package/docs/macros/anchor-scope.md +13 -10
- package/docs/macros/css.md +12 -9
- package/docs/macros/cva.md +9 -8
- package/docs/macros/index.md +10 -10
- package/docs/macros/keyframes.md +5 -4
- package/docs/macros/media.md +6 -5
- package/docs/macros/ref/as-anchor.md +12 -7
- package/docs/macros/ref/as-container.md +7 -4
- package/docs/macros/ref/at.md +10 -9
- package/docs/macros/ref/condition.md +1 -1
- package/docs/macros/ref/in.md +6 -6
- package/docs/macros/ref/index.md +11 -11
- package/docs/macros/ref/position-anchor.md +7 -4
- package/docs/macros/style.md +3 -3
- package/docs/macros/view-transition.md +13 -12
- package/docs/plugins/iconify.md +95 -85
- package/docs/plugins/index.md +3 -3
- package/docs/utilities-and-variants.md +4 -4
- package/docs/why.md +2 -2
- package/index.d.ts +2 -0
- package/package.json +31 -5
- package/skills/migrate-to-stillwind/SKILL.md +7 -2
|
@@ -7,7 +7,7 @@ description: "Move a Tailwind CSS v4 project to Stillwind, from the stylesheet a
|
|
|
7
7
|
|
|
8
8
|
You want to move an existing Tailwind CSS v4 project to Stillwind. Your utilities,
|
|
9
9
|
variants, theme, and plugins keep working. What changes is where you write them:
|
|
10
|
-
in `style()` calls instead of `className` strings.
|
|
10
|
+
in [`style()`](style.md) calls instead of `className` strings.
|
|
11
11
|
[Tailwind CSS compatibility](tailwind-compatibility.md) lists the tested
|
|
12
12
|
plugins and the differences.
|
|
13
13
|
|
|
@@ -28,14 +28,21 @@ In your stylesheet, replace `@import "tailwindcss"` with `@import "stillwind"`:
|
|
|
28
28
|
}
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
Keep your `@theme
|
|
32
|
-
`@
|
|
31
|
+
Keep your [`@theme`](../at-rules/theme.md), [`@utility`](../at-rules/utility.md),
|
|
32
|
+
[`@custom-variant`](../at-rules/custom-variant.md), [`@variant`](../at-rules/variant.md),
|
|
33
|
+
[`@apply`](../at-rules/apply.md), and [`@plugin`](../at-rules/plugin.md) rules.
|
|
33
34
|
|
|
34
35
|
Replace the Tailwind build plugin, such as `@tailwindcss/vite`, with the
|
|
35
36
|
Stillwind integration. Then create `stillwind.config.ts`, as described in
|
|
36
37
|
[Getting started](../index.md#configure-the-project), and set up your framework, as
|
|
37
38
|
described in [Framework integrations](../integrations.md).
|
|
38
39
|
|
|
40
|
+
With Tailwind, your code or framework configuration imports the stylesheet, for
|
|
41
|
+
example with `import "./app.css"` or in Starlight's `customCss`. With Vite and the
|
|
42
|
+
frameworks that run on it, remove these imports. The integration reads the
|
|
43
|
+
stylesheet that `css` selects and adds the compiled CSS to the page. If the
|
|
44
|
+
import remains, the page also receives the raw stylesheet.
|
|
45
|
+
|
|
39
46
|
## Move classes into style()
|
|
40
47
|
|
|
41
48
|
Replace each `className` string with a `style()` call that you spread onto the
|
|
@@ -58,14 +65,14 @@ write a one-off codemod for your repository that converts them in one pass.
|
|
|
58
65
|
|
|
59
66
|
## Replace class helpers
|
|
60
67
|
|
|
61
|
-
`style()` and `style.cva()` replace
|
|
62
|
-
build class strings:
|
|
68
|
+
[`style()`](../macros/style.md) and [`style.cva()`](../macros/cva.md) replace
|
|
69
|
+
the libraries that Tailwind projects use to build class strings:
|
|
63
70
|
|
|
64
|
-
| Library
|
|
65
|
-
|
|
|
66
|
-
| `clsx
|
|
67
|
-
| `tailwind-merge`
|
|
68
|
-
| `cva` from
|
|
71
|
+
| Library | Stillwind |
|
|
72
|
+
| ------------------------------------------------------------------------------------------------- | ----------------------------------------- |
|
|
73
|
+
| [`clsx`](https://github.com/lukeed/clsx), [`classnames`](https://github.com/JedWatson/classnames) | `style()` with conditions |
|
|
74
|
+
| [`tailwind-merge`](https://github.com/dcastil/tailwind-merge) | Compose a base with new utilities |
|
|
75
|
+
| `cva` from [Class Variance Authority](https://cva.style/) | `style.cva()` with the same configuration |
|
|
69
76
|
|
|
70
77
|
### clsx and classnames
|
|
71
78
|
|
|
@@ -123,8 +130,8 @@ export function Button({ tone }: VariantProps<typeof button>) {
|
|
|
123
130
|
`variants`, `defaultVariants`, and `compoundVariants` work as in
|
|
124
131
|
class-variance-authority. Write each option value as a plain utility string,
|
|
125
132
|
without `&&` or a ternary. The props that the factory returns cannot be passed
|
|
126
|
-
to `style()` as a base. The [style.cva() reference](../macros/cva.md) lists
|
|
127
|
-
other differences.
|
|
133
|
+
to `style()` as a base. The [`style.cva()` reference](../macros/cva.md) lists
|
|
134
|
+
the other differences.
|
|
128
135
|
|
|
129
136
|
For new components, consider state variants and `data-*` attributes instead of
|
|
130
137
|
options. See [Reusable styles](reusable-styles.md).
|
|
@@ -176,4 +183,85 @@ lists the packages that the test suite covers.
|
|
|
176
183
|
|
|
177
184
|
Run the [CLI checks](lint-adoption.md) over the migrated files. They
|
|
178
185
|
report utilities that Stillwind cannot resolve and Tailwind features that it
|
|
179
|
-
ignores. Then test the production build and your pages
|
|
186
|
+
ignores. Then test the production build, and compare your pages with the old
|
|
187
|
+
version as described in the next section.
|
|
188
|
+
|
|
189
|
+
### Compare computed styles
|
|
190
|
+
|
|
191
|
+
A successful build and clean CLI checks do not prove that the pages look the
|
|
192
|
+
same. For example, a class outside `style()` gets no CSS, and no check reports
|
|
193
|
+
it. A diff of the generated CSS or HTML does not help either, because Stillwind
|
|
194
|
+
renames the classes and reorders the rules. Instead, compare the computed styles
|
|
195
|
+
of the migrated components in a build from before the migration and a build from
|
|
196
|
+
after it. The test suite checks plugins in the same way, as
|
|
197
|
+
[Tailwind CSS compatibility](tailwind-compatibility.md#how-stillwind-checks-compatibility)
|
|
198
|
+
describes.
|
|
199
|
+
|
|
200
|
+
1. Build the project before and after the migration, and serve both builds.
|
|
201
|
+
2. Open the same page in both builds, with the same viewport size, theme, and
|
|
202
|
+
other state.
|
|
203
|
+
3. In each build, run the following function in the browser console. Pass a
|
|
204
|
+
selector that matches the root elements of the migrated components. In
|
|
205
|
+
Chrome DevTools, `copy(await snapshotStyles(".card"))` copies the result.
|
|
206
|
+
4. Save the two results to files, and compare them with a diff tool, such as
|
|
207
|
+
`git diff --no-index before.txt after.txt`.
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
async function snapshotStyles(rootSelector) {
|
|
211
|
+
await document.fonts.ready;
|
|
212
|
+
// Finishing a transition can start another one in a descendant that
|
|
213
|
+
// inherits the value, so repeat until no animation runs.
|
|
214
|
+
for (let round = 0; round < 20; round++) {
|
|
215
|
+
document.documentElement.getBoundingClientRect();
|
|
216
|
+
const running = document
|
|
217
|
+
.getAnimations()
|
|
218
|
+
.filter((animation) => animation.playState === "running");
|
|
219
|
+
if (running.length === 0) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
for (const animation of running) {
|
|
223
|
+
if (animation.effect.getComputedTiming().endTime === Infinity) {
|
|
224
|
+
animation.pause();
|
|
225
|
+
animation.currentTime = 0;
|
|
226
|
+
} else {
|
|
227
|
+
animation.finish();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
const lines = [];
|
|
232
|
+
document.querySelectorAll(rootSelector).forEach((root, rootIndex) => {
|
|
233
|
+
[root, ...root.querySelectorAll("*")].forEach((element, index) => {
|
|
234
|
+
for (const pseudo of ["", "::before", "::after"]) {
|
|
235
|
+
const style = getComputedStyle(element, pseudo);
|
|
236
|
+
if (pseudo && style.content === "none") {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
for (const name of [...style].filter((name) => !name.startsWith("--")).sort()) {
|
|
240
|
+
const value = style.getPropertyValue(name);
|
|
241
|
+
lines.push(`${rootIndex}.${index} ${element.localName}${pseudo} ${name}: ${value}`);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
return lines.join("\n");
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Each line of the result contains the position of the element, the element or
|
|
251
|
+
pseudo-element, and one property with its value. The function finishes running
|
|
252
|
+
transitions and animations, and stops infinite animations at their start, so
|
|
253
|
+
a theme change just before the call does not leave intermediate values. It
|
|
254
|
+
skips custom properties, because their names usually change in a migration.
|
|
255
|
+
|
|
256
|
+
Repeat the comparison for each theme and for each breakpoint that the project
|
|
257
|
+
uses. Then review the differences:
|
|
258
|
+
|
|
259
|
+
- Some differences do not change the look. For example, when you move a margin
|
|
260
|
+
from one element to its neighbor, the lines of both elements differ, but the
|
|
261
|
+
layout stays the same.
|
|
262
|
+
- The function reads only the current state. To compare states such as `:hover`
|
|
263
|
+
and `:focus-visible`, force the state in the browser's developer tools, or
|
|
264
|
+
hover and focus the element with a browser automation tool such as Playwright.
|
|
265
|
+
- The function matches elements by their order inside each root. When the
|
|
266
|
+
migration adds or removes an element, the lines that follow it no longer
|
|
267
|
+
match, so compare that part by hand.
|
|
@@ -10,8 +10,8 @@ It also lists the mistakes that silently produce no CSS. The examples use React.
|
|
|
10
10
|
|
|
11
11
|
## Keep styles next to their elements
|
|
12
12
|
|
|
13
|
-
Write the utilities in a `style()` call on the element that
|
|
14
|
-
several places need the same styles, reuse them in this order:
|
|
13
|
+
Write the utilities in a [`style()`](style.md) call on the element that
|
|
14
|
+
they style. When several places need the same styles, reuse them in this order:
|
|
15
15
|
|
|
16
16
|
1. Extract a component of your framework, and keep the `style()` call on its
|
|
17
17
|
element. The styles stay next to the markup that they depend on.
|
|
@@ -74,8 +74,8 @@ for what the application needs.
|
|
|
74
74
|
|
|
75
75
|
When an element's style depends on another element, such as a hovered parent, a
|
|
76
76
|
sibling, a container, or an anchor, connect them with a ref from
|
|
77
|
-
`style.ref()
|
|
78
|
-
parent and sibling selectors:
|
|
77
|
+
[`style.ref()`](../macros/ref/index.md). Do not use `group-*`, `peer-*`, named
|
|
78
|
+
containers, or hand-written parent and sibling selectors:
|
|
79
79
|
|
|
80
80
|
```tsx
|
|
81
81
|
import { style } from "stillwind/react";
|
|
@@ -97,11 +97,14 @@ containers, and anchors.
|
|
|
97
97
|
|
|
98
98
|
## Define animations in their components
|
|
99
99
|
|
|
100
|
-
Define keyframes with [style.keyframes()](../macros/keyframes.md) and view
|
|
101
|
-
transitions with [style.viewTransition()](../macros/view-transition.md) in
|
|
102
|
-
code that uses them. Do not add global
|
|
103
|
-
`
|
|
104
|
-
|
|
100
|
+
Define keyframes with [`style.keyframes()`](../macros/keyframes.md) and view
|
|
101
|
+
transitions with [`style.viewTransition()`](../macros/view-transition.md) in
|
|
102
|
+
the code that uses them. Do not add global
|
|
103
|
+
[`@keyframes`](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@keyframes)
|
|
104
|
+
rules or fixed
|
|
105
|
+
[`view-transition-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/view-transition-name)
|
|
106
|
+
values. The macros generate unique names, so you can add, move, or remove a
|
|
107
|
+
component without checking other code.
|
|
105
108
|
|
|
106
109
|
## Declare refs and animations in the smallest scope
|
|
107
110
|
|
|
@@ -219,8 +222,8 @@ from a long string.
|
|
|
219
222
|
|
|
220
223
|
## Keep values in the theme
|
|
221
224
|
|
|
222
|
-
Define colors, spacing, and breakpoints as `@theme` tokens, and
|
|
223
|
-
utilities that they add. Avoid arbitrary values such as `text-[#abcdef]` and
|
|
225
|
+
Define colors, spacing, and breakpoints as [`@theme`](../at-rules/theme.md) tokens, and
|
|
226
|
+
use the utilities that they add. Avoid arbitrary values such as `text-[#abcdef]` and
|
|
224
227
|
`max-[768px]:`. [Design systems](design-systems.md) enables lint
|
|
225
228
|
rules that report them.
|
|
226
229
|
|
|
@@ -258,7 +261,7 @@ Set `data-theme` on the root element, or on a container to theme part of the
|
|
|
258
261
|
page. The utilities, such as `bg-surface`, stay the same in every theme.
|
|
259
262
|
|
|
260
263
|
When a theme needs styles beyond its tokens, define a variant for it with
|
|
261
|
-
[
|
|
264
|
+
[`@custom-variant`](../at-rules/custom-variant.md), and use the variant instead
|
|
262
265
|
of a hand-written selector:
|
|
263
266
|
|
|
264
267
|
```css
|
|
@@ -268,7 +271,7 @@ of a hand-written selector:
|
|
|
268
271
|
## Use breakpoints from the theme in JavaScript
|
|
269
272
|
|
|
270
273
|
When JavaScript needs a breakpoint, get its media query with
|
|
271
|
-
[style.media()](../macros/media.md) instead of repeating the value:
|
|
274
|
+
[`style.media()`](../macros/media.md) instead of repeating the value:
|
|
272
275
|
|
|
273
276
|
```ts
|
|
274
277
|
import { style } from "stillwind/react";
|
|
@@ -282,8 +285,8 @@ change. [Responsive styles](responsive-styles.md) shows more uses.
|
|
|
282
285
|
|
|
283
286
|
## Define utilities with @apply
|
|
284
287
|
|
|
285
|
-
Write the body of a custom utility with `@apply
|
|
286
|
-
variants:
|
|
288
|
+
Write the body of a custom utility with [`@apply`](../at-rules/apply.md), and
|
|
289
|
+
write its conditions as variants:
|
|
287
290
|
|
|
288
291
|
```css
|
|
289
292
|
@utility link {
|
|
@@ -295,14 +298,14 @@ Do not write selectors or media queries by hand. The variants follow your
|
|
|
295
298
|
theme, and they avoid differences that are easy to miss. For example, the
|
|
296
299
|
`hover:` variant applies only on devices that can hover, while a plain `:hover`
|
|
297
300
|
rule stays active after a tap on a touch screen. Inside a style rule, use
|
|
298
|
-
[
|
|
301
|
+
[`@variant`](../at-rules/variant.md) instead of a condition.
|
|
299
302
|
|
|
300
303
|
## Avoid separate CSS
|
|
301
304
|
|
|
302
305
|
Write styles in `style()` calls and custom utilities, not in CSS files with
|
|
303
306
|
your own class names. A custom utility works with every variant, such as
|
|
304
307
|
`hover:link`, and a fixed class name does not. For a reusable condition, define
|
|
305
|
-
a variant with [
|
|
308
|
+
a variant with [`@custom-variant`](../at-rules/custom-variant.md) instead of
|
|
306
309
|
writing its selector in several rules.
|
|
307
310
|
|
|
308
311
|
For HTML that you do not control, such as rendered Markdown, define the styles
|
|
@@ -52,13 +52,14 @@ export function Layout() {
|
|
|
52
52
|
|
|
53
53
|
## Use breakpoints in authored CSS
|
|
54
54
|
|
|
55
|
-
In a CSS rule, nest `@variant` with the breakpoint name,
|
|
56
|
-
rule above. In an `@utility`
|
|
57
|
-
|
|
55
|
+
In a CSS rule, nest [`@variant`](../at-rules/variant.md) with the breakpoint name,
|
|
56
|
+
as in the `.navigation` rule above. In an [`@utility`](../at-rules/utility.md)
|
|
57
|
+
definition, use the variant in [`@apply`](../at-rules/apply.md) instead, such as
|
|
58
|
+
`@apply inline:flex-row`.
|
|
58
59
|
|
|
59
60
|
## Use breakpoints in JavaScript
|
|
60
61
|
|
|
61
|
-
`style.media()` returns the media query for a breakpoint name:
|
|
62
|
+
[`style.media()`](../macros/media.md) returns the media query for a breakpoint name:
|
|
62
63
|
|
|
63
64
|
```ts
|
|
64
65
|
import { style } from "stillwind/react";
|
|
@@ -76,8 +77,10 @@ export function dispose() {
|
|
|
76
77
|
```
|
|
77
78
|
|
|
78
79
|
The compiler replaces `style.media("sidebar")` with the query string, so the
|
|
79
|
-
JavaScript always matches the CSS.
|
|
80
|
-
|
|
80
|
+
JavaScript always matches the CSS.
|
|
81
|
+
[`matchMedia()`](https://developer.mozilla.org/docs/Web/API/Window/matchMedia)
|
|
82
|
+
is a browser API, so call it on the client. Remove the listener when its
|
|
83
|
+
component unmounts.
|
|
81
84
|
|
|
82
85
|
To combine conditions, write them in one argument. To accept alternatives, pass
|
|
83
86
|
several arguments:
|
|
@@ -12,8 +12,8 @@ which styles apply.
|
|
|
12
12
|
|
|
13
13
|
## Share a base style
|
|
14
14
|
|
|
15
|
-
Store a `style()` result, and pass it to other `style()`
|
|
16
|
-
the base and import it in other modules:
|
|
15
|
+
Store a [`style()`](style.md) result, and pass it to other `style()`
|
|
16
|
+
calls. You can export the base and import it in other modules:
|
|
17
17
|
|
|
18
18
|
```tsx
|
|
19
19
|
import { style } from "stillwind/react";
|
|
@@ -107,4 +107,4 @@ set a custom property instead. See
|
|
|
107
107
|
`style.cva()` accepts the configuration of `cva` from class-variance-authority.
|
|
108
108
|
Use it to migrate existing CVA components. See
|
|
109
109
|
[Replace class helpers](migrating-from-tailwind.md#replace-class-helpers)
|
|
110
|
-
and the [style.cva() reference](../macros/cva.md).
|
|
110
|
+
and the [`style.cva()` reference](../macros/cva.md).
|
|
@@ -12,8 +12,10 @@ property reaches descendants through ordinary CSS inheritance.
|
|
|
12
12
|
> **Experimental**
|
|
13
13
|
>
|
|
14
14
|
> Runtime conditions can change between releases. The `if()` variant needs a browser
|
|
15
|
-
> that supports the CSS keyword
|
|
16
|
-
> [
|
|
15
|
+
> that supports the CSS keyword
|
|
16
|
+
> [`revert-rule`](https://developer.mozilla.org/docs/Web/CSS/Reference/Values/revert-rule),
|
|
17
|
+
> which became Baseline in 2026. Check [Browser support](#browser-support)
|
|
18
|
+
> before you use it.
|
|
17
19
|
|
|
18
20
|
## Write a condition
|
|
19
21
|
|
|
@@ -69,7 +71,8 @@ In a stylesheet, write the same values yourself:
|
|
|
69
71
|
```
|
|
70
72
|
|
|
71
73
|
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
|
|
74
|
+
CSS without `useCssIf`. Do not register a boolean custom property with
|
|
75
|
+
[`@property`](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@property),
|
|
73
76
|
because the registration changes its initial value.
|
|
74
77
|
|
|
75
78
|
The browser evaluates the condition on the styled element. To test the state of
|
|
@@ -120,8 +123,10 @@ Put braces around a branch that contains a top-level comma:
|
|
|
120
123
|
|
|
121
124
|
## Enable native CSS if()
|
|
122
125
|
|
|
123
|
-
By default, the compiler expresses conditions with `var()`. The `useCssIf`
|
|
124
|
-
makes it write the native CSS
|
|
126
|
+
By default, the compiler expresses conditions with `var()`. The `useCssIf`
|
|
127
|
+
option makes it write the native CSS
|
|
128
|
+
[`if()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Values/if)
|
|
129
|
+
function instead, for values and variants:
|
|
125
130
|
|
|
126
131
|
```ts title="stillwind.config.ts"
|
|
127
132
|
import { defineConfig } from "stillwind/config";
|
package/docs/guides/style.md
CHANGED
|
@@ -29,8 +29,8 @@ The compiler reads the utilities at build time and generates their CSS.
|
|
|
29
29
|
In React, `style()` returns a `className` prop.
|
|
30
30
|
|
|
31
31
|
Utilities and variants come from the stylesheet that `stillwind.config.ts`
|
|
32
|
-
selects. A token that you add to `@theme` adds utilities,
|
|
33
|
-
for `--color-accent`.
|
|
32
|
+
selects. A token that you add to [`@theme`](../at-rules/theme.md) adds utilities,
|
|
33
|
+
such as `bg-accent` for `--color-accent`.
|
|
34
34
|
|
|
35
35
|
## Add variants
|
|
36
36
|
|
|
@@ -179,4 +179,4 @@ such as state updates or I/O, before you call `style()`.
|
|
|
179
179
|
- [Reusable styles](reusable-styles.md): how to share styles and define component options
|
|
180
180
|
- [Responsive styles](responsive-styles.md): how to name breakpoints and use them in JavaScript
|
|
181
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
|
|
182
|
+
- [The `style()` reference](../macros/style.md): every accepted input
|
|
@@ -16,17 +16,17 @@ utility or variant, use [Built-in utilities and variants](../utilities-and-varia
|
|
|
16
16
|
|
|
17
17
|
## What works
|
|
18
18
|
|
|
19
|
-
| Tailwind feature
|
|
20
|
-
|
|
|
21
|
-
| Default theme and preflight
|
|
22
|
-
| Utilities and variants
|
|
23
|
-
| `@theme
|
|
24
|
-
| `@apply
|
|
25
|
-
| `--theme()`, `--spacing()`, `--alpha()`
|
|
26
|
-
| `theme(--color-red-500)`
|
|
27
|
-
| `@plugin` with JavaScript plugins
|
|
28
|
-
| `@import` of CSS packages
|
|
29
|
-
| Tailwind configuration
|
|
19
|
+
| Tailwind feature | Support |
|
|
20
|
+
| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
|
|
21
|
+
| Default theme and preflight | Included in `@import "stillwind"` |
|
|
22
|
+
| Utilities and variants | Supported, including arbitrary values, modifiers, and `!` |
|
|
23
|
+
| [`@theme`](../at-rules/theme.md), [`@utility`](../at-rules/utility.md), [`@custom-variant`](../at-rules/custom-variant.md) | Supported |
|
|
24
|
+
| [`@apply`](../at-rules/apply.md), [`@variant`](../at-rules/variant.md) | Supported |
|
|
25
|
+
| `--theme()`, `--spacing()`, `--alpha()` | Supported |
|
|
26
|
+
| `theme(--color-red-500)` | Supported; v3 paths such as `theme(colors.red.500)` are not |
|
|
27
|
+
| [`@plugin`](../at-rules/plugin.md) with JavaScript plugins | Supported; see [Plugins and CSS packages](#plugins-and-css-packages) |
|
|
28
|
+
| `@import` of CSS packages | Supported; see [Plugins and CSS packages](#plugins-and-css-packages) |
|
|
29
|
+
| Tailwind configuration | Set the `tailwind` field of the project in `stillwind.config.ts` |
|
|
30
30
|
|
|
31
31
|
## How Stillwind checks compatibility
|
|
32
32
|
|
|
@@ -77,7 +77,7 @@ Load these packages with `@import`:
|
|
|
77
77
|
| `tailwind-scrollbar-hide/v4` | `scrollbar-hide` |
|
|
78
78
|
| `preline/variants.css` | `hs-dropdown-open:` |
|
|
79
79
|
|
|
80
|
-
Other plugins can use the same features. [
|
|
80
|
+
Other plugins can use the same features. [`@plugin`](../at-rules/plugin.md#tailwind-css-plugins)
|
|
81
81
|
lists the supported plugin API. JavaScript plugins need the `tailwindcss` package,
|
|
82
82
|
and CSS packages do not.
|
|
83
83
|
|
|
@@ -88,9 +88,9 @@ these combinations in your application.
|
|
|
88
88
|
### Class names that a plugin's selectors use
|
|
89
89
|
|
|
90
90
|
A plugin can select an element by a fixed class name. For example, the rules of
|
|
91
|
-
`prose` skip elements inside `not-prose`. `style()` keeps
|
|
92
|
-
`class` attribute, so `style("not-prose")` adds the class
|
|
93
|
-
keeps its name only without variants, so
|
|
91
|
+
`prose` skip elements inside `not-prose`. [`style()`](style.md) keeps
|
|
92
|
+
such a class in the `class` attribute, so `style("not-prose")` adds the class
|
|
93
|
+
`not-prose`. The class keeps its name only without variants, so
|
|
94
94
|
[invalid-marker-use](../lints/invalid-marker-use.md) reports `hover:not-prose`.
|
|
95
95
|
|
|
96
96
|
## What Stillwind adds
|
|
@@ -6,10 +6,12 @@ description: "Style view transition snapshots in the component, and give each it
|
|
|
6
6
|
# View transitions
|
|
7
7
|
|
|
8
8
|
You want an item to animate between two states of the page with the browser's
|
|
9
|
-
View Transition API.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
[View Transition API](https://developer.mozilla.org/docs/Web/API/View_Transition_API).
|
|
10
|
+
In plain CSS, you write
|
|
11
|
+
[`view-transition-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/view-transition-name)
|
|
12
|
+
and the `::view-transition-*` rules in a global stylesheet, and you keep every
|
|
13
|
+
name unique by hand. In Stillwind, you define the transition in the component
|
|
14
|
+
and name each item with a key.
|
|
13
15
|
|
|
14
16
|
## Define the transition and name each item
|
|
15
17
|
|
|
@@ -26,15 +28,15 @@ export function Product({ id, name }: { id: string; name: string }) {
|
|
|
26
28
|
}
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
`style.viewTransition()` defines the styles of
|
|
30
|
-
one pseudo-element:
|
|
31
|
+
[`style.viewTransition()`](../macros/view-transition.md) defines the styles of
|
|
32
|
+
the snapshots. Each field styles one pseudo-element:
|
|
31
33
|
|
|
32
|
-
| Field | Pseudo-element
|
|
33
|
-
| ----------- |
|
|
34
|
-
| `group` | `::view-transition-group()`
|
|
35
|
-
| `imagePair` | `::view-transition-image-pair()` |
|
|
36
|
-
| `old` | `::view-transition-old()`
|
|
37
|
-
| `new` | `::view-transition-new()`
|
|
34
|
+
| Field | Pseudo-element |
|
|
35
|
+
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
36
|
+
| `group` | [`::view-transition-group()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/::view-transition-group) |
|
|
37
|
+
| `imagePair` | [`::view-transition-image-pair()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/::view-transition-image-pair) |
|
|
38
|
+
| `old` | [`::view-transition-old()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/::view-transition-old) |
|
|
39
|
+
| `new` | [`::view-transition-new()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Selectors/::view-transition-new) |
|
|
38
40
|
|
|
39
41
|
Timing utilities in these fields set animation properties. For example,
|
|
40
42
|
`duration-150` sets `animation-duration`.
|
|
@@ -62,8 +64,8 @@ the View Transition API run the update without animation.
|
|
|
62
64
|
|
|
63
65
|
## Give each element one name
|
|
64
66
|
|
|
65
|
-
Use `.for()` once for each element, in one `style()` call.
|
|
66
|
-
transitions on one element, pass the others without `.for()`:
|
|
67
|
+
Use `.for()` once for each element, in one [`style()`](style.md) call.
|
|
68
|
+
To combine several transitions on one element, pass the others without `.for()`:
|
|
67
69
|
|
|
68
70
|
```tsx
|
|
69
71
|
import { style } from "stillwind/react";
|
|
@@ -80,5 +82,5 @@ The CLI reports a `style()` call that applies a transition without `.for()`, a
|
|
|
80
82
|
call with two `.for()` calls, and transitions split across separate `style()`
|
|
81
83
|
calls. It cannot check that keys are unique across the whole page.
|
|
82
84
|
|
|
83
|
-
The [style.viewTransition() reference](../macros/view-transition.md) covers
|
|
85
|
+
The [`style.viewTransition()` reference](../macros/view-transition.md) covers
|
|
84
86
|
dynamic keys and the generated CSS.
|
|
@@ -41,9 +41,9 @@ import { css, parts } from "stillwind/module-css";
|
|
|
41
41
|
```
|
|
42
42
|
|
|
43
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
|
|
45
|
-
those calls compose from other modules. It also contains the
|
|
46
|
-
preflight reset, and the other rules of your stylesheet.
|
|
44
|
+
contains the styles of the [`style()`](style.md) calls in that module
|
|
45
|
+
and the styles that those calls compose from other modules. It also contains the
|
|
46
|
+
theme values, the preflight reset, and the other rules of your stylesheet.
|
|
47
47
|
|
|
48
48
|
The import provides the CSS in two forms:
|
|
49
49
|
|
|
@@ -199,7 +199,7 @@ The `selector` option chooses the element that the utilities style. The string
|
|
|
199
199
|
contains the theme values and keyframes that its utilities need, and it adds
|
|
200
200
|
nothing to the page's stylesheet. Add it to the shadow root in the same way as
|
|
201
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)
|
|
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
205
|
## Style the shadow host
|
package/docs/index.md
CHANGED
|
@@ -39,8 +39,8 @@ Create `src/stillwind.css`:
|
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
`@import "stillwind"` loads the default Tailwind CSS v4 theme and utilities.
|
|
42
|
-
Each token in `@theme` adds utilities. For example,
|
|
43
|
-
`bg-accent` and `text-accent`.
|
|
42
|
+
Each token in [`@theme`](at-rules/theme.md) adds utilities. For example,
|
|
43
|
+
`--color-accent` adds `bg-accent` and `text-accent`.
|
|
44
44
|
|
|
45
45
|
## Configure the project
|
|
46
46
|
|
|
@@ -82,6 +82,8 @@ export default defineConfig({
|
|
|
82
82
|
|
|
83
83
|
Place `stillwind()` before `react()`. Stillwind must compile styles before React
|
|
84
84
|
compiles JSX. The plugin finds `stillwind.config.ts` in the application root.
|
|
85
|
+
It also adds the compiled CSS of your stylesheet to the page, so do not import
|
|
86
|
+
the stylesheet from your code.
|
|
85
87
|
|
|
86
88
|
## Style a component
|
|
87
89
|
|
package/docs/integrations.md
CHANGED
|
@@ -102,6 +102,15 @@ Some plugins split routes or server functions before compilation, such as the
|
|
|
102
102
|
TanStack Start plugin. Place those plugins before `stillwind()`:
|
|
103
103
|
`[tanstackStart(), stillwind(), react()]`.
|
|
104
104
|
|
|
105
|
+
The plugin reads the stylesheet that `css` selects in `stillwind.config.ts` and
|
|
106
|
+
adds the compiled CSS to the page. Do not import that stylesheet anywhere else:
|
|
107
|
+
not from JavaScript, not from another stylesheet, and not from framework options
|
|
108
|
+
such as Starlight's `customCss`. If you import it, Vite also bundles it as plain
|
|
109
|
+
CSS, and the page receives the raw `@theme` and `@utility` rules. Stillwind warns
|
|
110
|
+
when JavaScript or a framework option imports the stylesheet. It cannot detect
|
|
111
|
+
an `@import` in another stylesheet. This rule also applies to Astro, SvelteKit,
|
|
112
|
+
Nuxt, and other frameworks that run on Vite.
|
|
113
|
+
|
|
105
114
|
## Astro
|
|
106
115
|
|
|
107
116
|
Add the integration to `astro.config.ts`:
|
|
@@ -118,6 +127,61 @@ export default defineConfig({
|
|
|
118
127
|
The integration also adds styles to server-rendered pages and islands. Keep your
|
|
119
128
|
other integrations, such as `@astrojs/react`.
|
|
120
129
|
|
|
130
|
+
The integration inserts the styles at the end of `<head>` in each HTML page: an
|
|
131
|
+
inline `<style>` element in development, and `<link rel="stylesheet">` elements
|
|
132
|
+
in production builds. The styles therefore come after the stylesheets that Astro
|
|
133
|
+
and your other integrations add.
|
|
134
|
+
|
|
135
|
+
The browser orders cascade layers by the first place that declares them. If an
|
|
136
|
+
earlier stylesheet declares its own layers, Stillwind's `theme`, `base`, and
|
|
137
|
+
`utilities` layers come after them and win over them. To choose a different
|
|
138
|
+
order, declare all layers in a stylesheet that loads before Stillwind's styles.
|
|
139
|
+
|
|
140
|
+
### Starlight
|
|
141
|
+
|
|
142
|
+
Starlight declares its `starlight` layers in its own stylesheet, which loads
|
|
143
|
+
before Stillwind's styles. Without an earlier layer order, Stillwind's base styles
|
|
144
|
+
would override Starlight's content styles. Create a stylesheet that contains only
|
|
145
|
+
the layer order, and make it the only entry in `customCss`:
|
|
146
|
+
|
|
147
|
+
```css
|
|
148
|
+
/* src/styles/layers.css */
|
|
149
|
+
@layer properties, base, starlight, theme, components, utilities;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
// astro.config.mjs
|
|
154
|
+
import starlight from "@astrojs/starlight";
|
|
155
|
+
import { stillwind } from "@stillwind/integration/astro";
|
|
156
|
+
import { defineConfig } from "astro/config";
|
|
157
|
+
|
|
158
|
+
export default defineConfig({
|
|
159
|
+
integrations: [
|
|
160
|
+
starlight({
|
|
161
|
+
title: "Docs",
|
|
162
|
+
customCss: ["./src/styles/layers.css"],
|
|
163
|
+
}),
|
|
164
|
+
stillwind(),
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Put the Stillwind stylesheet in a separate file, select it with `css` in
|
|
170
|
+
`stillwind.config.ts`, and keep it out of `customCss`:
|
|
171
|
+
|
|
172
|
+
```css
|
|
173
|
+
/* src/styles/stillwind.css */
|
|
174
|
+
@import "@astrojs/starlight-tailwind";
|
|
175
|
+
@import "stillwind/theme.css" layer(theme);
|
|
176
|
+
@import "stillwind/utilities.css" layer(utilities);
|
|
177
|
+
@import "stillwind/builtins.css";
|
|
178
|
+
@import "stillwind/templates.css";
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`@astrojs/starlight-tailwind` adds the `dark` variant and theme tokens for
|
|
182
|
+
Starlight's colors and fonts. The stylesheet leaves out `stillwind/preflight.css`,
|
|
183
|
+
because Starlight resets the page styles itself.
|
|
184
|
+
|
|
121
185
|
## Next.js
|
|
122
186
|
|
|
123
187
|
Wrap your configuration in `next.config.mjs`:
|
|
@@ -5,9 +5,9 @@ description: "Reports two independent base styles in one call that set the same
|
|
|
5
5
|
|
|
6
6
|
# ambiguous-style-base-order
|
|
7
7
|
|
|
8
|
-
This rule reports a `style()` call with two base styles
|
|
9
|
-
property, when neither base is built on the other. The order
|
|
10
|
-
does not decide which base wins, so the result is not defined.
|
|
8
|
+
This rule reports a [`style()`](../macros/style.md) call with two base styles
|
|
9
|
+
that set the same property, when neither base is built on the other. The order
|
|
10
|
+
of the arguments does not decide which base wins, so the result is not defined.
|
|
11
11
|
|
|
12
12
|
## Reported
|
|
13
13
|
|
|
@@ -5,8 +5,8 @@ description: "Reports a top-level utility definition that also applies where the
|
|
|
5
5
|
|
|
6
6
|
# bypassed-undefinition
|
|
7
7
|
|
|
8
|
-
This rule reports a top-level `@utility` that also applies
|
|
9
|
-
removes the utility on purpose. Inside animation options, for example,
|
|
8
|
+
This rule reports a top-level [`@utility`](../at-rules/utility.md) that also applies
|
|
9
|
+
where Stillwind removes the utility on purpose. Inside animation options, for example,
|
|
10
10
|
`duration-*` sets `animation-duration`, and the built-in definitions remove the
|
|
11
11
|
`transition-duration` meaning there. A top-level `duration-slow` would bring that
|
|
12
12
|
meaning back.
|
|
@@ -36,8 +36,8 @@ meaning back.
|
|
|
36
36
|
## How to fix
|
|
37
37
|
|
|
38
38
|
Define the utility inside `@stillwind-registry default`, as in the example. Then
|
|
39
|
-
it applies in ordinary `style()` calls, and animation options
|
|
40
|
-
meaning of `duration-*`.
|
|
39
|
+
it applies in ordinary [`style()`](../macros/style.md) calls, and animation options
|
|
40
|
+
keep their own meaning of `duration-*`.
|
|
41
41
|
|
|
42
42
|
## Rule settings
|
|
43
43
|
|
|
@@ -6,9 +6,10 @@ description: "Reports a container or anchor property that a ref method and a uti
|
|
|
6
6
|
# conflicting-provider-properties
|
|
7
7
|
|
|
8
8
|
This rule reports a container or anchor property that a ref method, such as
|
|
9
|
-
`asContainer()
|
|
10
|
-
`asContainer("size")` sets
|
|
11
|
-
`
|
|
9
|
+
[`asContainer()`](../macros/ref/as-container.md), and another utility both set
|
|
10
|
+
on the same element. For example, `asContainer("size")` sets
|
|
11
|
+
`container-type: size`, and `@container` sets it to `inline-size`. Only one
|
|
12
|
+
value takes effect, and the code does not show which.
|
|
12
13
|
|
|
13
14
|
## Reported
|
|
14
15
|
|