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.
Files changed (305) hide show
  1. package/AGENTS_TEMPLATE.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +166 -0
  4. package/TAILWINDCSS-MIT-LICENSE +21 -0
  5. package/css/builtin-metadata/sw-motion-properties.css +186 -0
  6. package/css/builtin-metadata/tw-legacy-metadata.css +36 -0
  7. package/css/builtin-metadata/tw-properties.css +944 -0
  8. package/css/builtin-metadata/tw-registry-metadata.css +52 -0
  9. package/css/builtin-metadata/tw-relationship-metadata.css +10 -0
  10. package/css/builtin-utilities/sw-motion-contexts.css +1043 -0
  11. package/css/builtin-utilities/tw-backgrounds.css +606 -0
  12. package/css/builtin-utilities/tw-borders.css +954 -0
  13. package/css/builtin-utilities/tw-effects.css +1209 -0
  14. package/css/builtin-utilities/tw-flex-grid.css +749 -0
  15. package/css/builtin-utilities/tw-interactivity.css +680 -0
  16. package/css/builtin-utilities/tw-layout.css +943 -0
  17. package/css/builtin-utilities/tw-masks.css +1268 -0
  18. package/css/builtin-utilities/tw-motion.css +142 -0
  19. package/css/builtin-utilities/tw-spacing-sizing.css +621 -0
  20. package/css/builtin-utilities/tw-svg.css +50 -0
  21. package/css/builtin-utilities/tw-transforms.css +652 -0
  22. package/css/builtin-utilities/tw-typography.css +720 -0
  23. package/css/builtin-variants/sw-conditional.css +5 -0
  24. package/css/builtin-variants/sw-document.css +13 -0
  25. package/css/builtin-variants/tw-conditional.css +187 -0
  26. package/css/builtin-variants/tw-dynamic-selector.css +49 -0
  27. package/css/builtin-variants/tw-relationship.css +41 -0
  28. package/css/builtin-variants/tw-state.css +159 -0
  29. package/css/builtin-variants/tw-structural.css +121 -0
  30. package/css/builtins.css +111 -0
  31. package/css/preflight.css +401 -0
  32. package/css/templates.css +40 -0
  33. package/css/theme.css +546 -0
  34. package/css/utilities.css +9 -0
  35. package/dist/class-object-D24FFYqO.js +6 -0
  36. package/dist/class-object-D24FFYqO.js.map +1 -0
  37. package/dist/class-object-D7ZGJOf_.d.ts +9 -0
  38. package/dist/class-string-CQHnc9GN.d.ts +9 -0
  39. package/dist/class-string-Db8-oI4q.js +6 -0
  40. package/dist/class-string-Db8-oI4q.js.map +1 -0
  41. package/dist/config.d.ts +1 -0
  42. package/dist/config.js +2 -0
  43. package/dist/css.d.ts +100 -0
  44. package/dist/css.js +143 -0
  45. package/dist/css.js.map +1 -0
  46. package/dist/cva-BwX07CFw.js +204 -0
  47. package/dist/cva-BwX07CFw.js.map +1 -0
  48. package/dist/cva-DSpDNBYi.d.ts +9 -0
  49. package/dist/development-DttPQc71.d.ts +27 -0
  50. package/dist/development-J-JCSIm0.js +111 -0
  51. package/dist/development-J-JCSIm0.js.map +1 -0
  52. package/dist/frameworks/alpine.d.ts +20 -0
  53. package/dist/frameworks/alpine.js +18 -0
  54. package/dist/frameworks/alpine.js.map +1 -0
  55. package/dist/frameworks/astro.d.ts +3 -0
  56. package/dist/frameworks/astro.js +1 -0
  57. package/dist/frameworks/lit.d.ts +21 -0
  58. package/dist/frameworks/lit.js +38 -0
  59. package/dist/frameworks/lit.js.map +1 -0
  60. package/dist/frameworks/preact.d.ts +3 -0
  61. package/dist/frameworks/preact.js +1 -0
  62. package/dist/frameworks/qwik.d.ts +3 -0
  63. package/dist/frameworks/qwik.js +1 -0
  64. package/dist/frameworks/react.d.ts +10 -0
  65. package/dist/frameworks/react.js +6 -0
  66. package/dist/frameworks/react.js.map +1 -0
  67. package/dist/frameworks/solid.d.ts +3 -0
  68. package/dist/frameworks/solid.js +1 -0
  69. package/dist/frameworks/svelte.d.ts +3 -0
  70. package/dist/frameworks/svelte.js +1 -0
  71. package/dist/frameworks/vanilla.d.ts +27 -0
  72. package/dist/frameworks/vanilla.js +3 -0
  73. package/dist/frameworks/vue.d.ts +3 -0
  74. package/dist/frameworks/vue.js +1 -0
  75. package/dist/index-RwVFpxhE.d.ts +815 -0
  76. package/dist/macro/index.d.ts +2 -0
  77. package/dist/macro/index.js +1 -0
  78. package/dist/module-css.d.ts +30 -0
  79. package/dist/module-css.js +23 -0
  80. package/dist/module-css.js.map +1 -0
  81. package/dist/runtime/class-name-object-development.d.ts +10 -0
  82. package/dist/runtime/class-name-object-development.js +18 -0
  83. package/dist/runtime/class-name-object-development.js.map +1 -0
  84. package/dist/runtime/class-name-object.d.ts +16 -0
  85. package/dist/runtime/class-name-object.js +31 -0
  86. package/dist/runtime/class-name-object.js.map +1 -0
  87. package/dist/runtime/class-object-development.d.ts +10 -0
  88. package/dist/runtime/class-object-development.js +18 -0
  89. package/dist/runtime/class-object-development.js.map +1 -0
  90. package/dist/runtime/class-object.d.ts +16 -0
  91. package/dist/runtime/class-object.js +31 -0
  92. package/dist/runtime/class-object.js.map +1 -0
  93. package/dist/runtime/class-string-development.d.ts +10 -0
  94. package/dist/runtime/class-string-development.js +18 -0
  95. package/dist/runtime/class-string-development.js.map +1 -0
  96. package/dist/runtime/class-string.d.ts +16 -0
  97. package/dist/runtime/class-string.js +31 -0
  98. package/dist/runtime/class-string.js.map +1 -0
  99. package/dist/shared-B9IQXU6P.d.ts +32 -0
  100. package/dist/style-BV4ctkni.js +78 -0
  101. package/dist/style-BV4ctkni.js.map +1 -0
  102. package/dist/style-fTQbsVWZ.js +41 -0
  103. package/dist/style-fTQbsVWZ.js.map +1 -0
  104. package/docs/agents.md +76 -0
  105. package/docs/at-rules/apply.md +93 -0
  106. package/docs/at-rules/custom-variant.md +127 -0
  107. package/docs/at-rules/index.md +75 -0
  108. package/docs/at-rules/plugin.md +71 -0
  109. package/docs/at-rules/registry-directives.md +181 -0
  110. package/docs/at-rules/slot.md +58 -0
  111. package/docs/at-rules/stillwind-css-template.md +126 -0
  112. package/docs/at-rules/stillwind-property.md +133 -0
  113. package/docs/at-rules/stillwind-registry.md +115 -0
  114. package/docs/at-rules/stillwind-require-properties.md +91 -0
  115. package/docs/at-rules/stillwind-slot.md +85 -0
  116. package/docs/at-rules/stillwind-undef-arbitrary-property.md +75 -0
  117. package/docs/at-rules/stillwind-undef-utility.md +87 -0
  118. package/docs/at-rules/stillwind-undef-variant.md +55 -0
  119. package/docs/at-rules/theme.md +304 -0
  120. package/docs/at-rules/utility.md +286 -0
  121. package/docs/at-rules/variant.md +91 -0
  122. package/docs/concepts/css-ordering.md +245 -0
  123. package/docs/concepts/how-styles-compile.md +132 -0
  124. package/docs/configuration.md +298 -0
  125. package/docs/errors/SW01001.md +51 -0
  126. package/docs/errors/SW01002.md +52 -0
  127. package/docs/errors/SW01003.md +69 -0
  128. package/docs/errors/SW02001.md +23 -0
  129. package/docs/errors/SW02002.md +51 -0
  130. package/docs/errors/SW03001.md +71 -0
  131. package/docs/errors/SW03002.md +79 -0
  132. package/docs/errors/SW03003.md +36 -0
  133. package/docs/errors/SW10001.md +34 -0
  134. package/docs/errors/SW10002.md +36 -0
  135. package/docs/errors/SW10003.md +30 -0
  136. package/docs/errors/SW10004.md +39 -0
  137. package/docs/errors/SW10005.md +35 -0
  138. package/docs/errors/SW11001.md +37 -0
  139. package/docs/errors/SW11002.md +65 -0
  140. package/docs/errors/SW11003.md +20 -0
  141. package/docs/errors/SW12001.md +43 -0
  142. package/docs/errors/SW12002.md +42 -0
  143. package/docs/errors/SW13001.md +35 -0
  144. package/docs/errors/SW13002.md +33 -0
  145. package/docs/errors/SW13003.md +18 -0
  146. package/docs/errors/SW13004.md +45 -0
  147. package/docs/errors/SW14001.md +44 -0
  148. package/docs/errors/SW14002.md +47 -0
  149. package/docs/errors/SW14003.md +38 -0
  150. package/docs/errors/SW14004.md +48 -0
  151. package/docs/errors/SW14005.md +51 -0
  152. package/docs/errors/SW14006.md +19 -0
  153. package/docs/errors/SW14007.md +35 -0
  154. package/docs/errors/SW14008.md +41 -0
  155. package/docs/errors/SW15001.md +18 -0
  156. package/docs/errors/SW15002.md +19 -0
  157. package/docs/errors/SW15003.md +16 -0
  158. package/docs/errors/SW30001.md +21 -0
  159. package/docs/errors/SW30002.md +18 -0
  160. package/docs/errors/SW30003.md +17 -0
  161. package/docs/errors/SW30004.md +18 -0
  162. package/docs/errors/SW31001.md +20 -0
  163. package/docs/errors/SW31002.md +17 -0
  164. package/docs/errors/SW31003.md +18 -0
  165. package/docs/errors/SW31004.md +20 -0
  166. package/docs/errors/SW31005.md +18 -0
  167. package/docs/errors/SW31006.md +17 -0
  168. package/docs/errors/SW31007.md +18 -0
  169. package/docs/errors/SW31008.md +16 -0
  170. package/docs/errors/SW31009.md +18 -0
  171. package/docs/errors/SW31010.md +16 -0
  172. package/docs/errors/SW31011.md +17 -0
  173. package/docs/errors/SW32001.md +18 -0
  174. package/docs/errors/SW32002.md +45 -0
  175. package/docs/errors/SW32003.md +43 -0
  176. package/docs/errors/SW32004.md +17 -0
  177. package/docs/errors/SW32005.md +40 -0
  178. package/docs/errors/SW32006.md +18 -0
  179. package/docs/errors/SW32007.md +20 -0
  180. package/docs/errors/SW33001.md +17 -0
  181. package/docs/errors/SW33002.md +17 -0
  182. package/docs/errors/SW33003.md +17 -0
  183. package/docs/errors/SW33004.md +17 -0
  184. package/docs/errors/SW33005.md +20 -0
  185. package/docs/errors/SW34001.md +18 -0
  186. package/docs/errors/SW34002.md +17 -0
  187. package/docs/errors/SW34003.md +18 -0
  188. package/docs/errors/SW90001.md +17 -0
  189. package/docs/errors/SW90002.md +18 -0
  190. package/docs/errors/SW90003.md +17 -0
  191. package/docs/errors/SW90004.md +17 -0
  192. package/docs/errors/SW90005.md +16 -0
  193. package/docs/errors/SW90006.md +17 -0
  194. package/docs/errors/SW90007.md +17 -0
  195. package/docs/errors/SW90008.md +17 -0
  196. package/docs/errors/index.md +125 -0
  197. package/docs/guides/animations.md +73 -0
  198. package/docs/guides/design-systems.md +119 -0
  199. package/docs/guides/element-relationships.md +136 -0
  200. package/docs/guides/lint-adoption.md +128 -0
  201. package/docs/guides/migrating-from-css.md +126 -0
  202. package/docs/guides/migrating-from-tailwind.md +179 -0
  203. package/docs/guides/recommended-practices.md +338 -0
  204. package/docs/guides/responsive-styles.md +103 -0
  205. package/docs/guides/reusable-styles.md +110 -0
  206. package/docs/guides/style.md +181 -0
  207. package/docs/guides/tailwind-compatibility.md +126 -0
  208. package/docs/guides/view-transitions.md +84 -0
  209. package/docs/guides/web-components.md +216 -0
  210. package/docs/index.md +136 -0
  211. package/docs/integrations.md +190 -0
  212. package/docs/lints/ambiguous-style-base-order.md +50 -0
  213. package/docs/lints/bypassed-undefinition.md +50 -0
  214. package/docs/lints/clamped-value.md +44 -0
  215. package/docs/lints/conflicting-provider-properties.md +47 -0
  216. package/docs/lints/conflicting-utilities.md +55 -0
  217. package/docs/lints/document-scoped-selector.md +45 -0
  218. package/docs/lints/duplicate-definition.md +44 -0
  219. package/docs/lints/duplicate-utility.md +44 -0
  220. package/docs/lints/duplicate-view-transition-name.md +45 -0
  221. package/docs/lints/ignored-definition-condition.md +51 -0
  222. package/docs/lints/ignored-tailwind-feature.md +62 -0
  223. package/docs/lints/incompatible-property-value.md +60 -0
  224. package/docs/lints/incompatible-theme-value.md +46 -0
  225. package/docs/lints/index.md +140 -0
  226. package/docs/lints/ineffective-anchor-scope.md +46 -0
  227. package/docs/lints/interfering-imported-style-base.md +57 -0
  228. package/docs/lints/invalid-animation-option.md +47 -0
  229. package/docs/lints/invalid-css-directive.md +43 -0
  230. package/docs/lints/invalid-css-import.md +43 -0
  231. package/docs/lints/invalid-css-input.md +45 -0
  232. package/docs/lints/invalid-cva-config.md +46 -0
  233. package/docs/lints/invalid-cva-input.md +50 -0
  234. package/docs/lints/invalid-keyframes-definition.md +47 -0
  235. package/docs/lints/invalid-keyframes-use.md +47 -0
  236. package/docs/lints/invalid-keyframes-variant.md +48 -0
  237. package/docs/lints/invalid-lint-suppression.md +47 -0
  238. package/docs/lints/invalid-marker-use.md +53 -0
  239. package/docs/lints/invalid-media-query.md +52 -0
  240. package/docs/lints/invalid-ref-input.md +49 -0
  241. package/docs/lints/invalid-rule-group-input.md +58 -0
  242. package/docs/lints/invalid-runtime-condition.md +67 -0
  243. package/docs/lints/invalid-style-composition.md +52 -0
  244. package/docs/lints/invalid-style-input.md +47 -0
  245. package/docs/lints/invalid-theme-reference.md +52 -0
  246. package/docs/lints/invalid-utility.md +44 -0
  247. package/docs/lints/invalid-variant.md +45 -0
  248. package/docs/lints/invalid-view-transition-definition.md +46 -0
  249. package/docs/lints/invalid-view-transition-use.md +46 -0
  250. package/docs/lints/invalid-view-transition-variant.md +51 -0
  251. package/docs/lints/mismatched-framework-import.md +47 -0
  252. package/docs/lints/missing-document-target.md +44 -0
  253. package/docs/lints/missing-ref-attachment.md +44 -0
  254. package/docs/lints/missing-view-transition-name.md +46 -0
  255. package/docs/lints/mutating-macro-argument.md +48 -0
  256. package/docs/lints/no-arbitrary-breakpoints.md +50 -0
  257. package/docs/lints/no-arbitrary-colors.md +51 -0
  258. package/docs/lints/no-arbitrary-spacing.md +57 -0
  259. package/docs/lints/no-class-property.md +58 -0
  260. package/docs/lints/no-important.md +50 -0
  261. package/docs/lints/no-restricted-declarations.md +76 -0
  262. package/docs/lints/no-restricted-length-units.md +73 -0
  263. package/docs/lints/no-restricted-theme-tokens.md +73 -0
  264. package/docs/lints/no-restricted-utilities.md +73 -0
  265. package/docs/lints/prefer-canonical-utilities.md +69 -0
  266. package/docs/lints/prefer-direct-styling.md +47 -0
  267. package/docs/lints/prefer-explicit-nesting-selector.md +42 -0
  268. package/docs/lints/prefer-logical-properties.md +49 -0
  269. package/docs/lints/prefer-sorted-utilities.md +46 -0
  270. package/docs/lints/prefer-typed-relationships.md +48 -0
  271. package/docs/lints/prefer-typed-variables.md +43 -0
  272. package/docs/lints/prefer-variant-directive.md +59 -0
  273. package/docs/lints/redundant-variant.md +50 -0
  274. package/docs/lints/repeated-nesting-selector.md +59 -0
  275. package/docs/lints/runtime-condition-requires-css-if.md +59 -0
  276. package/docs/lints/split-view-transition-class.md +47 -0
  277. package/docs/lints/suspending-macro-argument.md +46 -0
  278. package/docs/lints/unknown-utility.md +47 -0
  279. package/docs/lints/unknown-variant.md +42 -0
  280. package/docs/lints/unsatisfiable-variants.md +42 -0
  281. package/docs/lints/unused-lint-suppression.md +57 -0
  282. package/docs/lints/unverified-style-base.md +64 -0
  283. package/docs/macros/anchor-scope.md +90 -0
  284. package/docs/macros/css.md +68 -0
  285. package/docs/macros/cva.md +153 -0
  286. package/docs/macros/index.md +30 -0
  287. package/docs/macros/keyframes.md +98 -0
  288. package/docs/macros/media.md +65 -0
  289. package/docs/macros/ref/as-anchor.md +70 -0
  290. package/docs/macros/ref/as-container.md +64 -0
  291. package/docs/macros/ref/at.md +68 -0
  292. package/docs/macros/ref/condition.md +86 -0
  293. package/docs/macros/ref/in.md +81 -0
  294. package/docs/macros/ref/index.md +115 -0
  295. package/docs/macros/ref/position-anchor.md +64 -0
  296. package/docs/macros/style.md +185 -0
  297. package/docs/macros/view-transition.md +159 -0
  298. package/docs/utilities.md +35 -0
  299. package/docs/why.md +144 -0
  300. package/index.css +7 -0
  301. package/package.json +135 -8
  302. package/skills/migrate-to-stillwind/SKILL.md +81 -0
  303. package/skills/setup-stillwind/SKILL.md +51 -0
  304. package/skills/stillwind/SKILL.md +54 -0
  305. package/index.js +0 -1
@@ -0,0 +1,103 @@
1
+ ---
2
+ title: "Responsive styles"
3
+ description: "Name breakpoints once, and use them in utilities, authored CSS, and JavaScript."
4
+ ---
5
+
6
+ # Responsive styles
7
+
8
+ You want components to change layout at the same widths. Tailwind defines
9
+ breakpoints in CSS, so a JavaScript check such as
10
+ `matchMedia("(width >= 52.5rem)")` repeats the value. In Stillwind, you name each
11
+ breakpoint once and use the name in both CSS and JavaScript.
12
+
13
+ ## Name breakpoints by layout role
14
+
15
+ Name breakpoints after the layout change that they cause, instead of a device
16
+ size:
17
+
18
+ ```css
19
+ @import "stillwind";
20
+
21
+ @theme {
22
+ --breakpoint-inline: 40rem;
23
+ --breakpoint-sidebar: 52.5rem;
24
+ --breakpoint-outline: 70rem;
25
+ }
26
+
27
+ .navigation {
28
+ @apply flex flex-col gap-3;
29
+ @variant inline {
30
+ @apply flex-row;
31
+ }
32
+ }
33
+ ```
34
+
35
+ Each `--breakpoint-*` token adds a variant, such as `sidebar:`. The default
36
+ breakpoints, such as `md:`, remain available unless you remove them.
37
+
38
+ ## Use breakpoints in components
39
+
40
+ ```tsx
41
+ import { style } from "stillwind/react";
42
+
43
+ export function Layout() {
44
+ return (
45
+ <div {...style("flex flex-col gap-4 sidebar:flex-row")}>
46
+ <nav {...style("sidebar:w-64")}>Navigation</nav>
47
+ <main {...style("flex-1")}>Content</main>
48
+ </div>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ## Use breakpoints in authored CSS
54
+
55
+ In a CSS rule, nest `@variant` with the breakpoint name, as in the `.navigation`
56
+ rule above. In an `@utility` definition, use the variant in `@apply` instead,
57
+ such as `@apply inline:flex-row`.
58
+
59
+ ## Use breakpoints in JavaScript
60
+
61
+ `style.media()` returns the media query for a breakpoint name:
62
+
63
+ ```ts
64
+ import { style } from "stillwind/react";
65
+
66
+ const sidebar = window.matchMedia(style.media("sidebar"));
67
+ const update = () => {
68
+ document.documentElement.dataset.sidebar = String(sidebar.matches);
69
+ };
70
+ sidebar.addEventListener("change", update);
71
+ update();
72
+
73
+ export function dispose() {
74
+ sidebar.removeEventListener("change", update);
75
+ }
76
+ ```
77
+
78
+ The compiler replaces `style.media("sidebar")` with the query string, so the
79
+ JavaScript always matches the CSS. `matchMedia()` is a browser API, so call it on
80
+ the client. Remove the listener when its component unmounts.
81
+
82
+ To combine conditions, write them in one argument. To accept alternatives, pass
83
+ several arguments:
84
+
85
+ ```ts
86
+ import { style } from "stillwind/react";
87
+
88
+ const enhanced = window.matchMedia(style.media("outline:motion-safe", "print"));
89
+ ```
90
+
91
+ This query matches a viewport at least as wide as `outline` without a
92
+ reduced-motion preference, or a printed page. `style.media()` accepts media
93
+ conditions only. Element states such as `hover` are not media conditions.
94
+
95
+ ## Report widths outside your breakpoints
96
+
97
+ The [no-arbitrary-breakpoints](../lints/no-arbitrary-breakpoints.md) rule
98
+ reports widths written as values, such as `min-[713px]:`. See
99
+ [Design systems](design-systems.md#report-values-outside-the-theme)
100
+ to enable it.
101
+
102
+ To respond to the width of a component instead of the viewport, use a container
103
+ query. See [Element relationships](element-relationships.md#react-to-a-containers-size).
@@ -0,0 +1,110 @@
1
+ ---
2
+ title: "Reusable styles"
3
+ description: "Share a base style, and express states and options with variants instead of toggled classes."
4
+ ---
5
+
6
+ # Reusable styles
7
+
8
+ You want components to share styles and to change their look by state or by
9
+ option. In Stillwind, you share a base style, and you express states and options
10
+ with variants. The element keeps the same classes, and its attributes decide
11
+ which styles apply.
12
+
13
+ ## Share a base style
14
+
15
+ Store a `style()` result, and pass it to other `style()` calls. You can export
16
+ the base and import it in other modules:
17
+
18
+ ```tsx
19
+ import { style } from "stillwind/react";
20
+
21
+ export const button = style(
22
+ "inline-flex rounded-md bg-gray-100 px-4 py-2 font-medium text-gray-900",
23
+ );
24
+ const primaryButton = style(button, "bg-blue-600 text-white");
25
+ const dangerButton = style(button, "bg-red-600 text-white");
26
+
27
+ export function Actions() {
28
+ return (
29
+ <div {...style("flex gap-2")}>
30
+ <button {...primaryButton}>Save</button>
31
+ <button {...dangerButton}>Delete</button>
32
+ </div>
33
+ );
34
+ }
35
+ ```
36
+
37
+ In this example, the derived styles replace the base's background and text
38
+ colors. Their CSS comes after the base's CSS, and their selectors have equal
39
+ specificity. The order of the class names does not affect the result.
40
+
41
+ A base's `hover:` selector can be more specific than a plain class in the
42
+ derived style. [CSS ordering](../concepts/css-ordering.md) explains variants,
43
+ conditions, and multiple bases.
44
+
45
+ A base passes on its classes only. Custom properties such as
46
+ `{ "--progress": value }` in the base do not carry over, and the CLI reports
47
+ them. Set custom properties in the `style()` call that is spread onto the element.
48
+
49
+ ## Express states with variants
50
+
51
+ Set the state as an attribute, and style it with a variant:
52
+
53
+ ```tsx
54
+ import { style } from "stillwind/react";
55
+
56
+ export function ToggleButton({ pressed }: { pressed: boolean }) {
57
+ return (
58
+ <button
59
+ aria-pressed={pressed}
60
+ {...style(
61
+ "rounded-md bg-gray-100 px-4 py-2",
62
+ "aria-pressed:bg-blue-600 aria-pressed:text-white",
63
+ )}
64
+ >
65
+ Bold
66
+ </button>
67
+ );
68
+ }
69
+ ```
70
+
71
+ The `aria-pressed` attribute is needed for accessibility anyway. Use variants
72
+ such as `disabled:`, `aria-expanded:`, and `open:` in the same way. The element
73
+ always has the same classes, so you do not need to think about which toggled
74
+ class wins.
75
+
76
+ ## Express options with data attributes
77
+
78
+ For an option without a matching ARIA attribute, set a `data-*` attribute:
79
+
80
+ ```tsx
81
+ import { style } from "stillwind/react";
82
+
83
+ export function Badge({ tone, label }: { tone: "neutral" | "danger"; label: string }) {
84
+ return (
85
+ <span
86
+ data-tone={tone}
87
+ {...style(
88
+ "rounded-full bg-gray-100 px-2 text-gray-900",
89
+ "data-[tone=danger]:bg-red-600 data-[tone=danger]:text-white",
90
+ )}
91
+ >
92
+ {label}
93
+ </span>
94
+ );
95
+ }
96
+ ```
97
+
98
+ The attribute also shows the option in the browser's developer tools and in
99
+ test queries.
100
+
101
+ For a value from a continuous range, such as a width or a progress percentage,
102
+ set a custom property instead. See
103
+ [Use runtime values](style.md#use-runtime-values).
104
+
105
+ ## Migrate CVA components
106
+
107
+ `style.cva()` accepts the configuration of `cva` from class-variance-authority.
108
+ Use it to migrate existing CVA components. See
109
+ [Replace class helpers](migrating-from-tailwind.md#replace-class-helpers)
110
+ and the [style.cva() reference](../macros/cva.md).
@@ -0,0 +1,181 @@
1
+ ---
2
+ title: "The basics of style()"
3
+ description: "Apply utilities, variants, conditions, overrides, and runtime values to an element."
4
+ ---
5
+
6
+ # The basics of style()
7
+
8
+ `style()` takes Tailwind CSS v4 utilities and returns props for an element.
9
+ You spread the props onto the element instead of writing a `className` string.
10
+ This page uses React. For other frameworks, import `style` from the entrypoint
11
+ listed in [Framework integrations](../integrations.md).
12
+
13
+ ## Apply utilities
14
+
15
+ ```tsx
16
+ import { style } from "stillwind/react";
17
+
18
+ export function Workspace() {
19
+ return (
20
+ <section {...style("flex flex-col gap-4 rounded-lg bg-white p-6")}>
21
+ <h2 {...style("text-xl font-semibold")}>Your workspace</h2>
22
+ <p {...style("text-gray-600")}>Keep your component styles together.</p>
23
+ </section>
24
+ );
25
+ }
26
+ ```
27
+
28
+ The compiler reads the utilities at build time and generates their CSS.
29
+ In React, `style()` returns a `className` prop.
30
+
31
+ Utilities and variants come from the stylesheet that `stillwind.config.ts`
32
+ selects. A token that you add to `@theme` adds utilities, such as `bg-accent`
33
+ for `--color-accent`.
34
+
35
+ ## Add variants
36
+
37
+ Write variants as in Tailwind:
38
+
39
+ ```tsx
40
+ import { style } from "stillwind/react";
41
+
42
+ export function SaveButton() {
43
+ return (
44
+ <button {...style("rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 md:px-6")}>
45
+ Save changes
46
+ </button>
47
+ );
48
+ }
49
+ ```
50
+
51
+ To apply several utilities under the same variant, use an object. Each key is
52
+ a variant followed by a colon:
53
+
54
+ ```tsx
55
+ import { style } from "stillwind/react";
56
+
57
+ export function Link() {
58
+ return (
59
+ <a href="/docs" {...style("text-blue-600", { "hover:": "text-blue-800 underline" })}>
60
+ Documentation
61
+ </a>
62
+ );
63
+ }
64
+ ```
65
+
66
+ ## Style states
67
+
68
+ When the element has an attribute for the state, use a variant:
69
+
70
+ ```tsx
71
+ import { style } from "stillwind/react";
72
+
73
+ export function SaveButton({ loading }: { loading: boolean }) {
74
+ return (
75
+ <button
76
+ disabled={loading}
77
+ {...style(
78
+ "rounded-md bg-blue-600 px-4 py-2 text-white disabled:cursor-wait disabled:opacity-60",
79
+ )}
80
+ >
81
+ {loading ? "Saving…" : "Save changes"}
82
+ </button>
83
+ );
84
+ }
85
+ ```
86
+
87
+ The element keeps the same classes, and the browser applies the `disabled:`
88
+ styles while the button is disabled. [Reusable styles](reusable-styles.md)
89
+ shows the same approach with `aria-*` and `data-*` attributes.
90
+
91
+ When no attribute represents the state, pass a condition and a string, as with `clsx`:
92
+
93
+ ```tsx
94
+ import { style } from "stillwind/react";
95
+
96
+ export function Row({ selected }: { selected: boolean }) {
97
+ return <li {...style("px-4 py-2", selected && "bg-blue-50 font-medium")}>Inbox</li>;
98
+ }
99
+ ```
100
+
101
+ The compiler generates CSS for both strings. At runtime, the condition decides
102
+ whether the element gets `bg-blue-50 font-medium`.
103
+
104
+ Write complete utility names in the source. The compiler cannot generate CSS for
105
+ a name that your code builds at runtime, such as `` `bg-${color}-600` ``.
106
+ Choose between complete names instead, such as
107
+ `color === "red" ? "bg-red-600" : "bg-blue-600"`.
108
+
109
+ ## Override a style
110
+
111
+ Store a `style()` result in a variable, and pass it to another `style()` call.
112
+ The compiler places CSS for the new utilities after the base's CSS:
113
+
114
+ ```tsx
115
+ import { style } from "stillwind/react";
116
+
117
+ const button = style("rounded-md bg-blue-600 px-4 py-2 text-white");
118
+ const dangerButton = style(button, "bg-red-600");
119
+
120
+ export function DeleteButton() {
121
+ return <button {...dangerButton}>Delete</button>;
122
+ }
123
+ ```
124
+
125
+ In this example, `dangerButton` has a red background because both background
126
+ rules use equally specific selectors. The order of the class names does not
127
+ affect the result. You can export a stored style and use it in other modules.
128
+
129
+ More specific selectors and `!important` can change which declaration wins.
130
+ See [CSS ordering](../concepts/css-ordering.md) for variants, conditions, and multiple
131
+ bases.
132
+
133
+ Store the inner style in a variable first. A `style()` call written directly
134
+ inside another, such as `style(style("p-4"), "text-sm")`, is not supported.
135
+ [Reusable styles](reusable-styles.md) covers shared styles and
136
+ component options in more detail.
137
+
138
+ ## Use runtime values
139
+
140
+ For a value that is known only at runtime, set a CSS custom property and read it
141
+ in a utility:
142
+
143
+ ```tsx
144
+ import { style } from "stillwind/react";
145
+
146
+ export function Progress({ value }: { value: number }) {
147
+ return (
148
+ <div {...style("h-2 w-(--progress) rounded-full bg-blue-600", { "--progress": `${value}%` })} />
149
+ );
150
+ }
151
+ ```
152
+
153
+ The utility `w-(--progress)` stays the same, so its CSS is generated at build
154
+ time. Only the value of `--progress` changes at runtime.
155
+
156
+ ## Add classes from other stylesheets
157
+
158
+ To add a class that another stylesheet defines, pass it in a `class` field:
159
+
160
+ ```tsx
161
+ import { style } from "stillwind/react";
162
+
163
+ export function Card({ className }: { className?: string }) {
164
+ return <article {...style("rounded-lg p-4", { class: className })} />;
165
+ }
166
+ ```
167
+
168
+ Stillwind passes these classes through and does not generate CSS for them.
169
+
170
+ ## Keep arguments free of side effects
171
+
172
+ The compiler can evaluate the arguments of `style()` in any order, and it can
173
+ skip arguments whose result is not used. Calculate values and perform effects,
174
+ such as state updates or I/O, before you call `style()`.
175
+
176
+ ## Next steps
177
+
178
+ - [Reusable styles](reusable-styles.md) shares styles and defines component options.
179
+ - [Responsive styles](responsive-styles.md) names breakpoints and uses them in JavaScript.
180
+ - [Checks in the editor and CI](lint-adoption.md) finds misspelled utilities and other mistakes.
181
+ - [The style() reference](../macros/style.md) lists every accepted input.
@@ -0,0 +1,126 @@
1
+ ---
2
+ title: "Tailwind CSS compatibility"
3
+ description: "Check which Tailwind CSS v4 features, plugins, and CSS packages work in Stillwind, and what Stillwind does differently by design."
4
+ ---
5
+
6
+ # Tailwind CSS compatibility
7
+
8
+ Stillwind supports the utilities, variants, theme, CSS directives, and plugins of
9
+ Tailwind CSS v4. To move a project, follow
10
+ [Migrating from Tailwind CSS](migrating-from-tailwind.md). This page
11
+ lists what works, how Stillwind checks it, and where Stillwind differs.
12
+
13
+ ## What works
14
+
15
+ | Tailwind feature | Support |
16
+ | --------------------------------------- | -------------------------------------------------------------------- |
17
+ | Default theme and preflight | Included in `@import "stillwind"` |
18
+ | Utilities and variants | Supported, including arbitrary values, modifiers, and `!` |
19
+ | `@theme`, `@utility`, `@custom-variant` | Supported |
20
+ | `@apply`, `@variant` | Supported |
21
+ | `--theme()`, `--spacing()`, `--alpha()` | Supported |
22
+ | `theme(--color-red-500)` | Supported; v3 paths such as `theme(colors.red.500)` are not |
23
+ | `@plugin` with JavaScript plugins | Supported; see [Plugins and CSS packages](#plugins-and-css-packages) |
24
+ | `@import` of CSS packages | Supported; see [Plugins and CSS packages](#plugins-and-css-packages) |
25
+ | Tailwind configuration | Set the `tailwind` field of the project in `stillwind.config.ts` |
26
+
27
+ ## How Stillwind checks compatibility
28
+
29
+ The test suite compares Stillwind with the Tailwind compiler. It runs both
30
+ compilers on the same input and fails when their results differ:
31
+
32
+ - For utilities and variants, it compares the generated CSS for each class in
33
+ Tailwind's public class list and in its variant list.
34
+ - For plugins and CSS packages, it builds the same stylesheet with both compilers
35
+ and compares the computed styles in Chrome.
36
+
37
+ The declarations inside a rule can stand in a different order from Tailwind's, as
38
+ [CSS ordering](../concepts/css-ordering.md) describes. The order of two declarations
39
+ that can affect each other stays the same, so the computed styles do not change.
40
+
41
+ ## Plugins and CSS packages
42
+
43
+ Tailwind CSS v4 plugins work in Stillwind in principle. The test suite runs the
44
+ following packages in Vite development and production builds and in Rspack
45
+ production builds. It also compares their output with Tailwind.
46
+
47
+ Load these packages with `@plugin`:
48
+
49
+ | Package | Example |
50
+ | ----------------------------------- | ------------------------------------------- |
51
+ | `@tailwindcss/typography` | `prose`, `prose-lg`, `prose-headings:` |
52
+ | `@tailwindcss/forms` | `form-input`, and the base styles of forms |
53
+ | `daisyui` | `btn`, `card`, `badge`, themes |
54
+ | `tailwindcss-animate` | `animate-in`, `fade-in-50` |
55
+ | `tailwindcss-motion` | `motion-preset-fade`, `motion-duration-700` |
56
+ | `tailwind-scrollbar` | `scrollbar-thin`, `scrollbar-thumb-brand` |
57
+ | `tailwindcss-radix` | `radix-state-open:` |
58
+ | `tailwindcss-react-aria-components` | `selected:` |
59
+ | `@headlessui/tailwindcss` | `ui-open:` |
60
+ | `@iconify/tailwind4` | `icon-[lucide--home]` |
61
+
62
+ Load these packages with `@import`:
63
+
64
+ | Package | Example |
65
+ | ---------------------------- | -------------------------------------- |
66
+ | `tw-animate-css` | `animate-in`, `fade-in-50` |
67
+ | `tailwindcss-animated` | `animate-fade`, `animate-duration-700` |
68
+ | `tailwindcss-intersect` | `intersect:` |
69
+ | `tailwindcss-safe-area` | `pt-safe-or-4` |
70
+ | `tailwind-scrollbar-hide/v4` | `scrollbar-hide` |
71
+ | `preline/variants.css` | `hs-dropdown-open:` |
72
+
73
+ Other plugins can use the same features. [@plugin](../at-rules/plugin.md#tailwind-css-plugins)
74
+ lists the supported plugin API. JavaScript plugins need the `tailwindcss` package,
75
+ and CSS packages do not.
76
+
77
+ The tests cover CSS. They do not run the JavaScript of a package, such as the
78
+ components of Preline. Plugins have no browser test with webpack or Next.js. Test
79
+ these combinations in your application.
80
+
81
+ ### Class names that a plugin's selectors use
82
+
83
+ A plugin can select an element by a fixed class name. For example, the rules of
84
+ `prose` skip elements inside `not-prose`. `style()` keeps such a class in the
85
+ `class` attribute, so `style("not-prose")` adds the class `not-prose`. The class
86
+ keeps its name only without variants, so
87
+ [invalid-marker-use](../lints/invalid-marker-use.md) reports `hover:not-prose`.
88
+
89
+ ## What Stillwind does not support
90
+
91
+ These differences come from the design of Stillwind. No setting changes them.
92
+
93
+ ### Classes outside style()
94
+
95
+ Only `style()` calls generate utilities. Stillwind does not scan files, so these
96
+ features have no replacement:
97
+
98
+ - `@source`, `@source inline()`, and `source(...)` on `@import`
99
+ - A safelist of class names
100
+ - Tailwind classes inside a dependency
101
+ - Utility classes that JavaScript adds at runtime, such as `` `bg-${color}-600` ``
102
+
103
+ Write each utility that you need in a `style()` call in your own code. For HTML
104
+ that you do not control, see
105
+ [Avoid separate CSS](recommended-practices.md#avoid-separate-css).
106
+
107
+ ### The tw: class prefix
108
+
109
+ Stillwind generates unique class names, so utilities do not need a prefix. Write
110
+ `p-4` instead of `tw:p-4`. Theme variables can still collide with other CSS in the
111
+ page. To prefix them, set `themePrefix` on the project, as
112
+ [Migrating from Tailwind CSS](migrating-from-tailwind.md#move-configuration)
113
+ describes. In a plugin, `prefix()` returns the class name unchanged.
114
+
115
+ ### Other differences
116
+
117
+ | Tailwind | Stillwind |
118
+ | ------------------------------------------ | --------------------------------------------------------------------------------- |
119
+ | `@reference` | Ignored; `@import` the stylesheet from the stylesheet of the project |
120
+ | `theme(colors.red.500)` | Stays in the CSS, where browsers reject it; use `--theme(--color-red-500)` |
121
+ | `blocklist` | Has no effect; use the `no-restricted-utilities` lint rule |
122
+ | Utilities that generate invalid CSS | Rejected, such as `justify-baseline`, because `justify-content` has no such value |
123
+ | `addVariant()` with the v3 `:merge()` form | Skipped, as in Tailwind CSS v4 |
124
+
125
+ [ignored-tailwind-feature](../lints/ignored-tailwind-feature.md) reports the
126
+ features in your stylesheet that have no effect.
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: "View transitions"
3
+ description: "Style view transition snapshots in the component, and give each item a stable name."
4
+ ---
5
+
6
+ # View transitions
7
+
8
+ You want an item to animate between two states of the page with the browser's
9
+ View Transition API. In plain CSS, you write `view-transition-name` and the
10
+ `::view-transition-*` rules in a global stylesheet, and you keep every name
11
+ unique by hand. In Stillwind, you define the transition in the component and
12
+ name each item with a key.
13
+
14
+ ## Define the transition and name each item
15
+
16
+ ```tsx
17
+ import { style } from "stillwind/react";
18
+
19
+ const productTransition = style.viewTransition({
20
+ old: "duration-150 motion-reduce:duration-0",
21
+ new: "delay-150 duration-150 motion-reduce:delay-0 motion-reduce:duration-0",
22
+ });
23
+
24
+ export function Product({ id, name }: { id: string; name: string }) {
25
+ return <article {...style(productTransition.for(id), "rounded-lg p-4")}>{name}</article>;
26
+ }
27
+ ```
28
+
29
+ `style.viewTransition()` defines the styles of the snapshots. Each field styles
30
+ one pseudo-element:
31
+
32
+ | Field | Pseudo-element |
33
+ | ----------- | -------------------------------- |
34
+ | `group` | `::view-transition-group()` |
35
+ | `imagePair` | `::view-transition-image-pair()` |
36
+ | `old` | `::view-transition-old()` |
37
+ | `new` | `::view-transition-new()` |
38
+
39
+ Timing utilities in these fields set animation properties. For example,
40
+ `duration-150` sets `animation-duration`.
41
+
42
+ `.for(id)` gives the element a view transition name from the key. Use a key
43
+ that stays the same for the same item before and after the update, such as a
44
+ database ID. Two items on the page at the same time need different keys.
45
+
46
+ ## Start the transition
47
+
48
+ Stillwind generates the styles and names. Your code starts the transition:
49
+
50
+ ```ts
51
+ export function navigate(update: () => void) {
52
+ if (document.startViewTransition) {
53
+ document.startViewTransition(update);
54
+ } else {
55
+ update();
56
+ }
57
+ }
58
+ ```
59
+
60
+ Call `update` the way your framework normally renders a change. Browsers without
61
+ the View Transition API run the update without animation.
62
+
63
+ ## Give each element one name
64
+
65
+ Use `.for()` once for each element, in one `style()` call. To combine several
66
+ transitions on one element, pass the others without `.for()`:
67
+
68
+ ```tsx
69
+ import { style } from "stillwind/react";
70
+
71
+ const fade = style.viewTransition({ old: "duration-150" });
72
+ const slide = style.viewTransition({ new: "duration-300" });
73
+
74
+ export function Card({ id }: { id: string }) {
75
+ return <article {...style(fade, slide.for(id))}>Card</article>;
76
+ }
77
+ ```
78
+
79
+ The CLI reports a `style()` call that applies a transition without `.for()`, a
80
+ call with two `.for()` calls, and transitions split across separate `style()`
81
+ calls. It cannot check that keys are unique across the whole page.
82
+
83
+ The [style.viewTransition() reference](../macros/view-transition.md) covers
84
+ dynamic keys and the generated CSS.