stillwind 0.0.0 → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_TEMPLATE.md +5 -0
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/TAILWINDCSS-MIT-LICENSE +21 -0
- package/css/builtin-metadata/sw-motion-properties.css +186 -0
- package/css/builtin-metadata/tw-legacy-metadata.css +36 -0
- package/css/builtin-metadata/tw-properties.css +944 -0
- package/css/builtin-metadata/tw-registry-metadata.css +52 -0
- package/css/builtin-metadata/tw-relationship-metadata.css +10 -0
- package/css/builtin-utilities/sw-motion-contexts.css +1043 -0
- package/css/builtin-utilities/tw-backgrounds.css +606 -0
- package/css/builtin-utilities/tw-borders.css +954 -0
- package/css/builtin-utilities/tw-effects.css +1209 -0
- package/css/builtin-utilities/tw-flex-grid.css +749 -0
- package/css/builtin-utilities/tw-interactivity.css +680 -0
- package/css/builtin-utilities/tw-layout.css +943 -0
- package/css/builtin-utilities/tw-masks.css +1268 -0
- package/css/builtin-utilities/tw-motion.css +142 -0
- package/css/builtin-utilities/tw-spacing-sizing.css +621 -0
- package/css/builtin-utilities/tw-svg.css +50 -0
- package/css/builtin-utilities/tw-transforms.css +652 -0
- package/css/builtin-utilities/tw-typography.css +720 -0
- package/css/builtin-variants/sw-conditional.css +5 -0
- package/css/builtin-variants/sw-document.css +13 -0
- package/css/builtin-variants/tw-conditional.css +187 -0
- package/css/builtin-variants/tw-dynamic-selector.css +49 -0
- package/css/builtin-variants/tw-relationship.css +41 -0
- package/css/builtin-variants/tw-state.css +159 -0
- package/css/builtin-variants/tw-structural.css +121 -0
- package/css/builtins.css +111 -0
- package/css/preflight.css +401 -0
- package/css/templates.css +40 -0
- package/css/theme.css +546 -0
- package/css/utilities.css +9 -0
- package/dist/class-object-D24FFYqO.js +6 -0
- package/dist/class-object-D24FFYqO.js.map +1 -0
- package/dist/class-object-D7ZGJOf_.d.ts +9 -0
- package/dist/class-string-CQHnc9GN.d.ts +9 -0
- package/dist/class-string-Db8-oI4q.js +6 -0
- package/dist/class-string-Db8-oI4q.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/css.d.ts +100 -0
- package/dist/css.js +143 -0
- package/dist/css.js.map +1 -0
- package/dist/cva-BwX07CFw.js +204 -0
- package/dist/cva-BwX07CFw.js.map +1 -0
- package/dist/cva-DSpDNBYi.d.ts +9 -0
- package/dist/development-DttPQc71.d.ts +27 -0
- package/dist/development-J-JCSIm0.js +111 -0
- package/dist/development-J-JCSIm0.js.map +1 -0
- package/dist/frameworks/alpine.d.ts +20 -0
- package/dist/frameworks/alpine.js +18 -0
- package/dist/frameworks/alpine.js.map +1 -0
- package/dist/frameworks/astro.d.ts +3 -0
- package/dist/frameworks/astro.js +1 -0
- package/dist/frameworks/lit.d.ts +21 -0
- package/dist/frameworks/lit.js +38 -0
- package/dist/frameworks/lit.js.map +1 -0
- package/dist/frameworks/preact.d.ts +3 -0
- package/dist/frameworks/preact.js +1 -0
- package/dist/frameworks/qwik.d.ts +3 -0
- package/dist/frameworks/qwik.js +1 -0
- package/dist/frameworks/react.d.ts +10 -0
- package/dist/frameworks/react.js +6 -0
- package/dist/frameworks/react.js.map +1 -0
- package/dist/frameworks/solid.d.ts +3 -0
- package/dist/frameworks/solid.js +1 -0
- package/dist/frameworks/svelte.d.ts +3 -0
- package/dist/frameworks/svelte.js +1 -0
- package/dist/frameworks/vanilla.d.ts +27 -0
- package/dist/frameworks/vanilla.js +3 -0
- package/dist/frameworks/vue.d.ts +3 -0
- package/dist/frameworks/vue.js +1 -0
- package/dist/index-RwVFpxhE.d.ts +815 -0
- package/dist/macro/index.d.ts +2 -0
- package/dist/macro/index.js +1 -0
- package/dist/module-css.d.ts +30 -0
- package/dist/module-css.js +23 -0
- package/dist/module-css.js.map +1 -0
- package/dist/runtime/class-name-object-development.d.ts +10 -0
- package/dist/runtime/class-name-object-development.js +18 -0
- package/dist/runtime/class-name-object-development.js.map +1 -0
- package/dist/runtime/class-name-object.d.ts +16 -0
- package/dist/runtime/class-name-object.js +31 -0
- package/dist/runtime/class-name-object.js.map +1 -0
- package/dist/runtime/class-object-development.d.ts +10 -0
- package/dist/runtime/class-object-development.js +18 -0
- package/dist/runtime/class-object-development.js.map +1 -0
- package/dist/runtime/class-object.d.ts +16 -0
- package/dist/runtime/class-object.js +31 -0
- package/dist/runtime/class-object.js.map +1 -0
- package/dist/runtime/class-string-development.d.ts +10 -0
- package/dist/runtime/class-string-development.js +18 -0
- package/dist/runtime/class-string-development.js.map +1 -0
- package/dist/runtime/class-string.d.ts +16 -0
- package/dist/runtime/class-string.js +31 -0
- package/dist/runtime/class-string.js.map +1 -0
- package/dist/shared-B9IQXU6P.d.ts +32 -0
- package/dist/style-BV4ctkni.js +78 -0
- package/dist/style-BV4ctkni.js.map +1 -0
- package/dist/style-fTQbsVWZ.js +41 -0
- package/dist/style-fTQbsVWZ.js.map +1 -0
- package/docs/agents.md +76 -0
- package/docs/at-rules/apply.md +93 -0
- package/docs/at-rules/custom-variant.md +127 -0
- package/docs/at-rules/index.md +75 -0
- package/docs/at-rules/plugin.md +71 -0
- package/docs/at-rules/registry-directives.md +181 -0
- package/docs/at-rules/slot.md +58 -0
- package/docs/at-rules/stillwind-css-template.md +126 -0
- package/docs/at-rules/stillwind-property.md +133 -0
- package/docs/at-rules/stillwind-registry.md +115 -0
- package/docs/at-rules/stillwind-require-properties.md +91 -0
- package/docs/at-rules/stillwind-slot.md +85 -0
- package/docs/at-rules/stillwind-undef-arbitrary-property.md +75 -0
- package/docs/at-rules/stillwind-undef-utility.md +87 -0
- package/docs/at-rules/stillwind-undef-variant.md +55 -0
- package/docs/at-rules/theme.md +304 -0
- package/docs/at-rules/utility.md +286 -0
- package/docs/at-rules/variant.md +91 -0
- package/docs/concepts/css-ordering.md +245 -0
- package/docs/concepts/how-styles-compile.md +132 -0
- package/docs/configuration.md +298 -0
- package/docs/errors/SW01001.md +51 -0
- package/docs/errors/SW01002.md +52 -0
- package/docs/errors/SW01003.md +69 -0
- package/docs/errors/SW02001.md +23 -0
- package/docs/errors/SW02002.md +51 -0
- package/docs/errors/SW03001.md +71 -0
- package/docs/errors/SW03002.md +79 -0
- package/docs/errors/SW03003.md +36 -0
- package/docs/errors/SW10001.md +34 -0
- package/docs/errors/SW10002.md +36 -0
- package/docs/errors/SW10003.md +30 -0
- package/docs/errors/SW10004.md +39 -0
- package/docs/errors/SW10005.md +35 -0
- package/docs/errors/SW11001.md +37 -0
- package/docs/errors/SW11002.md +65 -0
- package/docs/errors/SW11003.md +20 -0
- package/docs/errors/SW12001.md +43 -0
- package/docs/errors/SW12002.md +42 -0
- package/docs/errors/SW13001.md +35 -0
- package/docs/errors/SW13002.md +33 -0
- package/docs/errors/SW13003.md +18 -0
- package/docs/errors/SW13004.md +45 -0
- package/docs/errors/SW14001.md +44 -0
- package/docs/errors/SW14002.md +47 -0
- package/docs/errors/SW14003.md +38 -0
- package/docs/errors/SW14004.md +48 -0
- package/docs/errors/SW14005.md +51 -0
- package/docs/errors/SW14006.md +19 -0
- package/docs/errors/SW14007.md +35 -0
- package/docs/errors/SW14008.md +41 -0
- package/docs/errors/SW15001.md +18 -0
- package/docs/errors/SW15002.md +19 -0
- package/docs/errors/SW15003.md +16 -0
- package/docs/errors/SW30001.md +21 -0
- package/docs/errors/SW30002.md +18 -0
- package/docs/errors/SW30003.md +17 -0
- package/docs/errors/SW30004.md +18 -0
- package/docs/errors/SW31001.md +20 -0
- package/docs/errors/SW31002.md +17 -0
- package/docs/errors/SW31003.md +18 -0
- package/docs/errors/SW31004.md +20 -0
- package/docs/errors/SW31005.md +18 -0
- package/docs/errors/SW31006.md +17 -0
- package/docs/errors/SW31007.md +18 -0
- package/docs/errors/SW31008.md +16 -0
- package/docs/errors/SW31009.md +18 -0
- package/docs/errors/SW31010.md +16 -0
- package/docs/errors/SW31011.md +17 -0
- package/docs/errors/SW32001.md +18 -0
- package/docs/errors/SW32002.md +45 -0
- package/docs/errors/SW32003.md +43 -0
- package/docs/errors/SW32004.md +17 -0
- package/docs/errors/SW32005.md +40 -0
- package/docs/errors/SW32006.md +18 -0
- package/docs/errors/SW32007.md +20 -0
- package/docs/errors/SW33001.md +17 -0
- package/docs/errors/SW33002.md +17 -0
- package/docs/errors/SW33003.md +17 -0
- package/docs/errors/SW33004.md +17 -0
- package/docs/errors/SW33005.md +20 -0
- package/docs/errors/SW34001.md +18 -0
- package/docs/errors/SW34002.md +17 -0
- package/docs/errors/SW34003.md +18 -0
- package/docs/errors/SW90001.md +17 -0
- package/docs/errors/SW90002.md +18 -0
- package/docs/errors/SW90003.md +17 -0
- package/docs/errors/SW90004.md +17 -0
- package/docs/errors/SW90005.md +16 -0
- package/docs/errors/SW90006.md +17 -0
- package/docs/errors/SW90007.md +17 -0
- package/docs/errors/SW90008.md +17 -0
- package/docs/errors/index.md +125 -0
- package/docs/guides/animations.md +73 -0
- package/docs/guides/design-systems.md +119 -0
- package/docs/guides/element-relationships.md +136 -0
- package/docs/guides/lint-adoption.md +128 -0
- package/docs/guides/migrating-from-css.md +126 -0
- package/docs/guides/migrating-from-tailwind.md +179 -0
- package/docs/guides/recommended-practices.md +338 -0
- package/docs/guides/responsive-styles.md +103 -0
- package/docs/guides/reusable-styles.md +110 -0
- package/docs/guides/style.md +181 -0
- package/docs/guides/tailwind-compatibility.md +126 -0
- package/docs/guides/view-transitions.md +84 -0
- package/docs/guides/web-components.md +216 -0
- package/docs/index.md +136 -0
- package/docs/integrations.md +190 -0
- package/docs/lints/ambiguous-style-base-order.md +50 -0
- package/docs/lints/bypassed-undefinition.md +50 -0
- package/docs/lints/clamped-value.md +44 -0
- package/docs/lints/conflicting-provider-properties.md +47 -0
- package/docs/lints/conflicting-utilities.md +55 -0
- package/docs/lints/document-scoped-selector.md +45 -0
- package/docs/lints/duplicate-definition.md +44 -0
- package/docs/lints/duplicate-utility.md +44 -0
- package/docs/lints/duplicate-view-transition-name.md +45 -0
- package/docs/lints/ignored-definition-condition.md +51 -0
- package/docs/lints/ignored-tailwind-feature.md +62 -0
- package/docs/lints/incompatible-property-value.md +60 -0
- package/docs/lints/incompatible-theme-value.md +46 -0
- package/docs/lints/index.md +140 -0
- package/docs/lints/ineffective-anchor-scope.md +46 -0
- package/docs/lints/interfering-imported-style-base.md +57 -0
- package/docs/lints/invalid-animation-option.md +47 -0
- package/docs/lints/invalid-css-directive.md +43 -0
- package/docs/lints/invalid-css-import.md +43 -0
- package/docs/lints/invalid-css-input.md +45 -0
- package/docs/lints/invalid-cva-config.md +46 -0
- package/docs/lints/invalid-cva-input.md +50 -0
- package/docs/lints/invalid-keyframes-definition.md +47 -0
- package/docs/lints/invalid-keyframes-use.md +47 -0
- package/docs/lints/invalid-keyframes-variant.md +48 -0
- package/docs/lints/invalid-lint-suppression.md +47 -0
- package/docs/lints/invalid-marker-use.md +53 -0
- package/docs/lints/invalid-media-query.md +52 -0
- package/docs/lints/invalid-ref-input.md +49 -0
- package/docs/lints/invalid-rule-group-input.md +58 -0
- package/docs/lints/invalid-runtime-condition.md +67 -0
- package/docs/lints/invalid-style-composition.md +52 -0
- package/docs/lints/invalid-style-input.md +47 -0
- package/docs/lints/invalid-theme-reference.md +52 -0
- package/docs/lints/invalid-utility.md +44 -0
- package/docs/lints/invalid-variant.md +45 -0
- package/docs/lints/invalid-view-transition-definition.md +46 -0
- package/docs/lints/invalid-view-transition-use.md +46 -0
- package/docs/lints/invalid-view-transition-variant.md +51 -0
- package/docs/lints/mismatched-framework-import.md +47 -0
- package/docs/lints/missing-document-target.md +44 -0
- package/docs/lints/missing-ref-attachment.md +44 -0
- package/docs/lints/missing-view-transition-name.md +46 -0
- package/docs/lints/mutating-macro-argument.md +48 -0
- package/docs/lints/no-arbitrary-breakpoints.md +50 -0
- package/docs/lints/no-arbitrary-colors.md +51 -0
- package/docs/lints/no-arbitrary-spacing.md +57 -0
- package/docs/lints/no-class-property.md +58 -0
- package/docs/lints/no-important.md +50 -0
- package/docs/lints/no-restricted-declarations.md +76 -0
- package/docs/lints/no-restricted-length-units.md +73 -0
- package/docs/lints/no-restricted-theme-tokens.md +73 -0
- package/docs/lints/no-restricted-utilities.md +73 -0
- package/docs/lints/prefer-canonical-utilities.md +69 -0
- package/docs/lints/prefer-direct-styling.md +47 -0
- package/docs/lints/prefer-explicit-nesting-selector.md +42 -0
- package/docs/lints/prefer-logical-properties.md +49 -0
- package/docs/lints/prefer-sorted-utilities.md +46 -0
- package/docs/lints/prefer-typed-relationships.md +48 -0
- package/docs/lints/prefer-typed-variables.md +43 -0
- package/docs/lints/prefer-variant-directive.md +59 -0
- package/docs/lints/redundant-variant.md +50 -0
- package/docs/lints/repeated-nesting-selector.md +59 -0
- package/docs/lints/runtime-condition-requires-css-if.md +59 -0
- package/docs/lints/split-view-transition-class.md +47 -0
- package/docs/lints/suspending-macro-argument.md +46 -0
- package/docs/lints/unknown-utility.md +47 -0
- package/docs/lints/unknown-variant.md +42 -0
- package/docs/lints/unsatisfiable-variants.md +42 -0
- package/docs/lints/unused-lint-suppression.md +57 -0
- package/docs/lints/unverified-style-base.md +64 -0
- package/docs/macros/anchor-scope.md +90 -0
- package/docs/macros/css.md +68 -0
- package/docs/macros/cva.md +153 -0
- package/docs/macros/index.md +30 -0
- package/docs/macros/keyframes.md +98 -0
- package/docs/macros/media.md +65 -0
- package/docs/macros/ref/as-anchor.md +70 -0
- package/docs/macros/ref/as-container.md +64 -0
- package/docs/macros/ref/at.md +68 -0
- package/docs/macros/ref/condition.md +86 -0
- package/docs/macros/ref/in.md +81 -0
- package/docs/macros/ref/index.md +115 -0
- package/docs/macros/ref/position-anchor.md +64 -0
- package/docs/macros/style.md +185 -0
- package/docs/macros/view-transition.md +159 -0
- package/docs/utilities.md +35 -0
- package/docs/why.md +144 -0
- package/index.css +7 -0
- package/package.json +135 -8
- package/skills/migrate-to-stillwind/SKILL.md +81 -0
- package/skills/setup-stillwind/SKILL.md +51 -0
- package/skills/stillwind/SKILL.md +54 -0
- package/index.js +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.media()"
|
|
3
|
+
description: "Turn named breakpoints and other media variants into a media query string for JavaScript."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.media()
|
|
7
|
+
|
|
8
|
+
`style.media(...conditions)` returns a media query string, such as the argument
|
|
9
|
+
of `matchMedia()`. It uses the definitions of variants such as `md:` and
|
|
10
|
+
`motion-safe:` from your stylesheet, so JavaScript and CSS use the same
|
|
11
|
+
conditions.
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
### Source
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { style } from "stillwind/react";
|
|
19
|
+
|
|
20
|
+
export const query = style.media("md:motion-safe", "print");
|
|
21
|
+
export const matches = window.matchMedia(query);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Compiled code
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export const query = "(width >= 48rem) and (prefers-reduced-motion: no-preference), print";
|
|
28
|
+
export const matches = window.matchMedia(query);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Generated CSS
|
|
32
|
+
|
|
33
|
+
This macro adds no CSS to the stylesheet.
|
|
34
|
+
|
|
35
|
+
This query matches a viewport at least as wide as `md` without a reduced-motion
|
|
36
|
+
preference, or a printed page.
|
|
37
|
+
|
|
38
|
+
## Inputs
|
|
39
|
+
|
|
40
|
+
Each argument is a string literal or a template literal without interpolations.
|
|
41
|
+
It contains one or more variants. The final colon is optional.
|
|
42
|
+
|
|
43
|
+
| Form | Meaning |
|
|
44
|
+
| ------------------------ | -------------------------------- |
|
|
45
|
+
| Variants in one argument | Every condition must match |
|
|
46
|
+
| Several arguments | At least one argument must match |
|
|
47
|
+
|
|
48
|
+
Only variants that are media conditions are accepted. `hover` and other element
|
|
49
|
+
states, `supports-*`, and container queries are not media conditions. An
|
|
50
|
+
argument that is not a media condition is left out, and
|
|
51
|
+
[invalid-media-query](../lints/invalid-media-query.md) reports it. When no
|
|
52
|
+
argument remains, the result is `not all`.
|
|
53
|
+
|
|
54
|
+
Write `style.media()` outside other Stillwind calls.
|
|
55
|
+
|
|
56
|
+
## Output
|
|
57
|
+
|
|
58
|
+
The compiler replaces the call with a string literal. The string has no `@media`
|
|
59
|
+
and no braces. The call adds no CSS.
|
|
60
|
+
|
|
61
|
+
When you change a breakpoint in your stylesheet, the string changes the next
|
|
62
|
+
time the module compiles.
|
|
63
|
+
|
|
64
|
+
`matchMedia()` is a browser API. Call it on the client, and remove its listeners
|
|
65
|
+
when their component unmounts. See [Responsive styles](../guides/responsive-styles.md).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref.asAnchor()"
|
|
3
|
+
description: "Make the element that has a ref a named anchor for CSS anchor positioning."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref.asAnchor()
|
|
7
|
+
|
|
8
|
+
`trigger.asAnchor(scope?)` sets `anchor-name` on the element. Position another
|
|
9
|
+
element against it with [`trigger.positionAnchor()`](position-anchor.md).
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
### Source
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { style } from "stillwind/react";
|
|
17
|
+
|
|
18
|
+
const trigger = style.ref("trigger");
|
|
19
|
+
export const button = style(trigger, trigger.asAnchor());
|
|
20
|
+
export const popover = style("absolute", trigger.positionAnchor(), "top-[anchor(bottom)]");
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Compiled code
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const trigger = undefined;
|
|
27
|
+
export const button = {className:"sw_l9spr sw_trigger_xnn7w"};
|
|
28
|
+
export const popover = {className:"sw_mqosh"};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Generated CSS
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
```css
|
|
35
|
+
.sw_l9spr:where(.sw_trigger_xnn7w) {
|
|
36
|
+
anchor-name: --sw-a-trigger-xnn7w;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.sw_mqosh {
|
|
40
|
+
position-anchor: --sw-a-trigger-xnn7w;
|
|
41
|
+
position: absolute;
|
|
42
|
+
top: anchor(bottom);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Inputs
|
|
47
|
+
|
|
48
|
+
The optional scope also sets `anchor-scope` on the element:
|
|
49
|
+
|
|
50
|
+
| Scope | Effect |
|
|
51
|
+
| ---------------- | -------------------------------------------------- |
|
|
52
|
+
| Omitted | Sets no `anchor-scope` |
|
|
53
|
+
| `"all"` | Limits every anchor name to this element's subtree |
|
|
54
|
+
| `"none"` | Sets `anchor-scope: none` |
|
|
55
|
+
| An array of refs | Limits the anchor names of those refs |
|
|
56
|
+
|
|
57
|
+
Write the array directly in the call. The array includes the `trigger` ref only
|
|
58
|
+
when you list it. An empty array sets nothing, and
|
|
59
|
+
[ineffective-anchor-scope](../../lints/ineffective-anchor-scope.md) reports it.
|
|
60
|
+
|
|
61
|
+
## Behavior
|
|
62
|
+
|
|
63
|
+
Pass `trigger` and `trigger.asAnchor()` in the same `style()` call. The anchor
|
|
64
|
+
name applies only to an element that has the ref, and
|
|
65
|
+
[missing-ref-attachment](../../lints/missing-ref-attachment.md) reports a call
|
|
66
|
+
without it.
|
|
67
|
+
|
|
68
|
+
To limit the anchor name from an ancestor instead, use
|
|
69
|
+
[style.anchorScope()](../anchor-scope.md). Stillwind generates CSS only,
|
|
70
|
+
so check that the browsers you support implement anchor positioning.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref.asContainer()"
|
|
3
|
+
description: "Make the element that has a ref a named container for ref.at() queries."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref.asContainer()
|
|
7
|
+
|
|
8
|
+
`card.asContainer(type?)` sets `container-name` on the element, and it sets
|
|
9
|
+
`container-type` when you pass a type. Query the container with
|
|
10
|
+
[`card.at()`](at.md).
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const card = style.ref("card");
|
|
20
|
+
export const container = style(card, card.asContainer("inline-size"), "p-4");
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Compiled code
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const card = undefined;
|
|
27
|
+
export const container = {className:"sw_j0tj8 sw_card_uryy0"};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Generated CSS
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
.sw_j0tj8 {
|
|
35
|
+
padding: calc(var(--spacing) * 4);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sw_j0tj8:where(.sw_card_uryy0) {
|
|
39
|
+
container-name: sw-c-card-uryy0;
|
|
40
|
+
container-type: inline-size;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Inputs
|
|
45
|
+
|
|
46
|
+
The type is a string literal:
|
|
47
|
+
|
|
48
|
+
- `normal`, `size`, `inline-size`, or `scroll-state`
|
|
49
|
+
- a supported combination of these
|
|
50
|
+
- a CSS-wide keyword
|
|
51
|
+
|
|
52
|
+
Without a type, Stillwind does not set `container-type`, and the cascade decides
|
|
53
|
+
its value. A type stored in a variable is not accepted.
|
|
54
|
+
|
|
55
|
+
## Behavior
|
|
56
|
+
|
|
57
|
+
Pass `card` and `card.asContainer()` in the same `style()` call. The container
|
|
58
|
+
declarations apply only to an element that has the ref, and
|
|
59
|
+
[missing-ref-attachment](../../lints/missing-ref-attachment.md) reports a call
|
|
60
|
+
without it.
|
|
61
|
+
|
|
62
|
+
When another rule on the element also sets `container-name` or `container-type`,
|
|
63
|
+
[conflicting-provider-properties](../../lints/conflicting-provider-properties.md)
|
|
64
|
+
reports it.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref.at()"
|
|
3
|
+
description: "Style an element with a container query on the element that has a ref."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref.at()
|
|
7
|
+
|
|
8
|
+
`card.at(query?)` creates a container query on the container that the `card` ref
|
|
9
|
+
names. Make that element a container with
|
|
10
|
+
[`card.asContainer()`](as-container.md).
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const card = style.ref("card");
|
|
20
|
+
export const container = style(card, card.asContainer("inline-size"));
|
|
21
|
+
export const child = style({ [card.at("width >= 40rem")]: "grid-cols-2" });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Compiled code
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const card = undefined;
|
|
28
|
+
export const container = {className:"sw_28iqw sw_card_uryy0"};
|
|
29
|
+
export const child = {className:"sw_cunr1"};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Generated CSS
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
.sw_28iqw:where(.sw_card_uryy0) {
|
|
37
|
+
container-name: sw-c-card-uryy0;
|
|
38
|
+
container-type: inline-size;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@container sw-c-card-uryy0 (width >= 40rem) {
|
|
42
|
+
.sw_cunr1 {
|
|
43
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Inputs
|
|
49
|
+
|
|
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>` |
|
|
55
|
+
|
|
56
|
+
Write the query as a string literal or a tagged template without interpolations.
|
|
57
|
+
Leave out the outer parentheses.
|
|
58
|
+
|
|
59
|
+
## Behavior
|
|
60
|
+
|
|
61
|
+
Without a query, the condition matches whenever the styled element is inside a
|
|
62
|
+
container with the name.
|
|
63
|
+
|
|
64
|
+
Write the call directly as a computed key in `style()`. You cannot store it in a
|
|
65
|
+
variable and use it later.
|
|
66
|
+
|
|
67
|
+
See [Element relationships](../../guides/element-relationships.md#react-to-a-containers-size)
|
|
68
|
+
for a task-based example.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref() conditions"
|
|
3
|
+
description: "Style an element while an ancestor with a ref exists or matches variants such as hover."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref() conditions
|
|
7
|
+
|
|
8
|
+
Calling a ref creates a condition on the ref element. `card()` matches inside the
|
|
9
|
+
element that has the `card` ref. `card("hover")` matches there while that element
|
|
10
|
+
is hovered.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const card = style.ref("card");
|
|
20
|
+
export const container = style(card, "rounded-lg p-4");
|
|
21
|
+
export const title = style({ [card("hover")]: "text-blue-600" });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Compiled code
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
const card = undefined;
|
|
28
|
+
export const container = {className:"sw_vw9g3 sw_card_uryy0"};
|
|
29
|
+
export const title = {className:"sw_c67by"};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Generated CSS
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
```css
|
|
36
|
+
.sw_vw9g3 {
|
|
37
|
+
padding: calc(var(--spacing) * 4);
|
|
38
|
+
border-radius: var(--radius-lg);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media (hover: hover) {
|
|
42
|
+
.sw_c67by:is(:where(.sw_card_uryy0):hover *) {
|
|
43
|
+
color: var(--color-blue-600);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Inputs
|
|
49
|
+
|
|
50
|
+
| Form | Matches |
|
|
51
|
+
| ---------------------- | ----------------------------------------------------- |
|
|
52
|
+
| `card()` | Inside the ref element |
|
|
53
|
+
| `card("hover")` | Inside the ref element while it matches the variant |
|
|
54
|
+
| `card("hover:active")` | Inside the ref element while it matches every variant |
|
|
55
|
+
| ``card`hover` `` | The same as `card("hover")` |
|
|
56
|
+
|
|
57
|
+
The argument is a string literal or a tagged template without interpolations.
|
|
58
|
+
The final colon is optional.
|
|
59
|
+
|
|
60
|
+
## Where to write it
|
|
61
|
+
|
|
62
|
+
Write the condition as a computed key of an object in `style()`:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
style({ [card("hover")]: "text-blue-600" });
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You can also write it as a variant segment inside a utility template, followed by
|
|
69
|
+
`:`:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
style(`${card("hover")}:text-blue-600`);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You cannot store the condition in a variable and use it later.
|
|
76
|
+
|
|
77
|
+
## Behavior
|
|
78
|
+
|
|
79
|
+
The ref element must be an ancestor of the styled element. To match a sibling or
|
|
80
|
+
another element inside a shared ancestor, add [`.in()`](in.md).
|
|
81
|
+
|
|
82
|
+
The condition only selects elements. It does not attach the ref, so attach it with
|
|
83
|
+
`style(card)` on the ancestor.
|
|
84
|
+
|
|
85
|
+
See [Element relationships](../../guides/element-relationships.md#react-to-a-parents-state)
|
|
86
|
+
for a task-based example.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref().in()"
|
|
3
|
+
description: "Style an element from the state of a sibling, inside an ancestor that has another ref."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref().in()
|
|
7
|
+
|
|
8
|
+
`trigger("hover").in(card)` matches while the `trigger` element is hovered and an
|
|
9
|
+
element with the `card` ref contains both the `trigger` element and the styled
|
|
10
|
+
element. Use it to style an element from the state of a sibling.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const card = style.ref("card");
|
|
20
|
+
const trigger = style.ref("trigger");
|
|
21
|
+
export const container = style(card, "p-4");
|
|
22
|
+
export const button = style(trigger, "rounded-md px-4 py-2");
|
|
23
|
+
export const text = style({ [trigger("hover").in(card)]: "text-blue-600" });
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Compiled code
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const card = undefined;
|
|
30
|
+
const trigger = undefined;
|
|
31
|
+
export const container = {className:"sw_fxivy sw_card_uryy0"};
|
|
32
|
+
export const button = {className:"sw_92u2q sw_trigger_fvqcy"};
|
|
33
|
+
export const text = {className:"sw_yz349"};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Generated CSS
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
.sw_fxivy {
|
|
41
|
+
padding: calc(var(--spacing) * 4);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sw_92u2q {
|
|
45
|
+
padding-inline: calc(var(--spacing) * 4);
|
|
46
|
+
padding-block: calc(var(--spacing) * 2);
|
|
47
|
+
border-radius: var(--radius-md);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@media (hover: hover) {
|
|
51
|
+
.sw_yz349:is(:where(.sw_card_uryy0):has(:where(.sw_trigger_fvqcy):hover) *) {
|
|
52
|
+
color: var(--color-blue-600);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Inputs
|
|
58
|
+
|
|
59
|
+
The receiver is a [ref condition](condition.md), such as
|
|
60
|
+
`trigger("hover")` or `trigger()`. The argument is one of these:
|
|
61
|
+
|
|
62
|
+
| Argument | The scope element |
|
|
63
|
+
| ---------------------- | ------------------------------------------- |
|
|
64
|
+
| `card` | Has the `card` ref |
|
|
65
|
+
| `card("focus-within")` | Has the `card` ref and matches the variants |
|
|
66
|
+
|
|
67
|
+
The argument cannot use `.in()` or `.at()` itself.
|
|
68
|
+
|
|
69
|
+
## Behavior
|
|
70
|
+
|
|
71
|
+
The scope element must be a strict ancestor of both elements. It cannot be the
|
|
72
|
+
styled element itself.
|
|
73
|
+
|
|
74
|
+
Calling `.in()` more than once adds each scope as another condition, and every
|
|
75
|
+
condition must match.
|
|
76
|
+
|
|
77
|
+
Write the whole chain directly as a computed key in `style()`. You cannot store it
|
|
78
|
+
in a variable and use it later.
|
|
79
|
+
|
|
80
|
+
See [Element relationships](../../guides/element-relationships.md#react-to-a-siblings-state)
|
|
81
|
+
for a task-based example.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "style.ref() and ref methods"
|
|
3
|
+
description: "Name an element with a ref, and style other elements from its state, size, or anchor position."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# style.ref() and ref methods
|
|
7
|
+
|
|
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 to
|
|
10
|
+
style other elements from that element's state, size, or position.
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Source
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { style } from "stillwind/react";
|
|
18
|
+
|
|
19
|
+
const card = style.ref("card");
|
|
20
|
+
export const container = style(card, card.asContainer("inline-size"));
|
|
21
|
+
export const child = style({
|
|
22
|
+
[card("hover")]: "text-blue-600",
|
|
23
|
+
[card.at("width >= 40rem")]: "grid-cols-2",
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Compiled code
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const card = undefined;
|
|
31
|
+
export const container = {className:"sw_28iqw sw_card_uryy0"};
|
|
32
|
+
export const child = {className:"sw_6hxbo"};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Generated CSS
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
.sw_28iqw:where(.sw_card_uryy0) {
|
|
40
|
+
container-name: sw-c-card-uryy0;
|
|
41
|
+
container-type: inline-size;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@container sw-c-card-uryy0 (width >= 40rem) {
|
|
45
|
+
.sw_6hxbo {
|
|
46
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@media (hover: hover) {
|
|
51
|
+
.sw_6hxbo:is(:where(.sw_card_uryy0):hover *) {
|
|
52
|
+
color: var(--color-blue-600);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Declare a ref
|
|
58
|
+
|
|
59
|
+
Write `style.ref()` as the initial value of a variable: `const card = style.ref("card")`.
|
|
60
|
+
The declaration can be at the top level of a module, in a function, or in a
|
|
61
|
+
callback such as the one that you pass to `map()`.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
items.map((item) => {
|
|
65
|
+
const row = style.ref("row");
|
|
66
|
+
return (
|
|
67
|
+
<li {...style(row, "p-4")}>
|
|
68
|
+
<span {...style({ [row("hover")]: "underline" })}>{item}</span>
|
|
69
|
+
</li>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The compiler generates a unique name for each `style.ref()` call in the source.
|
|
75
|
+
The name stays the same in every render, loop iteration, and function call. You
|
|
76
|
+
can export a ref, import it, and pass it as an argument.
|
|
77
|
+
|
|
78
|
+
The argument of `style.ref()`, such as `"row"` in `style.ref("row")`, is a
|
|
79
|
+
label. The label only makes the generated names easier to read, such as in the
|
|
80
|
+
browser's developer tools. It does not make the name unique, and you can omit
|
|
81
|
+
it: `const row = style.ref()`. Two refs with the same label stay separate, and
|
|
82
|
+
so do two refs without a label. When you write a label, it must be a string
|
|
83
|
+
literal.
|
|
84
|
+
|
|
85
|
+
Because the name stays the same, a ref cannot distinguish nested elements that
|
|
86
|
+
use the same declaration. For example, a tree node can render its child nodes
|
|
87
|
+
inside its ref element. Every level then has the same name, and
|
|
88
|
+
`node("hover")` matches while any ancestor node is hovered, not only the
|
|
89
|
+
nearest one.
|
|
90
|
+
|
|
91
|
+
## Methods
|
|
92
|
+
|
|
93
|
+
| Method | Where to write it | Effect |
|
|
94
|
+
| ---------------------------------------------------------- | --------------------------- | ------------------------------------------------------ |
|
|
95
|
+
| `ref` | A `style()` 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
|
+
|
|
103
|
+
Write each method call directly in `style()`. You cannot store the result of a
|
|
104
|
+
method call in a variable and use it later.
|
|
105
|
+
|
|
106
|
+
## Generated code
|
|
107
|
+
|
|
108
|
+
When the compiler knows which ref a call uses, the ref becomes plain class names
|
|
109
|
+
and selectors, and the ref variable can become `undefined` in JavaScript. When a
|
|
110
|
+
call chooses among several refs at runtime, the generated code keeps the fields
|
|
111
|
+
that the choice needs. The compiled code reads those fields directly. In
|
|
112
|
+
development, Stillwind checks them first. The code does not watch the DOM.
|
|
113
|
+
|
|
114
|
+
See [Element relationships](../../guides/element-relationships.md) for task-based
|
|
115
|
+
examples.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "ref.positionAnchor()"
|
|
3
|
+
description: "Position the styled element against the anchor that a ref names."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ref.positionAnchor()
|
|
7
|
+
|
|
8
|
+
`trigger.positionAnchor()` sets `position-anchor` on the styled element, so that
|
|
9
|
+
`anchor()` values in its other utilities refer to the `trigger` anchor.
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
### Source
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { style } from "stillwind/react";
|
|
17
|
+
|
|
18
|
+
const trigger = style.ref("trigger");
|
|
19
|
+
export const button = style(trigger, trigger.asAnchor());
|
|
20
|
+
export const popover = style(
|
|
21
|
+
"absolute",
|
|
22
|
+
trigger.positionAnchor(),
|
|
23
|
+
"top-[anchor(bottom)] left-[anchor(left)]",
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Compiled code
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const trigger = undefined;
|
|
31
|
+
export const button = {className:"sw_l9spr sw_trigger_xnn7w"};
|
|
32
|
+
export const popover = {className:"sw_fu7et"};
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Generated CSS
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
.sw_l9spr:where(.sw_trigger_xnn7w) {
|
|
40
|
+
anchor-name: --sw-a-trigger-xnn7w;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.sw_fu7et {
|
|
44
|
+
position-anchor: --sw-a-trigger-xnn7w;
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: anchor(bottom);
|
|
47
|
+
left: anchor(left);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Inputs
|
|
52
|
+
|
|
53
|
+
`positionAnchor()` takes no arguments.
|
|
54
|
+
|
|
55
|
+
## Behavior
|
|
56
|
+
|
|
57
|
+
The styled element does not need the `trigger` ref. The anchor element needs it,
|
|
58
|
+
together with [`trigger.asAnchor()`](as-anchor.md).
|
|
59
|
+
|
|
60
|
+
Write the call directly in `style()`. You cannot store it in a variable and use
|
|
61
|
+
it later.
|
|
62
|
+
|
|
63
|
+
See [Element relationships](../../guides/element-relationships.md#position-an-element-at-an-anchor)
|
|
64
|
+
for a complete example with an anchor scope.
|