stillwind 0.8.0 → 0.9.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/CHANGELOG.md +193 -0
- package/css/builtin-variants/tw-relationship.css +4 -4
- package/css/builtins.css +1 -1
- package/dist/frameworks/alpine.d.ts +1 -1
- package/dist/frameworks/astro.d.ts +1 -1
- package/dist/frameworks/lit.d.ts +1 -1
- package/dist/frameworks/preact.d.ts +1 -1
- package/dist/frameworks/qwik.d.ts +1 -1
- package/dist/frameworks/solid.d.ts +1 -1
- package/dist/frameworks/svelte.d.ts +1 -1
- package/dist/frameworks/vanilla.d.ts +1 -1
- package/dist/frameworks/vue.d.ts +1 -1
- package/docs/at-rules/apply.md +5 -5
- package/docs/at-rules/custom-variant.md +12 -12
- package/docs/at-rules/index.md +19 -19
- package/docs/at-rules/plugin.md +7 -7
- package/docs/at-rules/registry-directives.md +9 -9
- package/docs/at-rules/slot.md +6 -6
- package/docs/at-rules/stillwind-css-template.md +7 -7
- package/docs/at-rules/stillwind-property.md +10 -10
- package/docs/at-rules/stillwind-registry.md +18 -18
- package/docs/at-rules/stillwind-require-properties.md +9 -9
- package/docs/at-rules/stillwind-slot.md +6 -6
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +9 -9
- package/docs/at-rules/stillwind-undef-utility.md +10 -10
- package/docs/at-rules/stillwind-undef-variant.md +6 -6
- package/docs/at-rules/theme.md +23 -23
- package/docs/at-rules/utility.md +30 -30
- package/docs/at-rules/variant.md +6 -6
- package/docs/cli.md +7 -7
- package/docs/concepts/css-ordering.md +17 -17
- package/docs/concepts/how-styles-compile.md +14 -14
- package/docs/concepts/stylesheets.md +4 -4
- package/docs/configuration.md +19 -19
- package/docs/editors.md +8 -8
- package/docs/errors/SW01003.md +1 -1
- package/docs/errors/SW10001.md +1 -1
- package/docs/errors/SW10002.md +1 -1
- package/docs/errors/SW10004.md +6 -6
- package/docs/errors/SW10005.md +1 -1
- package/docs/errors/SW11001.md +1 -1
- package/docs/errors/SW11003.md +1 -1
- package/docs/errors/SW12001.md +2 -2
- package/docs/errors/SW12002.md +1 -1
- package/docs/errors/SW13001.md +1 -1
- package/docs/errors/SW13003.md +2 -2
- package/docs/errors/SW14001.md +1 -1
- package/docs/errors/SW14003.md +4 -4
- package/docs/errors/SW14004.md +2 -2
- package/docs/errors/SW14005.md +1 -1
- package/docs/errors/SW14006.md +1 -1
- package/docs/errors/SW14007.md +2 -2
- package/docs/errors/SW14008.md +1 -1
- package/docs/errors/SW30001.md +1 -1
- package/docs/errors/SW31001.md +1 -1
- package/docs/errors/SW31004.md +1 -1
- package/docs/errors/SW33005.md +1 -1
- package/docs/errors/SW34002.md +1 -1
- package/docs/errors/SW90001.md +1 -1
- package/docs/errors/SW90005.md +1 -1
- package/docs/errors/SW90006.md +1 -1
- package/docs/errors/index.md +72 -72
- package/docs/formatters.md +5 -5
- package/docs/guides/animations.md +7 -8
- package/docs/guides/design-systems.md +7 -7
- package/docs/guides/element-relationships.md +15 -19
- package/docs/guides/lint-adoption.md +5 -5
- package/docs/guides/migrating-from-css.md +11 -11
- package/docs/guides/migrating-from-tailwind.md +16 -16
- package/docs/guides/recommended-practices.md +18 -18
- package/docs/guides/responsive-styles.md +7 -7
- package/docs/guides/reusable-styles.md +5 -5
- package/docs/guides/runtime-conditions.md +6 -6
- package/docs/guides/style.md +15 -15
- package/docs/guides/tailwind-compatibility.md +21 -21
- package/docs/guides/view-transitions.md +9 -11
- package/docs/guides/web-components.md +4 -4
- package/docs/index.md +14 -12
- package/docs/integrations.md +3 -3
- package/docs/lints/ambiguous-style-base-order.md +2 -2
- package/docs/lints/bypassed-undefinition.md +3 -3
- package/docs/lints/clamped-value.md +1 -1
- package/docs/lints/conflicting-provider-properties.md +2 -2
- package/docs/lints/conflicting-utilities.md +2 -2
- package/docs/lints/document-scoped-selector.md +1 -1
- package/docs/lints/duplicate-definition.md +3 -3
- package/docs/lints/duplicate-utility.md +2 -2
- package/docs/lints/duplicate-view-transition-name.md +3 -3
- package/docs/lints/ignored-definition-condition.md +2 -2
- package/docs/lints/ignored-tailwind-feature.md +3 -3
- package/docs/lints/implicit-nesting-selector.md +2 -2
- package/docs/lints/incompatible-property-value.md +3 -3
- package/docs/lints/incompatible-theme-value.md +1 -1
- package/docs/lints/index.md +74 -74
- package/docs/lints/ineffective-anchor-scope.md +2 -2
- package/docs/lints/interfering-imported-style-base.md +1 -1
- package/docs/lints/invalid-animation-option.md +3 -3
- package/docs/lints/invalid-css-directive.md +3 -3
- package/docs/lints/invalid-css-import.md +2 -2
- package/docs/lints/invalid-css-input.md +4 -4
- package/docs/lints/invalid-cva-config.md +2 -2
- package/docs/lints/invalid-cva-input.md +4 -4
- package/docs/lints/invalid-keyframes-definition.md +2 -2
- package/docs/lints/invalid-keyframes-use.md +2 -2
- package/docs/lints/invalid-keyframes-variant.md +4 -4
- package/docs/lints/invalid-lint-suppression.md +3 -3
- package/docs/lints/invalid-marker-use.md +2 -2
- package/docs/lints/invalid-media-query.md +4 -4
- package/docs/lints/invalid-ref-input.md +4 -4
- package/docs/lints/invalid-rule-group-input.md +2 -2
- package/docs/lints/invalid-runtime-condition.md +3 -3
- package/docs/lints/invalid-stored-variant.md +3 -3
- package/docs/lints/invalid-style-composition.md +2 -2
- package/docs/lints/invalid-style-input.md +2 -2
- package/docs/lints/invalid-theme-reference.md +3 -3
- package/docs/lints/invalid-utility.md +3 -3
- package/docs/lints/invalid-variant.md +2 -2
- package/docs/lints/invalid-view-transition-definition.md +2 -2
- package/docs/lints/invalid-view-transition-use.md +2 -2
- package/docs/lints/invalid-view-transition-variant.md +3 -3
- package/docs/lints/mismatched-framework-import.md +3 -3
- package/docs/lints/missing-document-target.md +2 -2
- package/docs/lints/missing-ref-attachment.md +4 -4
- package/docs/lints/missing-view-transition-name.md +3 -3
- package/docs/lints/mutating-macro-argument.md +2 -2
- package/docs/lints/no-arbitrary-breakpoints.md +2 -2
- package/docs/lints/no-arbitrary-colors.md +2 -2
- package/docs/lints/no-arbitrary-spacing.md +1 -1
- package/docs/lints/no-class-property.md +3 -3
- package/docs/lints/no-important.md +2 -2
- package/docs/lints/no-restricted-declarations.md +1 -1
- package/docs/lints/no-restricted-length-units.md +1 -1
- package/docs/lints/no-restricted-theme-tokens.md +1 -1
- package/docs/lints/no-restricted-utilities.md +2 -2
- package/docs/lints/prefer-canonical-utilities.md +2 -2
- package/docs/lints/prefer-direct-styling.md +3 -3
- package/docs/lints/prefer-logical-properties.md +3 -3
- package/docs/lints/prefer-sorted-utilities.md +2 -2
- package/docs/lints/prefer-typed-relationships.md +3 -3
- package/docs/lints/prefer-typed-variables.md +1 -1
- package/docs/lints/prefer-variant-directive.md +3 -3
- package/docs/lints/redundant-variant.md +2 -2
- package/docs/lints/repeated-nesting-selector.md +2 -2
- package/docs/lints/runtime-condition-requires-css-if.md +3 -3
- package/docs/lints/split-view-transition-class.md +3 -3
- package/docs/lints/suspending-macro-argument.md +2 -2
- package/docs/lints/unknown-utility.md +4 -4
- package/docs/lints/unknown-variant.md +2 -2
- package/docs/lints/unmatched-host-selector.md +2 -2
- package/docs/lints/unsatisfiable-variants.md +1 -1
- package/docs/lints/unused-lint-suppression.md +1 -1
- package/docs/lints/unverified-style-base.md +2 -2
- package/docs/macros/anchor-scope.md +13 -13
- package/docs/macros/css.md +7 -7
- package/docs/macros/cva.md +13 -13
- package/docs/macros/index.md +10 -10
- package/docs/macros/keyframes.md +9 -9
- package/docs/macros/media.md +2 -2
- package/docs/macros/ref/as-anchor.md +11 -11
- package/docs/macros/ref/as-container.md +8 -8
- package/docs/macros/ref/at.md +10 -10
- package/docs/macros/ref/condition.md +8 -8
- package/docs/macros/ref/in.md +11 -11
- package/docs/macros/ref/index.md +16 -16
- package/docs/macros/ref/position-anchor.md +9 -9
- package/docs/macros/style.md +24 -24
- package/docs/macros/view-transition.md +16 -16
- package/docs/macros/when.md +13 -13
- package/docs/plugins/iconify.md +5 -5
- package/docs/plugins/index.md +4 -4
- package/docs/utilities-and-variants.md +6 -6
- package/docs/why.md +13 -15
- package/package.json +8 -6
|
@@ -10,7 +10,7 @@ description: "Make the element that has a ref a named container for ref.at() que
|
|
|
10
10
|
on the element, and it sets
|
|
11
11
|
[`container-type`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/container-type)
|
|
12
12
|
when you pass a type. Query the container with
|
|
13
|
-
[`card.at()`](at
|
|
13
|
+
[`card.at()`](https://stillwind.dev/docs/macros/ref/at).
|
|
14
14
|
|
|
15
15
|
## Example
|
|
16
16
|
|
|
@@ -27,19 +27,19 @@ export const container = style(card, card.asContainer("inline-size"), "p-4");
|
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
const card = undefined;
|
|
30
|
-
export const container = {className:"
|
|
30
|
+
export const container = {className:"sw_9kism sw_card_nudp9"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
.
|
|
37
|
+
.sw_9kism {
|
|
38
38
|
padding: calc(var(--spacing) * 4);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.
|
|
42
|
-
container-name: sw-c-card-
|
|
41
|
+
.sw_9kism:where(.sw_card_nudp9) {
|
|
42
|
+
container-name: sw-c-card-nudp9;
|
|
43
43
|
container-type: inline-size;
|
|
44
44
|
}
|
|
45
45
|
```
|
|
@@ -57,11 +57,11 @@ its value. A type stored in a variable is not accepted.
|
|
|
57
57
|
|
|
58
58
|
## Behavior
|
|
59
59
|
|
|
60
|
-
Pass `card` and `card.asContainer()` in the same [`style()`](
|
|
60
|
+
Pass `card` and `card.asContainer()` in the same [`style()`](https://stillwind.dev/docs/macros/style)
|
|
61
61
|
call. The container declarations apply only to an element that has the ref, and
|
|
62
|
-
[missing-ref-attachment](
|
|
62
|
+
[missing-ref-attachment](https://stillwind.dev/docs/lints/missing-ref-attachment) reports a call
|
|
63
63
|
without it.
|
|
64
64
|
|
|
65
65
|
When another rule on the element also sets `container-name` or `container-type`,
|
|
66
|
-
[conflicting-provider-properties](
|
|
66
|
+
[conflicting-provider-properties](https://stillwind.dev/docs/lints/conflicting-provider-properties)
|
|
67
67
|
reports it.
|
package/docs/macros/ref/at.md
CHANGED
|
@@ -8,7 +8,7 @@ description: "Style an element with a container query on the element that has a
|
|
|
8
8
|
`card.at(query?)` creates
|
|
9
9
|
[a container query](https://developer.mozilla.org/docs/Web/CSS/Guides/Containment/Container_queries)
|
|
10
10
|
on the container that the `card` ref names. Make that element a container with
|
|
11
|
-
[`card.asContainer()`](as-container
|
|
11
|
+
[`card.asContainer()`](https://stillwind.dev/docs/macros/ref/as-container).
|
|
12
12
|
|
|
13
13
|
## Example
|
|
14
14
|
|
|
@@ -26,21 +26,21 @@ export const child = style({ [card.at("width >= 40rem")]: "grid-cols-2" });
|
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
const card = undefined;
|
|
29
|
-
export const container = {className:"
|
|
30
|
-
export const child = {className:"
|
|
29
|
+
export const container = {className:"sw_osnwd sw_card_nudp9"};
|
|
30
|
+
export const child = {className:"sw_hzszw"};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Generated CSS
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
```css
|
|
37
|
-
.
|
|
38
|
-
container-name: sw-c-card-
|
|
37
|
+
.sw_osnwd:where(.sw_card_nudp9) {
|
|
38
|
+
container-name: sw-c-card-nudp9;
|
|
39
39
|
container-type: inline-size;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
@container sw-c-card-
|
|
43
|
-
.
|
|
42
|
+
@container sw-c-card-nudp9 (width >= 40rem) {
|
|
43
|
+
.sw_hzszw {
|
|
44
44
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -62,8 +62,8 @@ Leave out the outer parentheses.
|
|
|
62
62
|
Without a query, the condition matches whenever the styled element is inside a
|
|
63
63
|
container with the name.
|
|
64
64
|
|
|
65
|
-
Write the call directly as a computed key in [`style()`](
|
|
66
|
-
To use it in several places, store it with [`style.when()`](
|
|
65
|
+
Write the call directly as a computed key in [`style()`](https://stillwind.dev/docs/macros/style).
|
|
66
|
+
To use it in several places, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
67
67
|
|
|
68
|
-
See [Element relationships](
|
|
68
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-containers-size)
|
|
69
69
|
for a task-based example.
|
|
@@ -25,21 +25,21 @@ export const title = style({ [card("hover")]: "text-blue-600" });
|
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
const card = undefined;
|
|
28
|
-
export const container = {className:"
|
|
29
|
-
export const title = {className:"
|
|
28
|
+
export const container = {className:"sw_gky8e sw_card_nudp9"};
|
|
29
|
+
export const title = {className:"sw_0m922"};
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Generated CSS
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
```css
|
|
36
|
-
.
|
|
36
|
+
.sw_gky8e {
|
|
37
37
|
padding: calc(var(--spacing) * 4);
|
|
38
38
|
border-radius: var(--radius-lg);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
@media (hover: hover) {
|
|
42
|
-
.
|
|
42
|
+
.sw_0m922:is(:where(.sw_card_nudp9):hover *) {
|
|
43
43
|
color: var(--color-blue-600);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -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()`](https://stillwind.dev/docs/macros/style):
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
65
|
style({ [card("hover")]: "text-blue-600" });
|
|
@@ -73,15 +73,15 @@ style(`${card("hover")}:text-blue-600`);
|
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
To use the same condition in several places, store it with
|
|
76
|
-
[`style.when()`](
|
|
76
|
+
[`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
77
77
|
|
|
78
78
|
## Behavior
|
|
79
79
|
|
|
80
80
|
The ref element must be an ancestor of the styled element. To match a sibling or
|
|
81
|
-
another element inside a shared ancestor, add [`.in()`](in
|
|
81
|
+
another element inside a shared ancestor, add [`.in()`](https://stillwind.dev/docs/macros/ref/in).
|
|
82
82
|
|
|
83
83
|
The condition only selects elements. It does not attach the ref, so attach it with
|
|
84
84
|
`style(card)` on the ancestor.
|
|
85
85
|
|
|
86
|
-
See [Element relationships](
|
|
86
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-parents-state)
|
|
87
87
|
for a task-based example.
|
package/docs/macros/ref/in.md
CHANGED
|
@@ -28,27 +28,27 @@ export const text = style({ [trigger("hover").in(card)]: "text-blue-600" });
|
|
|
28
28
|
```ts
|
|
29
29
|
const card = undefined;
|
|
30
30
|
const trigger = undefined;
|
|
31
|
-
export const container = {className:"
|
|
32
|
-
export const button = {className:"
|
|
33
|
-
export const text = {className:"
|
|
31
|
+
export const container = {className:"sw_dsyoo sw_card_nudp9"};
|
|
32
|
+
export const button = {className:"sw_zycpr sw_trigger_xnhw0"};
|
|
33
|
+
export const text = {className:"sw_hfcxb"};
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Generated CSS
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
```css
|
|
40
|
-
.
|
|
40
|
+
.sw_dsyoo {
|
|
41
41
|
padding: calc(var(--spacing) * 4);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.
|
|
44
|
+
.sw_zycpr {
|
|
45
45
|
padding-inline: calc(var(--spacing) * 4);
|
|
46
46
|
padding-block: calc(var(--spacing) * 2);
|
|
47
47
|
border-radius: var(--radius-md);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@media (hover: hover) {
|
|
51
|
-
.
|
|
51
|
+
.sw_hfcxb:is(:where(.sw_card_nudp9):has(:where(.sw_trigger_xnhw0):hover) *) {
|
|
52
52
|
color: var(--color-blue-600);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -56,7 +56,7 @@ export const text = {className:"sw_yz349"};
|
|
|
56
56
|
|
|
57
57
|
## Inputs
|
|
58
58
|
|
|
59
|
-
The receiver is a [ref condition](condition
|
|
59
|
+
The receiver is a [ref condition](https://stillwind.dev/docs/macros/ref/condition), such as
|
|
60
60
|
`trigger("hover")` or `trigger()`. The argument is one of these:
|
|
61
61
|
|
|
62
62
|
| Argument | The scope element |
|
|
@@ -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()`](at
|
|
67
|
+
The argument cannot use `.in()` or [`.at()`](https://stillwind.dev/docs/macros/ref/at) 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
|
-
To use it in several places, store it with [`style.when()`](
|
|
77
|
+
Write the whole chain directly as a computed key in [`style()`](https://stillwind.dev/docs/macros/style).
|
|
78
|
+
To use it in several places, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
79
79
|
|
|
80
|
-
See [Element relationships](
|
|
80
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#react-to-a-siblings-state)
|
|
81
81
|
for a task-based example.
|
package/docs/macros/ref/index.md
CHANGED
|
@@ -28,27 +28,27 @@ export const child = style({
|
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
const card = undefined;
|
|
31
|
-
export const container = {className:"
|
|
32
|
-
export const child = {className:"
|
|
31
|
+
export const container = {className:"sw_osnwd sw_card_nudp9"};
|
|
32
|
+
export const child = {className:"sw_duzby"};
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Generated CSS
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
```css
|
|
39
|
-
.
|
|
40
|
-
container-name: sw-c-card-
|
|
39
|
+
.sw_osnwd:where(.sw_card_nudp9) {
|
|
40
|
+
container-name: sw-c-card-nudp9;
|
|
41
41
|
container-type: inline-size;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
@container sw-c-card-
|
|
45
|
-
.
|
|
44
|
+
@container sw-c-card-nudp9 (width >= 40rem) {
|
|
45
|
+
.sw_duzby {
|
|
46
46
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@media (hover: hover) {
|
|
51
|
-
.
|
|
51
|
+
.sw_duzby:is(:where(.sw_card_nudp9):hover *) {
|
|
52
52
|
color: var(--color-blue-600);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -92,17 +92,17 @@ nearest one.
|
|
|
92
92
|
|
|
93
93
|
| Method | Where to write it | Effect |
|
|
94
94
|
| ---------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------ |
|
|
95
|
-
| `ref` | A [`style()`](
|
|
96
|
-
| [`ref()`](condition
|
|
97
|
-
| [`ref().in()`](in
|
|
98
|
-
| [`ref.at()`](at
|
|
99
|
-
| [`ref.asContainer()`](as-container
|
|
100
|
-
| [`ref.asAnchor()`](as-anchor
|
|
101
|
-
| [`ref.positionAnchor()`](position-anchor
|
|
95
|
+
| `ref` | A [`style()`](https://stillwind.dev/docs/macros/style) argument | Attaches the ref to the element |
|
|
96
|
+
| [`ref()`](https://stillwind.dev/docs/macros/ref/condition) | A computed key in `style()` | Matches inside the ref element, optionally in a state |
|
|
97
|
+
| [`ref().in()`](https://stillwind.dev/docs/macros/ref/in) | After a ref condition | Matches inside a shared ancestor, such as for siblings |
|
|
98
|
+
| [`ref.at()`](https://stillwind.dev/docs/macros/ref/at) | A computed key in `style()` | Matches a container query on the ref element |
|
|
99
|
+
| [`ref.asContainer()`](https://stillwind.dev/docs/macros/ref/as-container) | A `style()` argument | Makes the ref element a named container |
|
|
100
|
+
| [`ref.asAnchor()`](https://stillwind.dev/docs/macros/ref/as-anchor) | A `style()` argument | Makes the ref element a named anchor |
|
|
101
|
+
| [`ref.positionAnchor()`](https://stillwind.dev/docs/macros/ref/position-anchor) | 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. To reuse a ref condition or a
|
|
105
|
-
container query, store it with [`style.when()`](
|
|
105
|
+
container query, store it with [`style.when()`](https://stillwind.dev/docs/macros/when).
|
|
106
106
|
|
|
107
107
|
## Generated code
|
|
108
108
|
|
|
@@ -112,5 +112,5 @@ call chooses among several refs at runtime, the generated code keeps the fields
|
|
|
112
112
|
that the choice needs. The compiled code reads those fields directly. In
|
|
113
113
|
development, Stillwind checks them first. The code does not watch the DOM.
|
|
114
114
|
|
|
115
|
-
See [Element relationships](
|
|
115
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships) for task-based
|
|
116
116
|
examples.
|
|
@@ -31,20 +31,20 @@ export const popover = style(
|
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
const trigger = undefined;
|
|
34
|
-
export const button = {className:"
|
|
35
|
-
export const popover = {className:"
|
|
34
|
+
export const button = {className:"sw_6x3gz sw_trigger_xnhw0"};
|
|
35
|
+
export const popover = {className:"sw_6gq48"};
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Generated CSS
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
```css
|
|
42
|
-
.
|
|
43
|
-
anchor-name: --sw-a-trigger-
|
|
42
|
+
.sw_6x3gz:where(.sw_trigger_xnhw0) {
|
|
43
|
+
anchor-name: --sw-a-trigger-xnhw0;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
.
|
|
47
|
-
position-anchor: --sw-a-trigger-
|
|
46
|
+
.sw_6gq48 {
|
|
47
|
+
position-anchor: --sw-a-trigger-xnhw0;
|
|
48
48
|
position: absolute;
|
|
49
49
|
top: anchor(bottom);
|
|
50
50
|
left: anchor(left);
|
|
@@ -58,10 +58,10 @@ export const popover = {className:"sw_fu7et"};
|
|
|
58
58
|
## Behavior
|
|
59
59
|
|
|
60
60
|
The styled element does not need the `trigger` ref. The anchor element needs it,
|
|
61
|
-
together with [`trigger.asAnchor()`](as-anchor
|
|
61
|
+
together with [`trigger.asAnchor()`](https://stillwind.dev/docs/macros/ref/as-anchor).
|
|
62
62
|
|
|
63
|
-
Write the call directly in [`style()`](
|
|
63
|
+
Write the call directly in [`style()`](https://stillwind.dev/docs/macros/style). You cannot store it
|
|
64
64
|
in a variable and use it later.
|
|
65
65
|
|
|
66
|
-
See [Element relationships](
|
|
66
|
+
See [Element relationships](https://stillwind.dev/docs/guides/element-relationships#position-an-element-at-an-anchor)
|
|
67
67
|
for a complete example with an anchor scope.
|
package/docs/macros/style.md
CHANGED
|
@@ -23,16 +23,16 @@ other frameworks receive `class` and `style`. Spread the result onto the element
|
|
|
23
23
|
| A stored `style()` result | `base` | Adds the classes of the base |
|
|
24
24
|
|
|
25
25
|
`false`, `null`, and `undefined` add nothing. Ref, keyframes, and view transition
|
|
26
|
-
calls are also inputs; see [`style.ref()`](ref
|
|
27
|
-
[`style.keyframes()`](keyframes
|
|
28
|
-
[`style.viewTransition()`](view-transition
|
|
26
|
+
calls are also inputs; see [`style.ref()`](https://stillwind.dev/docs/macros/ref),
|
|
27
|
+
[`style.keyframes()`](https://stillwind.dev/docs/macros/keyframes), and
|
|
28
|
+
[`style.viewTransition()`](https://stillwind.dev/docs/macros/view-transition).
|
|
29
29
|
|
|
30
30
|
Write utility names as literals. The compiler reads them from the source, so a
|
|
31
31
|
name that your code builds at runtime produces no CSS.
|
|
32
32
|
|
|
33
33
|
Inside an object with variant keys, write utilities only. A `class` field, a
|
|
34
34
|
custom property, a ref, or a stored `style()` result belongs outside that object.
|
|
35
|
-
[invalid-rule-group-input](
|
|
35
|
+
[invalid-rule-group-input](https://stillwind.dev/docs/lints/invalid-rule-group-input) reports these
|
|
36
36
|
inputs.
|
|
37
37
|
|
|
38
38
|
## Static input
|
|
@@ -51,14 +51,14 @@ export const props = style("rounded-md p-4 text-blue-600");
|
|
|
51
51
|
### Compiled code
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
export const props = {className:"
|
|
54
|
+
export const props = {className:"sw_7hd93"};
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
### Generated CSS
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
```css
|
|
61
|
-
.
|
|
61
|
+
.sw_7hd93 {
|
|
62
62
|
padding: calc(var(--spacing) * 4);
|
|
63
63
|
color: var(--color-blue-600);
|
|
64
64
|
border-radius: var(--radius-md);
|
|
@@ -88,18 +88,18 @@ export const props = style("p-4", active && "bg-blue-500", {
|
|
|
88
88
|
import { stillwindClsx } from "stillwind/runtime";
|
|
89
89
|
|
|
90
90
|
declare const active: boolean;
|
|
91
|
-
export const props = {className:stillwindClsx("
|
|
91
|
+
export const props = {className:stillwindClsx("sw_gmm8m",(active) && ("sw_661jk")),style:{"--progress":"0.5"}};
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
### Generated CSS
|
|
95
95
|
|
|
96
96
|
|
|
97
97
|
```css
|
|
98
|
-
.
|
|
98
|
+
.sw_gmm8m {
|
|
99
99
|
padding: calc(var(--spacing) * 4);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
.
|
|
102
|
+
.sw_661jk {
|
|
103
103
|
background-color: var(--color-blue-500);
|
|
104
104
|
}
|
|
105
105
|
```
|
|
@@ -112,7 +112,7 @@ Stillwind imports a checked version that reports invalid values.
|
|
|
112
112
|
A stored `style()` result passed to another call is a base. The compiler places
|
|
113
113
|
the base's CSS before the CSS generated by the call that receives it. The later
|
|
114
114
|
declarations win when the other cascade criteria, such as specificity and
|
|
115
|
-
importance, are equal. See [CSS ordering](
|
|
115
|
+
importance, are equal. See [CSS ordering](https://stillwind.dev/docs/concepts/css-ordering).
|
|
116
116
|
|
|
117
117
|
### Source
|
|
118
118
|
|
|
@@ -128,20 +128,20 @@ export const props = style(base, "p-4 bg-blue-600 text-white");
|
|
|
128
128
|
```ts
|
|
129
129
|
import { stillwindClassNameObjectClassKey, stillwindClassNameObjectMerge, stillwindClassNameObjectToFragment } from "stillwind/runtime";
|
|
130
130
|
|
|
131
|
-
const base = {className:"
|
|
132
|
-
export const props = stillwindClassNameObjectMerge({[stillwindClassNameObjectClassKey]:"
|
|
131
|
+
const base = {className:"sw_8pxd9"};
|
|
132
|
+
export const props = stillwindClassNameObjectMerge({[stillwindClassNameObjectClassKey]:"sw_sba7k"},stillwindClassNameObjectToFragment((base)));
|
|
133
133
|
```
|
|
134
134
|
|
|
135
135
|
### Generated CSS
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
```css
|
|
139
|
-
.
|
|
139
|
+
.sw_8pxd9 {
|
|
140
140
|
padding: calc(var(--spacing) * 2);
|
|
141
141
|
border-radius: var(--radius-md);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
.
|
|
144
|
+
.sw_sba7k {
|
|
145
145
|
padding: calc(var(--spacing) * 4);
|
|
146
146
|
color: var(--color-white);
|
|
147
147
|
background-color: var(--color-blue-600);
|
|
@@ -150,12 +150,12 @@ export const props = stillwindClassNameObjectMerge({[stillwindClassNameObjectCla
|
|
|
150
150
|
|
|
151
151
|
A base can come from any framework entrypoint and passes on its classes only.
|
|
152
152
|
The receiving call returns its own framework's props. The base's inline style and
|
|
153
|
-
custom properties do not carry over, and [invalid-style-composition](
|
|
153
|
+
custom properties do not carry over, and [invalid-style-composition](https://stillwind.dev/docs/lints/invalid-style-composition)
|
|
154
154
|
reports them. Set them in the call that receives the base.
|
|
155
155
|
|
|
156
156
|
Store a base in a variable before you pass it. A `style()` call written
|
|
157
157
|
directly inside another call produces no CSS, and
|
|
158
|
-
[invalid-style-input](
|
|
158
|
+
[invalid-style-input](https://stillwind.dev/docs/lints/invalid-style-input) reports it.
|
|
159
159
|
|
|
160
160
|
## Argument order
|
|
161
161
|
|
|
@@ -181,11 +181,11 @@ arguments set the same custom property, the later one wins.
|
|
|
181
181
|
|
|
182
182
|
Do not reorder arguments to fix a conflict. Reordering does not change the
|
|
183
183
|
result, and it does not remove a finding of
|
|
184
|
-
[conflicting-utilities](
|
|
185
|
-
[ambiguous-style-base-order](
|
|
186
|
-
[interfering-imported-style-base](
|
|
184
|
+
[conflicting-utilities](https://stillwind.dev/docs/lints/conflicting-utilities),
|
|
185
|
+
[ambiguous-style-base-order](https://stillwind.dev/docs/lints/ambiguous-style-base-order), or
|
|
186
|
+
[interfering-imported-style-base](https://stillwind.dev/docs/lints/interfering-imported-style-base).
|
|
187
187
|
Remove the utility that should not apply, or build the overriding style on the
|
|
188
|
-
other style. [CSS ordering](
|
|
188
|
+
other style. [CSS ordering](https://stillwind.dev/docs/concepts/css-ordering) describes the complete
|
|
189
189
|
rules.
|
|
190
190
|
|
|
191
191
|
## How props combine at runtime
|
|
@@ -203,9 +203,9 @@ combines the inputs:
|
|
|
203
203
|
The compiler can evaluate arguments in any order, and it can skip arguments
|
|
204
204
|
whose result is not used. Arguments must not perform I/O, change shared state,
|
|
205
205
|
or depend on how often they run. Calculate such values before the call.
|
|
206
|
-
[mutating-macro-argument](
|
|
207
|
-
[suspending-macro-argument](
|
|
206
|
+
[mutating-macro-argument](https://stillwind.dev/docs/lints/mutating-macro-argument) and
|
|
207
|
+
[suspending-macro-argument](https://stillwind.dev/docs/lints/suspending-macro-argument) report the
|
|
208
208
|
cases that the CLI can detect.
|
|
209
209
|
|
|
210
|
-
See [The basics of style()](
|
|
211
|
-
[Reusable styles](
|
|
210
|
+
See [The basics of style()](https://stillwind.dev/docs/guides/style) and
|
|
211
|
+
[Reusable styles](https://stillwind.dev/docs/guides/reusable-styles) for task-based guides.
|
|
@@ -6,7 +6,7 @@ description: "Define view transition snapshot styles, and give each element a tr
|
|
|
6
6
|
# style.viewTransition()
|
|
7
7
|
|
|
8
8
|
`style.viewTransition(definition)` defines the styles of view transition
|
|
9
|
-
snapshots. Passing the result to [`style()`](style
|
|
9
|
+
snapshots. Passing the result to [`style()`](https://stillwind.dev/docs/macros/style) adds its
|
|
10
10
|
transition class to the element. Calling `.for(key)` also gives the element a
|
|
11
11
|
[`view-transition-name`](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/view-transition-name).
|
|
12
12
|
|
|
@@ -28,28 +28,28 @@ export const props = style(transition.for("product-42"));
|
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
30
|
const transition = undefined;
|
|
31
|
-
export const props = {className:"
|
|
31
|
+
export const props = {className:"sw_vue90"};
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
### Generated CSS
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
```css
|
|
38
|
-
::view-transition-old(.sw-vt-
|
|
38
|
+
::view-transition-old(.sw-vt-6lpts) {
|
|
39
39
|
animation-duration: .15s;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
::view-transition-new(.sw-vt-
|
|
42
|
+
::view-transition-new(.sw-vt-6lpts) {
|
|
43
43
|
animation-delay: .15s;
|
|
44
44
|
animation-duration: .15s;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
.
|
|
48
|
-
view-transition-class: sw-vt-
|
|
47
|
+
.sw_vue90 {
|
|
48
|
+
view-transition-class: sw-vt-6lpts;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.
|
|
52
|
-
view-transition-name: sw-vt-
|
|
51
|
+
.sw_vue90 {
|
|
52
|
+
view-transition-name: sw-vt-6lpts-product-42;
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -118,23 +118,23 @@ import { stillwindViewTransitionName } from "stillwind/runtime";
|
|
|
118
118
|
const transition = undefined;
|
|
119
119
|
|
|
120
120
|
declare const id: string;
|
|
121
|
-
export const props = {className:"
|
|
121
|
+
export const props = {className:"sw_gpjrb",style:{"view-transition-name":stillwindViewTransitionName("sw-vt-6lpts",id)}};
|
|
122
122
|
```
|
|
123
123
|
|
|
124
124
|
### Generated CSS
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
```css
|
|
128
|
-
::view-transition-old(.sw-vt-
|
|
128
|
+
::view-transition-old(.sw-vt-6lpts) {
|
|
129
129
|
animation-duration: .15s;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
::view-transition-new(.sw-vt-
|
|
132
|
+
::view-transition-new(.sw-vt-6lpts) {
|
|
133
133
|
animation-duration: .15s;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
.
|
|
137
|
-
view-transition-class: sw-vt-
|
|
136
|
+
.sw_gpjrb {
|
|
137
|
+
view-transition-class: sw-vt-6lpts;
|
|
138
138
|
}
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -152,9 +152,9 @@ Pass the other definitions without `.for()`, such as `style(fade, slide.for(id))
|
|
|
152
152
|
|
|
153
153
|
Transition classes from separate `style()` calls do not combine. Each call sets
|
|
154
154
|
the whole `view-transition-class` list, so one list replaces the other.
|
|
155
|
-
[split-view-transition-class](
|
|
156
|
-
[duplicate-view-transition-name](
|
|
155
|
+
[split-view-transition-class](https://stillwind.dev/docs/lints/split-view-transition-class) and
|
|
156
|
+
[duplicate-view-transition-name](https://stillwind.dev/docs/lints/duplicate-view-transition-name)
|
|
157
157
|
report these cases.
|
|
158
158
|
|
|
159
|
-
See [View transitions](
|
|
159
|
+
See [View transitions](https://stillwind.dev/docs/guides/view-transitions) to start a transition
|
|
160
160
|
from your application.
|
package/docs/macros/when.md
CHANGED
|
@@ -6,9 +6,9 @@ description: "Store a variant sequence or alternatives, such as a ref condition,
|
|
|
6
6
|
# style.when()
|
|
7
7
|
|
|
8
8
|
`style.when(...variants)` stores a sequence of variants in a variable. Use the
|
|
9
|
-
variable in [`style()`](style
|
|
9
|
+
variable in [`style()`](https://stillwind.dev/docs/macros/style) where you would write the variants.
|
|
10
10
|
This helps when several elements need the same
|
|
11
|
-
[ref condition](ref/condition
|
|
11
|
+
[ref condition](https://stillwind.dev/docs/macros/ref/condition), because a ref call must otherwise
|
|
12
12
|
be repeated in each `style()` call.
|
|
13
13
|
|
|
14
14
|
## Example
|
|
@@ -32,29 +32,29 @@ export const arrow = style(`${cardHover}:translate-x-1`);
|
|
|
32
32
|
const card = undefined;
|
|
33
33
|
const cardHover = undefined;
|
|
34
34
|
|
|
35
|
-
export const root = {className:"
|
|
36
|
-
export const title = {className:"
|
|
37
|
-
export const arrow = {className:"
|
|
35
|
+
export const root = {className:"sw_1tsgv sw_card_nudp9"};
|
|
36
|
+
export const title = {className:"sw_0m922"};
|
|
37
|
+
export const arrow = {className:"sw_nlo24"};
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Generated CSS
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
```css
|
|
44
|
-
.
|
|
44
|
+
.sw_1tsgv {
|
|
45
45
|
border-radius: var(--radius-lg);
|
|
46
46
|
border-style: var(--tw-border-style);
|
|
47
47
|
border-width: 1px;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
@media (hover: hover) {
|
|
51
|
-
.
|
|
51
|
+
.sw_0m922:is(:where(.sw_card_nudp9):hover *) {
|
|
52
52
|
color: var(--color-blue-600);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@media (hover: hover) {
|
|
57
|
-
.
|
|
57
|
+
.sw_nlo24:is(:where(.sw_card_nudp9):hover *) {
|
|
58
58
|
--tw-translate-x: calc(var(--spacing) * 1);
|
|
59
59
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
60
60
|
}
|
|
@@ -72,8 +72,8 @@ The final colon is optional.
|
|
|
72
72
|
| Form | Example |
|
|
73
73
|
| ------------------------------------------------------------- | --------------------------------------- |
|
|
74
74
|
| A string literal of variants | `style.when("hover:md")` |
|
|
75
|
-
| A [ref condition](ref/condition
|
|
76
|
-
| A [container query](ref/at
|
|
75
|
+
| A [ref condition](https://stillwind.dev/docs/macros/ref/condition), with `.in()` | `style.when(card("hover").in(list))` |
|
|
76
|
+
| A [container query](https://stillwind.dev/docs/macros/ref/at) | `style.when(card.at("width >= 40rem"))` |
|
|
77
77
|
| A template literal whose interpolations are complete variants | ``style.when(`md:${card("hover")}`)`` |
|
|
78
78
|
| Another stored variant | `style.when(cardHover)` |
|
|
79
79
|
|
|
@@ -85,7 +85,7 @@ Write the call as the initial value of a variable, outside other Stillwind
|
|
|
85
85
|
calls. Declare a stored variant before another `style.when()` call uses it.
|
|
86
86
|
A `style()` call can use one that is declared later in the module.
|
|
87
87
|
|
|
88
|
-
[invalid-stored-variant](
|
|
88
|
+
[invalid-stored-variant](https://stillwind.dev/docs/lints/invalid-stored-variant) reports an
|
|
89
89
|
argument that is not a sequence of variants.
|
|
90
90
|
|
|
91
91
|
## Alternatives
|
|
@@ -102,7 +102,7 @@ export const title = style({ [active]: "text-blue-600" });
|
|
|
102
102
|
A use means the same as writing the use once for each argument, in argument
|
|
103
103
|
order. `title` is equal to
|
|
104
104
|
`style({ "hover:": "text-blue-600", [card("focus-within")]: "text-blue-600" })`.
|
|
105
|
-
Unlike an [`or(...)`](
|
|
105
|
+
Unlike an [`or(...)`](https://stillwind.dev/docs/guides/style#match-any-of-several-variants)
|
|
106
106
|
variant, the arguments can be ref conditions and container queries.
|
|
107
107
|
|
|
108
108
|
## Uses
|
|
@@ -119,7 +119,7 @@ refer to one stored variant. A choice at runtime, such as
|
|
|
119
119
|
`[active ? cardHover : cardFocus]`, does not work, because the compiler
|
|
120
120
|
expands the variants at build time. Write a key for each stored variant instead.
|
|
121
121
|
|
|
122
|
-
[`style.cva()`](cva
|
|
122
|
+
[`style.cva()`](https://stillwind.dev/docs/macros/cva) values and [`.in()`](https://stillwind.dev/docs/macros/ref/in)
|
|
123
123
|
do not accept a stored variant.
|
|
124
124
|
|
|
125
125
|
## Output
|