stillwind 0.5.0 → 0.6.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 +5 -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 +11 -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/package.json +29 -5
- package/skills/migrate-to-stillwind/SKILL.md +7 -2
|
@@ -5,9 +5,10 @@ description: "Reports asContainer() or asAnchor() in a call that does not attach
|
|
|
5
5
|
|
|
6
6
|
# missing-ref-attachment
|
|
7
7
|
|
|
8
|
-
This rule reports `asContainer()`
|
|
9
|
-
|
|
10
|
-
the ref
|
|
8
|
+
This rule reports [`asContainer()`](../macros/ref/as-container.md) or
|
|
9
|
+
[`asAnchor()`](../macros/ref/as-anchor.md) in a [`style()`](../macros/style.md)
|
|
10
|
+
call that does not also attach the ref. The container or anchor applies only to
|
|
11
|
+
an element that has the ref, so without it, nothing happens.
|
|
11
12
|
|
|
12
13
|
## Reported
|
|
13
14
|
|
|
@@ -31,7 +32,8 @@ style(card, card.asContainer("inline-size"));
|
|
|
31
32
|
|
|
32
33
|
Pass the ref and the method in the same `style()` call, as in the example.
|
|
33
34
|
|
|
34
|
-
`positionAnchor()` is not reported. The
|
|
35
|
+
[`positionAnchor()`](../macros/ref/position-anchor.md) is not reported. The
|
|
36
|
+
positioned element does not need the ref.
|
|
35
37
|
|
|
36
38
|
## Rule settings
|
|
37
39
|
|
|
@@ -5,9 +5,11 @@ description: "Reports a view transition applied without .for()."
|
|
|
5
5
|
|
|
6
6
|
# missing-view-transition-name
|
|
7
7
|
|
|
8
|
-
This rule reports a `style()` call that applies a view
|
|
9
|
-
`.for()
|
|
10
|
-
|
|
8
|
+
This rule reports a [`style()`](../macros/style.md) call that applies a view
|
|
9
|
+
transition without [`.for()`](../macros/view-transition.md). The transition
|
|
10
|
+
adds its class, but the element has no
|
|
11
|
+
[`view-transition-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/view-transition-name),
|
|
12
|
+
so the browser does not capture it.
|
|
11
13
|
|
|
12
14
|
## Reported
|
|
13
15
|
|
|
@@ -29,8 +31,8 @@ style(transition.for("card"));
|
|
|
29
31
|
|
|
30
32
|
## How to fix
|
|
31
33
|
|
|
32
|
-
- Call `.for()` with a key that stays the same
|
|
33
|
-
update, such as its ID.
|
|
34
|
+
- Call `.for()` with a key that stays the same
|
|
35
|
+
for the item before and after the update, such as its ID.
|
|
34
36
|
- When the call combines several transitions, call `.for()` on one of them.
|
|
35
37
|
|
|
36
38
|
The rule does not check that keys are unique across the page.
|
|
@@ -37,7 +37,7 @@ name as a variant, as in the example:
|
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
If a default breakpoint such as `md:` fits the design, use it instead. To use the
|
|
40
|
-
same width in JavaScript, pass the name to [style.media()](../macros/media.md).
|
|
40
|
+
same width in JavaScript, pass the name to [`style.media()`](../macros/media.md).
|
|
41
41
|
|
|
42
42
|
## Rule settings
|
|
43
43
|
|
|
@@ -5,9 +5,10 @@ description: "Reports the class field, which adds classes without generated CSS.
|
|
|
5
5
|
|
|
6
6
|
# no-class-property
|
|
7
7
|
|
|
8
|
-
This rule reports a `class` field in `style()
|
|
9
|
-
another stylesheet defines, so Stillwind does not check
|
|
10
|
-
when every style in the project must come from utilities.
|
|
8
|
+
This rule reports a `class` field in [`style()`](../macros/style.md). A `class`
|
|
9
|
+
field adds classes that another stylesheet defines, so Stillwind does not check
|
|
10
|
+
them. Enable this rule when every style in the project must come from utilities.
|
|
11
|
+
No preset enables it.
|
|
11
12
|
|
|
12
13
|
## Reported
|
|
13
14
|
|
|
@@ -13,8 +13,9 @@ active theme and custom definitions.
|
|
|
13
13
|
The rule also finds the utility for CSS that you know. Write the declaration as an
|
|
14
14
|
arbitrary property, and let `stillwind lint --fix` replace it.
|
|
15
15
|
|
|
16
|
-
Within one string or one CSS `@apply` statement, it can
|
|
17
|
-
`w-4 h-4` into `size-4`. Utilities must have the same
|
|
16
|
+
Within one string or one CSS [`@apply`](../at-rules/apply.md) statement, it can
|
|
17
|
+
combine utilities such as `w-4 h-4` into `size-4`. Utilities must have the same
|
|
18
|
+
variants and importance.
|
|
18
19
|
|
|
19
20
|
## Theme tokens
|
|
20
21
|
|
|
@@ -29,8 +29,8 @@ const button = style("p-4");
|
|
|
29
29
|
|
|
30
30
|
## How to fix
|
|
31
31
|
|
|
32
|
-
- Give the styles to the element itself with its own
|
|
33
|
-
example.
|
|
32
|
+
- Give the styles to the element itself with its own
|
|
33
|
+
[`style()`](../macros/style.md) call, as in the example.
|
|
34
34
|
- If the element comes from markup that you cannot change, such as rendered
|
|
35
35
|
Markdown, keep the selector and add a
|
|
36
36
|
[suppression comment](../configuration.md#suppression-comments) with the
|
|
@@ -5,10 +5,10 @@ description: "Reports a condition in your stylesheet that a named variant can re
|
|
|
5
5
|
|
|
6
6
|
# prefer-variant-directive
|
|
7
7
|
|
|
8
|
-
This rule reports a condition in a rule
|
|
9
|
-
query, that a variant of your theme
|
|
10
|
-
|
|
11
|
-
`stylistic` preset enables this rule.
|
|
8
|
+
This rule reports a condition in a rule or a [`@utility`](../at-rules/utility.md)
|
|
9
|
+
body of your stylesheet, such as an `@media` query, that a variant of your theme
|
|
10
|
+
expresses with the same meaning. The named variant keeps the stylesheet in sync
|
|
11
|
+
when the theme changes the breakpoint. The `stylistic` preset enables this rule.
|
|
12
12
|
|
|
13
13
|
## Reported
|
|
14
14
|
|
|
@@ -36,13 +36,13 @@ variant keeps the stylesheet in sync when the theme changes the breakpoint. The
|
|
|
36
36
|
|
|
37
37
|
## How to fix
|
|
38
38
|
|
|
39
|
-
Replace the condition with `@variant` and the name of
|
|
40
|
-
example. The automatic fix applies it.
|
|
39
|
+
Replace the condition with [`@variant`](../at-rules/variant.md) and the name of
|
|
40
|
+
the variant, as in the example. The automatic fix applies it.
|
|
41
41
|
|
|
42
42
|
## Options
|
|
43
43
|
|
|
44
|
-
`pxToRem` treats `px` and `rem` in media queries as equal at 16px per `rem`.
|
|
45
|
-
it, `@media (width >= 768px)` also matches `md`.
|
|
44
|
+
`pxToRem` treats `px` and `rem` in media queries as equal at 16px per `rem`.
|
|
45
|
+
With it, `@media (width >= 768px)` also matches `md`.
|
|
46
46
|
|
|
47
47
|
## Rule settings
|
|
48
48
|
|
|
@@ -6,8 +6,9 @@ description: "Reports view transitions split across separate style() calls."
|
|
|
6
6
|
# split-view-transition-class
|
|
7
7
|
|
|
8
8
|
This rule reports view transitions that reach one element through separate
|
|
9
|
-
`style()` calls, such as a base style and the call that
|
|
10
|
-
sets the whole `view-transition-class` list, so one list
|
|
9
|
+
[`style()`](../macros/style.md) calls, such as a base style and the call that
|
|
10
|
+
receives it. Each call sets the whole `view-transition-class` list, so one list
|
|
11
|
+
replaces the other.
|
|
11
12
|
|
|
12
13
|
## Reported
|
|
13
14
|
|
|
@@ -33,8 +34,8 @@ style(first, second.for("card"));
|
|
|
33
34
|
## How to fix
|
|
34
35
|
|
|
35
36
|
Pass every transition of the element to the same `style()` call, with one
|
|
36
|
-
`.for()
|
|
37
|
-
definitions themselves.
|
|
37
|
+
[`.for()`](../macros/view-transition.md) call, as in the example. You can
|
|
38
|
+
still store and share the transition definitions themselves.
|
|
38
39
|
|
|
39
40
|
## Rule settings
|
|
40
41
|
|
|
@@ -6,8 +6,8 @@ description: "Reports await, yield, or import() inside an argument of style() or
|
|
|
6
6
|
# suspending-macro-argument
|
|
7
7
|
|
|
8
8
|
This rule reports `await`, `yield`, or a dynamic `import()` inside an argument of
|
|
9
|
-
`style()` or another macro. The compiler can move or skip
|
|
10
|
-
so the code would not wait or load where you wrote it.
|
|
9
|
+
[`style()`](../macros/style.md) or another macro. The compiler can move or skip
|
|
10
|
+
argument expressions, so the code would not wait or load where you wrote it.
|
|
11
11
|
|
|
12
12
|
## Reported
|
|
13
13
|
|
|
@@ -30,7 +30,8 @@ style("bg-red-950");
|
|
|
30
30
|
- Check the spelling against the theme. In the example, the last character is
|
|
31
31
|
the letter `O` instead of zero. The intended token is `--color-red-950`.
|
|
32
32
|
- To use a value that the theme does not have, add a token to your stylesheet,
|
|
33
|
-
such as `--color-red-999` in `@theme
|
|
33
|
+
such as `--color-red-999` in [`@theme`](../at-rules/theme.md), or define the
|
|
34
|
+
utility with [`@utility`](../at-rules/utility.md).
|
|
34
35
|
- For a class that another stylesheet defines, pass it in a `class` field, such as
|
|
35
36
|
`style({ class: "external-card" })`.
|
|
36
37
|
|
|
@@ -28,8 +28,8 @@ style("hover:p-4");
|
|
|
28
28
|
## How to fix
|
|
29
29
|
|
|
30
30
|
- Correct the spelling of the variant.
|
|
31
|
-
- To use a variant of your own, define it with
|
|
32
|
-
stylesheet.
|
|
31
|
+
- To use a variant of your own, define it with
|
|
32
|
+
[`@custom-variant`](../at-rules/custom-variant.md) in your stylesheet.
|
|
33
33
|
|
|
34
34
|
## Rule settings
|
|
35
35
|
|
|
@@ -5,9 +5,10 @@ description: "Reports a base style whose source the CLI cannot find from its typ
|
|
|
5
5
|
|
|
6
6
|
# unverified-style-base
|
|
7
7
|
|
|
8
|
-
This rule reports a base style whose type does not show which
|
|
9
|
-
created it, such as a value declared as
|
|
10
|
-
cannot find the CSS of the base, so
|
|
8
|
+
This rule reports a base style whose type does not show which
|
|
9
|
+
[`style()`](../macros/style.md) call created it, such as a value declared as
|
|
10
|
+
`ReturnType<typeof style>`. The compiler cannot find the CSS of the base, so
|
|
11
|
+
it cannot order the later utilities after it.
|
|
11
12
|
|
|
12
13
|
## Project files
|
|
13
14
|
|
|
@@ -5,9 +5,11 @@ description: "Limit where an anchor name is visible, so that each component inst
|
|
|
5
5
|
|
|
6
6
|
# style.anchorScope()
|
|
7
7
|
|
|
8
|
-
`style.anchorScope(scope)` sets
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
`style.anchorScope(scope)` sets
|
|
9
|
+
[`anchor-scope`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-scope)
|
|
10
|
+
on an element. Inside that element, a positioned element finds only the
|
|
11
|
+
anchors that are also inside it. Use it when a component with an anchor
|
|
12
|
+
renders more than once on a page.
|
|
11
13
|
|
|
12
14
|
## Example
|
|
13
15
|
|
|
@@ -52,11 +54,11 @@ export const popover = {className:"sw_vqbik"};
|
|
|
52
54
|
|
|
53
55
|
Three elements work together:
|
|
54
56
|
|
|
55
|
-
| Element | Call | Sets
|
|
56
|
-
| ----------- | -------------------------------------- |
|
|
57
|
-
| The anchor | `style(trigger, trigger.asAnchor())` | `anchor-name`
|
|
58
|
-
| An ancestor | `style(style.anchorScope([trigger]))` | `anchor-scope`
|
|
59
|
-
| The popover | `style(trigger.positionAnchor(), ...)` | `position-anchor` |
|
|
57
|
+
| Element | Call | Sets |
|
|
58
|
+
| ----------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
59
|
+
| The anchor | `style(trigger, trigger.asAnchor())` | [`anchor-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-name) |
|
|
60
|
+
| An ancestor | `style(style.anchorScope([trigger]))` | [`anchor-scope`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-scope) |
|
|
61
|
+
| The popover | `style(trigger.positionAnchor(), ...)` | [`position-anchor`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/position-anchor) |
|
|
60
62
|
|
|
61
63
|
Put the scope on the ancestor that contains one anchor and its popover.
|
|
62
64
|
|
|
@@ -75,10 +77,11 @@ An empty array sets nothing, and repeated refs add nothing.
|
|
|
75
77
|
[ineffective-anchor-scope](../lints/ineffective-anchor-scope.md) reports both.
|
|
76
78
|
|
|
77
79
|
`style.anchorScope()` only sets the CSS property. It does not attach a ref, it
|
|
78
|
-
does not create an anchor name, and it does not affect
|
|
80
|
+
does not create an anchor name, and it does not affect
|
|
81
|
+
[`.in()`](ref/in.md) conditions.
|
|
79
82
|
|
|
80
83
|
You can also set the scope on the anchor itself with
|
|
81
|
-
`trigger.asAnchor(scope)`. See [ref.asAnchor()](ref/as-anchor.md).
|
|
84
|
+
`trigger.asAnchor(scope)`. See [`ref.asAnchor()`](ref/as-anchor.md).
|
|
82
85
|
|
|
83
86
|
## Generated code
|
|
84
87
|
|
package/docs/macros/css.md
CHANGED
|
@@ -6,8 +6,8 @@ description: "Compile utilities into a CSS string that you place yourself, such
|
|
|
6
6
|
# style.css()
|
|
7
7
|
|
|
8
8
|
`style.css(...rules, options?)` compiles utilities into a CSS string. Unlike
|
|
9
|
-
`style()
|
|
10
|
-
goes, such as a shadow root.
|
|
9
|
+
[`style()`](style.md), it adds nothing to the page's stylesheet. You
|
|
10
|
+
decide where the string goes, such as a shadow root.
|
|
11
11
|
|
|
12
12
|
## Example
|
|
13
13
|
|
|
@@ -24,7 +24,7 @@ export const css = style.css("p-4 text-blue-600", {
|
|
|
24
24
|
### Compiled code
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
export const css = "/*! stillwind v0.
|
|
27
|
+
export const css = "/*! stillwind v0.6.0 | MIT License | https://stillwind.dev */\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n:where(:root, :host){--color-blue-600:oklch(54.6% 0.245 262.881);--spacing:0.25rem;}:host{padding:calc(var(--spacing) * 4);}:host{color:var(--color-blue-600);}";
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### Generated CSS
|
|
@@ -41,10 +41,10 @@ reports them.
|
|
|
41
41
|
|
|
42
42
|
The last argument can be an options object literal:
|
|
43
43
|
|
|
44
|
-
| Option | Value
|
|
45
|
-
| ---------- |
|
|
46
|
-
| `selector` | The selector that utilities without their own selector style, such as `:host`
|
|
47
|
-
| `template` | The name of an `@stillwind-css-template` in your stylesheet; defaults to `default` |
|
|
44
|
+
| Option | Value |
|
|
45
|
+
| ---------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| `selector` | The selector that utilities without their own selector style, such as `:host` |
|
|
47
|
+
| `template` | The name of an [`@stillwind-css-template`](../at-rules/stillwind-css-template.md) in your stylesheet; defaults to `default` |
|
|
48
48
|
|
|
49
49
|
A variant that sets its own selector, such as `host:` or `[button]:`, keeps that
|
|
50
50
|
selector. A utility without `selector` and without such a variant produces no
|
|
@@ -59,8 +59,10 @@ The string contains the theme values, keyframes, and other supporting CSS that
|
|
|
59
59
|
the template and the utilities need. It never contains the preflight reset.
|
|
60
60
|
|
|
61
61
|
Add the string to the page yourself, for example with
|
|
62
|
-
`CSSStyleSheet.replaceSync()`
|
|
63
|
-
|
|
62
|
+
[`CSSStyleSheet.replaceSync()`](https://developer.mozilla.org/docs/Web/API/CSSStyleSheet/replaceSync)
|
|
63
|
+
and a shadow root's
|
|
64
|
+
[`adoptedStyleSheets`](https://developer.mozilla.org/docs/Web/API/ShadowRoot/adoptedStyleSheets).
|
|
65
|
+
The results in [Built-in utilities and variants](../utilities-and-variants.md)
|
|
64
66
|
leave out the supporting CSS, so they cannot replace this string.
|
|
65
67
|
|
|
66
68
|
To add all styles of a module to a shadow root, including the preflight reset,
|
package/docs/macros/cva.md
CHANGED
|
@@ -6,9 +6,9 @@ description: "Create a factory that selects compiled styles by option, with the
|
|
|
6
6
|
# style.cva()
|
|
7
7
|
|
|
8
8
|
`style.cva(base?, config?)` creates a factory with the configuration format of
|
|
9
|
-
`cva` from
|
|
10
|
-
option at build time. Calling the factory selects
|
|
11
|
-
chosen options and returns props for an element.
|
|
9
|
+
`cva` from [Class Variance Authority](https://cva.style/). The compiler
|
|
10
|
+
generates the CSS for every option at build time. Calling the factory selects
|
|
11
|
+
the compiled classes for the chosen options and returns props for an element.
|
|
12
12
|
|
|
13
13
|
`style.cva()` exists mainly to migrate existing CVA components. For new
|
|
14
14
|
components, see [Reusable styles](../guides/reusable-styles.md).
|
|
@@ -114,11 +114,12 @@ options.
|
|
|
114
114
|
The base and each option value accept utility strings, arrays, objects with
|
|
115
115
|
variant keys, `true`, `false`, `null`, `undefined`, and custom properties.
|
|
116
116
|
|
|
117
|
-
They do not accept `&&`, ternaries, stored `style()`
|
|
118
|
-
or `class` fields. To choose a style at runtime,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
malformed
|
|
117
|
+
They do not accept `&&`, ternaries, stored [`style()`](style.md)
|
|
118
|
+
results, refs, animations, or `class` fields. To choose a style at runtime,
|
|
119
|
+
pass a different option to the factory.
|
|
120
|
+
[invalid-cva-input](../lints/invalid-cva-input.md) reports these values, and
|
|
121
|
+
[invalid-cva-config](../lints/invalid-cva-config.md) reports a malformed
|
|
122
|
+
configuration.
|
|
122
123
|
|
|
123
124
|
A custom property value can be an expression. The factory evaluates it once,
|
|
124
125
|
when the factory is created. Custom properties stay in the inline style, so a
|
package/docs/macros/index.md
CHANGED
|
@@ -9,16 +9,16 @@ Stillwind's API consists of macros: functions that the compiler replaces with
|
|
|
9
9
|
generated code at build time. Each page lists the inputs that the macro accepts,
|
|
10
10
|
and it shows the generated JavaScript and CSS for its examples.
|
|
11
11
|
|
|
12
|
-
| Macro
|
|
13
|
-
|
|
|
14
|
-
| [style()](style.md) | Style an element | [The basics of style()](../guides/style.md) |
|
|
15
|
-
| [style.ref()](ref/index.md) | Style an element from another element's state, size, or position | [Element relationships](../guides/element-relationships.md) |
|
|
16
|
-
| [style.anchorScope()](anchor-scope.md) | Limit where an anchor name is visible | [Element relationships](../guides/element-relationships.md) |
|
|
17
|
-
| [style.keyframes()](keyframes.md) | Define an animation in a component | [Animations](../guides/animations.md) |
|
|
18
|
-
| [style.viewTransition()](view-transition.md) | Style view transition snapshots and name each item | [View transitions](../guides/view-transitions.md) |
|
|
19
|
-
| [style.media()](media.md) | Use a named breakpoint as a media query in JavaScript | [Responsive styles](../guides/responsive-styles.md) |
|
|
20
|
-
| [style.css()](css.md) | Compile utilities into a CSS string for a shadow root | [Web Components](../guides/web-components.md) |
|
|
21
|
-
| [style.cva()](cva.md) | Migrate components that use `cva` | [Migrating from Tailwind CSS](../guides/migrating-from-tailwind.md) |
|
|
12
|
+
| Macro | Use it to | Guide |
|
|
13
|
+
| -------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------- |
|
|
14
|
+
| [`style()`](style.md) | Style an element | [The basics of style()](../guides/style.md) |
|
|
15
|
+
| [`style.ref()`](ref/index.md) | Style an element from another element's state, size, or position | [Element relationships](../guides/element-relationships.md) |
|
|
16
|
+
| [`style.anchorScope()`](anchor-scope.md) | Limit where an anchor name is visible | [Element relationships](../guides/element-relationships.md) |
|
|
17
|
+
| [`style.keyframes()`](keyframes.md) | Define an animation in a component | [Animations](../guides/animations.md) |
|
|
18
|
+
| [`style.viewTransition()`](view-transition.md) | Style view transition snapshots and name each item | [View transitions](../guides/view-transitions.md) |
|
|
19
|
+
| [`style.media()`](media.md) | Use a named breakpoint as a media query in JavaScript | [Responsive styles](../guides/responsive-styles.md) |
|
|
20
|
+
| [`style.css()`](css.md) | Compile utilities into a CSS string for a shadow root | [Web Components](../guides/web-components.md) |
|
|
21
|
+
| [`style.cva()`](cva.md) | Migrate components that use `cva` | [Migrating from Tailwind CSS](../guides/migrating-from-tailwind.md) |
|
|
22
22
|
|
|
23
23
|
Import the macros from the entrypoint of your framework, such as
|
|
24
24
|
`stillwind/react`. The examples on these pages use React.
|
package/docs/macros/keyframes.md
CHANGED
|
@@ -6,8 +6,8 @@ description: "Define keyframes in a component, and apply them with animation opt
|
|
|
6
6
|
# style.keyframes()
|
|
7
7
|
|
|
8
8
|
`style.keyframes(definition)` defines an animation. Calling the result inside
|
|
9
|
-
`style()` applies the animation, and its argument sets
|
|
10
|
-
The compiler generates a unique animation name.
|
|
9
|
+
[`style()`](style.md) applies the animation, and its argument sets
|
|
10
|
+
the animation's options. The compiler generates a unique animation name.
|
|
11
11
|
|
|
12
12
|
## Example
|
|
13
13
|
|
|
@@ -90,8 +90,9 @@ as `{ "motion-safe:": fade("duration-300") }`.
|
|
|
90
90
|
|
|
91
91
|
When the compiler knows which animation a call uses, the call becomes plain
|
|
92
92
|
class names, and the definition variable can become `undefined` in JavaScript.
|
|
93
|
-
The compiler writes every
|
|
94
|
-
|
|
93
|
+
The compiler writes every
|
|
94
|
+
[`@keyframes`](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@keyframes)
|
|
95
|
+
rule that the calls need, together with the theme values that the frames use.
|
|
95
96
|
|
|
96
97
|
See [Animations](../guides/animations.md) for task-based examples, and
|
|
97
98
|
[invalid-keyframes-variant](../lints/invalid-keyframes-variant.md) for
|
package/docs/macros/media.md
CHANGED
|
@@ -6,9 +6,9 @@ description: "Turn named breakpoints and other media variants into a media query
|
|
|
6
6
|
# style.media()
|
|
7
7
|
|
|
8
8
|
`style.media(...conditions)` returns a media query string, such as the argument
|
|
9
|
-
of `matchMedia()
|
|
10
|
-
|
|
11
|
-
conditions.
|
|
9
|
+
of [`matchMedia()`](https://developer.mozilla.org/docs/Web/API/Window/matchMedia).
|
|
10
|
+
It uses the definitions of variants such as `md:` and `motion-safe:` from your
|
|
11
|
+
stylesheet, so JavaScript and CSS use the same conditions.
|
|
12
12
|
|
|
13
13
|
## Example
|
|
14
14
|
|
|
@@ -61,5 +61,6 @@ and no braces. The call adds no CSS.
|
|
|
61
61
|
When you change a breakpoint in your stylesheet, the string changes the next
|
|
62
62
|
time the module compiles.
|
|
63
63
|
|
|
64
|
-
`matchMedia()` is a browser API. Call it on the client, and remove its
|
|
65
|
-
when their component unmounts. See
|
|
64
|
+
`matchMedia()` is a browser API. Call it on the client, and remove its
|
|
65
|
+
listeners when their component unmounts. See
|
|
66
|
+
[Responsive styles](../guides/responsive-styles.md).
|
|
@@ -5,8 +5,10 @@ description: "Make the element that has a ref a named anchor for CSS anchor posi
|
|
|
5
5
|
|
|
6
6
|
# ref.asAnchor()
|
|
7
7
|
|
|
8
|
-
`trigger.asAnchor(scope?)` sets
|
|
9
|
-
|
|
8
|
+
`trigger.asAnchor(scope?)` sets
|
|
9
|
+
[`anchor-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-name)
|
|
10
|
+
on the element. Position another element against it with
|
|
11
|
+
[`trigger.positionAnchor()`](position-anchor.md).
|
|
10
12
|
|
|
11
13
|
## Example
|
|
12
14
|
|
|
@@ -45,7 +47,9 @@ export const popover = {className:"sw_mqosh"};
|
|
|
45
47
|
|
|
46
48
|
## Inputs
|
|
47
49
|
|
|
48
|
-
The optional scope also sets
|
|
50
|
+
The optional scope also sets
|
|
51
|
+
[`anchor-scope`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/anchor-scope)
|
|
52
|
+
on the element:
|
|
49
53
|
|
|
50
54
|
| Scope | Effect |
|
|
51
55
|
| ---------------- | -------------------------------------------------- |
|
|
@@ -60,11 +64,12 @@ when you list it. An empty array sets nothing, and
|
|
|
60
64
|
|
|
61
65
|
## Behavior
|
|
62
66
|
|
|
63
|
-
Pass `trigger` and `trigger.asAnchor()` in the same
|
|
64
|
-
name applies only to an
|
|
67
|
+
Pass `trigger` and `trigger.asAnchor()` in the same
|
|
68
|
+
[`style()`](../style.md) call. The anchor name applies only to an
|
|
69
|
+
element that has the ref, and
|
|
65
70
|
[missing-ref-attachment](../../lints/missing-ref-attachment.md) reports a call
|
|
66
71
|
without it.
|
|
67
72
|
|
|
68
73
|
To limit the anchor name from an ancestor instead, use
|
|
69
|
-
[style.anchorScope()](../anchor-scope.md). Stillwind generates CSS
|
|
70
|
-
so check that the browsers you support implement anchor positioning.
|
|
74
|
+
[`style.anchorScope()`](../anchor-scope.md). Stillwind generates CSS
|
|
75
|
+
only, so check that the browsers you support implement anchor positioning.
|
|
@@ -5,8 +5,11 @@ description: "Make the element that has a ref a named container for ref.at() que
|
|
|
5
5
|
|
|
6
6
|
# ref.asContainer()
|
|
7
7
|
|
|
8
|
-
`card.asContainer(type?)` sets
|
|
9
|
-
`container-
|
|
8
|
+
`card.asContainer(type?)` sets
|
|
9
|
+
[`container-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/container-name)
|
|
10
|
+
on the element, and it sets
|
|
11
|
+
[`container-type`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/container-type)
|
|
12
|
+
when you pass a type. Query the container with
|
|
10
13
|
[`card.at()`](at.md).
|
|
11
14
|
|
|
12
15
|
## Example
|
|
@@ -54,8 +57,8 @@ its value. A type stored in a variable is not accepted.
|
|
|
54
57
|
|
|
55
58
|
## Behavior
|
|
56
59
|
|
|
57
|
-
Pass `card` and `card.asContainer()` in the same `style()`
|
|
58
|
-
declarations apply only to an element that has the ref, and
|
|
60
|
+
Pass `card` and `card.asContainer()` in the same [`style()`](../style.md)
|
|
61
|
+
call. The container declarations apply only to an element that has the ref, and
|
|
59
62
|
[missing-ref-attachment](../../lints/missing-ref-attachment.md) reports a call
|
|
60
63
|
without it.
|
|
61
64
|
|
package/docs/macros/ref/at.md
CHANGED
|
@@ -5,8 +5,9 @@ description: "Style an element with a container query on the element that has a
|
|
|
5
5
|
|
|
6
6
|
# ref.at()
|
|
7
7
|
|
|
8
|
-
`card.at(query?)` creates
|
|
9
|
-
|
|
8
|
+
`card.at(query?)` creates
|
|
9
|
+
[a container query](https://developer.mozilla.org/docs/Web/CSS/Guides/Containment/Container_queries)
|
|
10
|
+
on the container that the `card` ref names. Make that element a container with
|
|
10
11
|
[`card.asContainer()`](as-container.md).
|
|
11
12
|
|
|
12
13
|
## Example
|
|
@@ -47,11 +48,11 @@ export const child = {className:"sw_cunr1"};
|
|
|
47
48
|
|
|
48
49
|
## Inputs
|
|
49
50
|
|
|
50
|
-
| Form | Generated condition
|
|
51
|
-
| ---------------------------- |
|
|
52
|
-
| `card.at("width >= 40rem")` | `@container <name> (width >= 40rem)` |
|
|
53
|
-
| ``card.at`width >= 40rem` `` | The same as the string form
|
|
54
|
-
| `card.at()` or `card.at("")` | `@container <name>`
|
|
51
|
+
| Form | Generated condition |
|
|
52
|
+
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `card.at("width >= 40rem")` | [`@container <name> (width >= 40rem)`](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@container) |
|
|
54
|
+
| ``card.at`width >= 40rem` `` | The same as the string form |
|
|
55
|
+
| `card.at()` or `card.at("")` | `@container <name>` |
|
|
55
56
|
|
|
56
57
|
Write the query as a string literal or a tagged template without interpolations.
|
|
57
58
|
Leave out the outer parentheses.
|
|
@@ -61,8 +62,8 @@ Leave out the outer parentheses.
|
|
|
61
62
|
Without a query, the condition matches whenever the styled element is inside a
|
|
62
63
|
container with the name.
|
|
63
64
|
|
|
64
|
-
Write the call directly as a computed key in `style()
|
|
65
|
-
variable and use it later.
|
|
65
|
+
Write the call directly as a computed key in [`style()`](../style.md).
|
|
66
|
+
You cannot store it in a variable and use it later.
|
|
66
67
|
|
|
67
68
|
See [Element relationships](../../guides/element-relationships.md#react-to-a-containers-size)
|
|
68
69
|
for a task-based example.
|
|
@@ -59,7 +59,7 @@ The final colon is optional.
|
|
|
59
59
|
|
|
60
60
|
## Where to write it
|
|
61
61
|
|
|
62
|
-
Write the condition as a computed key of an object in `style()
|
|
62
|
+
Write the condition as a computed key of an object in [`style()`](../style.md):
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
65
|
style({ [card("hover")]: "text-blue-600" });
|
package/docs/macros/ref/in.md
CHANGED
|
@@ -5,9 +5,9 @@ description: "Style an element from the state of a sibling, inside an ancestor t
|
|
|
5
5
|
|
|
6
6
|
# ref().in()
|
|
7
7
|
|
|
8
|
-
`trigger("hover").in(card)` matches while the `trigger` element is hovered and
|
|
9
|
-
element with the `card` ref contains both the `trigger` element and the
|
|
10
|
-
element. Use it to style an element from the state of a sibling.
|
|
8
|
+
`trigger("hover").in(card)` matches while the `trigger` element is hovered and
|
|
9
|
+
an element with the `card` ref contains both the `trigger` element and the
|
|
10
|
+
styled element. Use it to style an element from the state of a sibling.
|
|
11
11
|
|
|
12
12
|
## Example
|
|
13
13
|
|
|
@@ -64,7 +64,7 @@ The receiver is a [ref condition](condition.md), such as
|
|
|
64
64
|
| `card` | Has the `card` ref |
|
|
65
65
|
| `card("focus-within")` | Has the `card` ref and matches the variants |
|
|
66
66
|
|
|
67
|
-
The argument cannot use `.in()` or `.at()` itself.
|
|
67
|
+
The argument cannot use `.in()` or [`.at()`](at.md) itself.
|
|
68
68
|
|
|
69
69
|
## Behavior
|
|
70
70
|
|
|
@@ -74,8 +74,8 @@ styled element itself.
|
|
|
74
74
|
Calling `.in()` more than once adds each scope as another condition, and every
|
|
75
75
|
condition must match.
|
|
76
76
|
|
|
77
|
-
Write the whole chain directly as a computed key in `style()
|
|
78
|
-
in a variable and use it later.
|
|
77
|
+
Write the whole chain directly as a computed key in [`style()`](../style.md).
|
|
78
|
+
You cannot store it in a variable and use it later.
|
|
79
79
|
|
|
80
80
|
See [Element relationships](../../guides/element-relationships.md#react-to-a-siblings-state)
|
|
81
81
|
for a task-based example.
|
package/docs/macros/ref/index.md
CHANGED
|
@@ -6,8 +6,8 @@ description: "Name an element with a ref, and style other elements from its stat
|
|
|
6
6
|
# style.ref() and ref methods
|
|
7
7
|
|
|
8
8
|
`style.ref(label?)` creates a ref: a name for an element that other styles can
|
|
9
|
-
refer to. Attach the ref to an element with `style(ref)`. Then use its methods
|
|
10
|
-
style other elements from that element's state, size, or position.
|
|
9
|
+
refer to. Attach the ref to an element with `style(ref)`. Then use its methods
|
|
10
|
+
to style other elements from that element's state, size, or position.
|
|
11
11
|
|
|
12
12
|
## Example
|
|
13
13
|
|
|
@@ -90,15 +90,15 @@ nearest one.
|
|
|
90
90
|
|
|
91
91
|
## Methods
|
|
92
92
|
|
|
93
|
-
| Method | Where to write it
|
|
94
|
-
| ---------------------------------------------------------- |
|
|
95
|
-
| `ref` | A `style()` argument
|
|
96
|
-
| [`ref()`](condition.md) | A computed key in `style()`
|
|
97
|
-
| [`ref().in()`](in.md) | After a ref condition
|
|
98
|
-
| [`ref.at()`](at.md) | A computed key in `style()`
|
|
99
|
-
| [`ref.asContainer()`](as-container.md) | A `style()` argument
|
|
100
|
-
| [`ref.asAnchor()`](as-anchor.md) | A `style()` argument
|
|
101
|
-
| [`ref.positionAnchor()`](position-anchor.md) | A `style()` argument
|
|
93
|
+
| Method | Where to write it | Effect |
|
|
94
|
+
| ---------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |
|
|
95
|
+
| `ref` | A [`style()`](../style.md) argument | Attaches the ref to the element |
|
|
96
|
+
| [`ref()`](condition.md) | A computed key in `style()` | Matches inside the ref element, optionally in a state |
|
|
97
|
+
| [`ref().in()`](in.md) | After a ref condition | Matches inside a shared ancestor, such as for siblings |
|
|
98
|
+
| [`ref.at()`](at.md) | A computed key in `style()` | Matches a container query on the ref element |
|
|
99
|
+
| [`ref.asContainer()`](as-container.md) | A `style()` argument | Makes the ref element a named container |
|
|
100
|
+
| [`ref.asAnchor()`](as-anchor.md) | A `style()` argument | Makes the ref element a named anchor |
|
|
101
|
+
| [`ref.positionAnchor()`](position-anchor.md) | A `style()` argument | Positions the styled element against the anchor |
|
|
102
102
|
|
|
103
103
|
Write each method call directly in `style()`. You cannot store the result of a
|
|
104
104
|
method call in a variable and use it later.
|
|
@@ -5,8 +5,11 @@ description: "Position the styled element against the anchor that a ref names."
|
|
|
5
5
|
|
|
6
6
|
# ref.positionAnchor()
|
|
7
7
|
|
|
8
|
-
`trigger.positionAnchor()` sets
|
|
9
|
-
`anchor()
|
|
8
|
+
`trigger.positionAnchor()` sets
|
|
9
|
+
[`position-anchor`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/position-anchor)
|
|
10
|
+
on the styled element, so that
|
|
11
|
+
[`anchor()`](https://developer.mozilla.org/docs/Web/CSS/Reference/Values/anchor)
|
|
12
|
+
values in its other utilities refer to the `trigger` anchor.
|
|
10
13
|
|
|
11
14
|
## Example
|
|
12
15
|
|
|
@@ -57,8 +60,8 @@ export const popover = {className:"sw_fu7et"};
|
|
|
57
60
|
The styled element does not need the `trigger` ref. The anchor element needs it,
|
|
58
61
|
together with [`trigger.asAnchor()`](as-anchor.md).
|
|
59
62
|
|
|
60
|
-
Write the call directly in `style()
|
|
61
|
-
it later.
|
|
63
|
+
Write the call directly in [`style()`](../style.md). You cannot store it
|
|
64
|
+
in a variable and use it later.
|
|
62
65
|
|
|
63
66
|
See [Element relationships](../../guides/element-relationships.md#position-an-element-at-an-anchor)
|
|
64
67
|
for a complete example with an anchor scope.
|