stillwind 0.1.0 → 0.4.1

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 (54) hide show
  1. package/README.md +19 -19
  2. package/css/builtin-utilities/tw-layout.css +2 -2
  3. package/css/logical/divide.css +67 -0
  4. package/css/logical/overflow.css +57 -0
  5. package/css/logical/overscroll.css +40 -0
  6. package/css/logical/resize.css +19 -0
  7. package/css/logical/snap.css +20 -0
  8. package/docs/at-rules/apply.md +1 -1
  9. package/docs/at-rules/custom-variant.md +3 -3
  10. package/docs/at-rules/plugin.md +2 -3
  11. package/docs/at-rules/slot.md +1 -1
  12. package/docs/at-rules/stillwind-css-template.md +2 -2
  13. package/docs/at-rules/stillwind-property.md +1 -1
  14. package/docs/at-rules/stillwind-registry.md +1 -1
  15. package/docs/at-rules/stillwind-require-properties.md +1 -1
  16. package/docs/at-rules/stillwind-undef-arbitrary-property.md +1 -1
  17. package/docs/at-rules/stillwind-undef-utility.md +8 -1
  18. package/docs/at-rules/stillwind-undef-variant.md +1 -1
  19. package/docs/at-rules/theme.md +5 -5
  20. package/docs/at-rules/utility.md +6 -5
  21. package/docs/at-rules/variant.md +1 -1
  22. package/docs/cli.md +375 -0
  23. package/docs/concepts/stylesheets.md +89 -0
  24. package/docs/configuration.md +44 -6
  25. package/docs/editors.md +110 -0
  26. package/docs/errors/SW10002.md +1 -1
  27. package/docs/formatters.md +87 -0
  28. package/docs/guides/lint-adoption.md +3 -12
  29. package/docs/guides/migrating-from-css.md +2 -0
  30. package/docs/guides/runtime-conditions.md +187 -0
  31. package/docs/guides/style.md +6 -5
  32. package/docs/guides/tailwind-compatibility.md +22 -1
  33. package/docs/guides/web-components.md +29 -0
  34. package/docs/index.md +6 -4
  35. package/docs/integrations.md +3 -0
  36. package/docs/lints/{prefer-explicit-nesting-selector.md → implicit-nesting-selector.md} +3 -3
  37. package/docs/lints/index.md +44 -43
  38. package/docs/lints/invalid-runtime-condition.md +2 -1
  39. package/docs/lints/invalid-utility.md +1 -1
  40. package/docs/lints/prefer-canonical-utilities.md +21 -4
  41. package/docs/lints/prefer-logical-properties.md +18 -0
  42. package/docs/lints/runtime-condition-requires-css-if.md +2 -1
  43. package/docs/lints/unknown-utility.md +3 -2
  44. package/docs/lints/unknown-variant.md +1 -1
  45. package/docs/lints/unmatched-host-selector.md +44 -0
  46. package/docs/macros/css.md +3 -3
  47. package/docs/plugins/iconify.md +270 -0
  48. package/docs/plugins/index.md +26 -0
  49. package/docs/utilities-and-variants.md +75 -0
  50. package/docs/why.md +1 -1
  51. package/package.json +11 -6
  52. package/skills/migrate-to-stillwind/SKILL.md +3 -1
  53. package/skills/stillwind/SKILL.md +34 -19
  54. package/docs/utilities.md +0 -35
@@ -28,7 +28,7 @@ style("flex");
28
28
  ## How to fix
29
29
 
30
30
  - Remove the modifier or value that the utility does not accept.
31
- - Check the accepted forms in [Built-in utilities](../utilities.md).
31
+ - Check the accepted forms in [Built-in utilities and variants](../utilities-and-variants.md).
32
32
 
33
33
  A utility name or theme value that does not exist is reported by
34
34
  [unknown-utility](unknown-utility.md) instead.
@@ -5,14 +5,31 @@ description: "Suggests standard utility spellings and combines equivalent utilit
5
5
 
6
6
  # prefer-canonical-utilities
7
7
 
8
- This rule suggests standard spellings, such as `px-4` for `px-[16px]`. It also
9
- removes unnecessary spaces from arbitrary values, simplifies variants and modifiers,
10
- and replaces legacy Tailwind spellings. Suggestions use your active theme and custom
11
- definitions.
8
+ This rule suggests standard spellings, such as `px-4` for `px-[16px]` and `p-4` for
9
+ `[padding:16px]`. It also removes unnecessary spaces from arbitrary values, simplifies
10
+ variants and modifiers, and replaces legacy Tailwind spellings. Suggestions use your
11
+ active theme and custom definitions.
12
+
13
+ The rule also finds the utility for CSS that you know. Write the declaration as an
14
+ arbitrary property, and let `stillwind lint --fix` replace it.
12
15
 
13
16
  Within one string or one CSS `@apply` statement, it can combine utilities such as
14
17
  `w-4 h-4` into `size-4`. Utilities must have the same variants and importance.
15
18
 
19
+ ## Theme tokens
20
+
21
+ A replacement keeps every theme token that the original utility references. For
22
+ example, `w-96` stays as written even when `--container-sm` has the same value, because
23
+ the two tokens can differ after a theme change.
24
+
25
+ A fixed value becomes a token only when the choice is clear:
26
+
27
+ - A spacing multiple comes first, so `w-[448px]` becomes `w-112`, not `w-md`.
28
+ - A named token is used when no spacing multiple fits and it is the only match, so
29
+ `rounded-[8px]` becomes `rounded-lg`.
30
+ - The value stays as written when unrelated named tokens match it. An alias of a token
31
+ does not count as an unrelated token.
32
+
16
33
  ## Reported
17
34
 
18
35
  ```tsx
@@ -33,6 +33,24 @@ style("ms-4");
33
33
  - If the side must stay on the left in every language, such as for an icon that
34
34
  points left, keep the physical form and add a
35
35
  [suppression comment](../configuration.md#suppression-comments).
36
+ - For `overflow-x-*`, `overflow-y-*`, `overscroll-x-*`, `overscroll-y-*`, and
37
+ `divide-y-*`, import
38
+ the matching [logical stylesheet](../concepts/stylesheets.md#logical-axis-utilities).
39
+ These utilities then keep their names and write logical properties.
40
+
41
+ ## Shorthands
42
+
43
+ A shorthand that gives every side the same value does not depend on the writing
44
+ direction, so this rule does not report `p-4` or `overflow-hidden`.
45
+
46
+ The rule reports a shorthand with different values for its sides, such as
47
+ `[padding:1rem_2rem]`. It also reports a shorthand that sets only some sides, such
48
+ as `[border-top:var(--border)]`, for every value.
49
+
50
+ The rule does not report a single variable in a shorthand for all sides, such as
51
+ `[padding:var(--gap)]`, because the compiler cannot determine which values the
52
+ variable holds. With a second value, as in `[padding:var(--gap)_1rem]`, the two
53
+ values differ, so the rule reports the shorthand.
36
54
 
37
55
  ## Rule settings
38
56
 
@@ -46,7 +46,8 @@ style("if(--state:active):block");
46
46
  - Otherwise, represent the state with an attribute and use an attribute variant.
47
47
  That requires changing the code that sets the state as well.
48
48
 
49
- See [Configuration](../configuration.md#generated-css).
49
+ See [Runtime conditions](../guides/runtime-conditions.md#enable-native-css-if) and
50
+ [Configuration](../configuration.md#generated-css).
50
51
 
51
52
  ## Rule settings
52
53
 
@@ -34,13 +34,14 @@ style("bg-red-950");
34
34
  - For a class that another stylesheet defines, pass it in a `class` field, such as
35
35
  `style({ class: "external-card" })`.
36
36
 
37
- [Built-in utilities](../utilities.md) looks up the utilities of the default theme.
37
+ [Built-in utilities and variants](../utilities-and-variants.md) looks up the
38
+ utilities of the default theme.
38
39
 
39
40
  ## Rule settings
40
41
 
41
42
  | Preset | Severity |
42
43
  | --- | --- |
43
- | `recommended` | warn |
44
+ | `recommended` | deny |
44
45
  | `strict` | deny |
45
46
  | `stylistic` | off |
46
47
 
@@ -35,7 +35,7 @@ style("hover:p-4");
35
35
 
36
36
  | Preset | Severity |
37
37
  | --- | --- |
38
- | `recommended` | warn |
38
+ | `recommended` | deny |
39
39
  | `strict` | deny |
40
40
  | `stylistic` | off |
41
41
 
@@ -0,0 +1,44 @@
1
+ ---
2
+ title: "unmatched-host-selector"
3
+ description: "Reports a variant that tests a shadow host through the elements around it."
4
+ ---
5
+
6
+ # unmatched-host-selector
7
+
8
+ This rule reports a variant stack that tests a shadow host through the elements
9
+ around it, such as `host:in-[.page]:` or `host:group-hover:`. A selector in a shadow
10
+ tree cannot read those elements, so the rule never matches.
11
+
12
+ ## Reported
13
+
14
+ ```tsx
15
+ style.css("host:in-[.page]:block");
16
+ ```
17
+
18
+ > unmatched-host-selector: `:where(:is(.page)) :host` cannot match the shadow host; pass the state down with a custom property
19
+ >
20
+ > Example:1:17
21
+
22
+ ## Fixed
23
+
24
+ ```tsx
25
+ style.css("[:host(.page)]:block");
26
+ ```
27
+
28
+ ## How to fix
29
+
30
+ - Add a class or an attribute to the host, and test it inside `:host()`, as in the
31
+ example.
32
+ - Set a custom property on the outer element, and read it on the host with
33
+ [`--if()`](../guides/runtime-conditions.md). Custom properties inherit into a
34
+ shadow tree.
35
+
36
+ ## Rule settings
37
+
38
+ | Preset | Severity |
39
+ | --- | --- |
40
+ | `recommended` | warn |
41
+ | `strict` | deny |
42
+ | `stylistic` | off |
43
+
44
+ [Configure lint](../configuration.md#lint) to change the severity or options.
@@ -24,7 +24,7 @@ export const css = style.css("p-4 text-blue-600", {
24
24
  ### Compiled code
25
25
 
26
26
  ```ts
27
- export const css = "/*! stillwind v0.0.0 | MIT License | https://stillwind.dev */\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n:where(:root, :host){--color-blue-600:oklch(54.6% 0.245 262.881);--spacing:0.25rem;}:host{padding:calc(var(--spacing) * 4);}:host{color:var(--color-blue-600);}";
27
+ export const css = "/*! stillwind v0.4.1 | MIT License | https://stillwind.dev */\n/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n:where(:root, :host){--color-blue-600:oklch(54.6% 0.245 262.881);--spacing:0.25rem;}:host{padding:calc(var(--spacing) * 4);}:host{color:var(--color-blue-600);}";
28
28
  ```
29
29
 
30
30
  ### Generated CSS
@@ -60,8 +60,8 @@ the template and the utilities need. It never contains the preflight reset.
60
60
 
61
61
  Add the string to the page yourself, for example with
62
62
  `CSSStyleSheet.replaceSync()` and a shadow root's `adoptedStyleSheets`. The
63
- results in [Built-in utilities](../utilities.md) leave out the supporting CSS,
64
- so they cannot replace this string.
63
+ results in [Built-in utilities and variants](../utilities-and-variants.md)
64
+ leave out the supporting CSS, so they cannot replace this string.
65
65
 
66
66
  To add all styles of a module to a shadow root, including the preflight reset,
67
67
  import them from `stillwind/module-css` instead. See
@@ -0,0 +1,270 @@
1
+ ---
2
+ title: "Iconify icons"
3
+ description: "Use Iconify icons as utilities, and include only the icons that you use in your CSS."
4
+ ---
5
+
6
+ # Iconify icons
7
+
8
+ `@stillwind/plugin-iconify` adds Iconify icons as Stillwind utilities. Only the
9
+ icons that you use reach your CSS.
10
+
11
+ ## Usage
12
+
13
+ Install the plugin and the icon sets that the project uses:
14
+
15
+ ```sh
16
+ vp i -D @stillwind/plugin-iconify @iconify-json/mdi
17
+ ```
18
+
19
+ Load the plugin in the project stylesheet:
20
+
21
+ ```css
22
+ @import "stillwind";
23
+ @plugin "@stillwind/plugin-iconify";
24
+ ```
25
+
26
+ Use `icon-<set>--<icon>` or `icon-[<set>--<icon>]` to select an icon. Variants apply as
27
+ usual. The [prefer-canonical-utilities](../lints/prefer-canonical-utilities.md) lint
28
+ suggests the form without brackets:
29
+
30
+ ```tsx
31
+ <span {...style("icon-mdi--close", "hover:icon-[mdi--close-circle]")} />
32
+ ```
33
+
34
+ ## Sizes
35
+
36
+ An icon is `1em` high by default, and its width follows the icon's aspect ratio. To change the
37
+ height, add a size utility to the same element:
38
+
39
+ | Utility | Height |
40
+ | ---------------------------------------- | ------------------------------------------- |
41
+ | `icon-<name>` | The value of the `--icon-size-<name>` token |
42
+ | `icon-full` | `100%` of the parent's height |
43
+ | `icon-[<length>]`, `icon-[<percentage>]` | The given value |
44
+ | `icon-(<custom-property>)` | The value of the given custom property |
45
+
46
+ To add a named size, define a `--icon-size-<name>` token in `@theme`. Its value must be a length
47
+ or a percentage. For example, this token adds the `icon-lg` utility:
48
+
49
+ ```css
50
+ @theme {
51
+ --icon-size-lg: 1.5rem;
52
+ }
53
+ ```
54
+
55
+ ```tsx
56
+ <span {...style("icon-mdi--close icon-lg")} />
57
+ ```
58
+
59
+ `icon-full` needs a parent with a definite height. In a parent whose height depends on its
60
+ content, the icon is 0 high. To size an icon by its width instead, override the height:
61
+ `icon-mdi--close w-full h-auto` fills the parent's width and keeps the icon's aspect ratio.
62
+ When other utilities, such as `size-full` or `max-w-full`, change the box, the SVG keeps its
63
+ aspect ratio and stays centered in the box.
64
+
65
+ A size utility changes only the icon on its own element. A size on a parent does not change the
66
+ icons of its children. An icon on `::before` or `::after` also needs its own size, so give the
67
+ size utility the same variant as the icon:
68
+
69
+ ```tsx
70
+ <span {...style("before:icon-mdi--close before:icon-lg")} />
71
+ ```
72
+
73
+ Size values follow lint policies configured for `height`. For example,
74
+ [no-restricted-length-units](../lints/no-restricted-length-units.md) with
75
+ `properties: ["height"]` checks their units, and
76
+ [no-arbitrary-spacing](../lints/no-arbitrary-spacing.md) with `properties: ["height"]`
77
+ reports arbitrary sizes, but not named sizes such as `icon-lg`.
78
+
79
+ ## Icon sets
80
+
81
+ The plugin finds a set in this order:
82
+
83
+ 1. The `collections` option of a configured instance.
84
+ 2. The `@iconify-json/<set>` package.
85
+ 3. The `@iconify/json` package, which contains every Iconify set.
86
+
87
+ Install icon set packages in the project that contains your stylesheet. Changes to a
88
+ set's JSON file update its icons automatically. Editors complete the icons of configured sets
89
+ and of the `@iconify-json/*` packages listed in the project's `package.json` dependencies.
90
+ When `@iconify/json` is installed, editors also complete its set names, such as `icon-mdi--`,
91
+ and list the icons of a set after the input names it.
92
+
93
+ ### License notices
94
+
95
+ The CSS output starts with a license notice for each icon set whose icons it contains, such as
96
+ `/*! Material Design Icons | Pictogrammers | Apache 2.0 | ... */`. The notice contains the set's
97
+ name, author, and license from the set's metadata. A `@iconify-json/<set>` package supplies the
98
+ metadata in its `info.json` file. The `@iconify/json` package and custom JSON sets supply it in
99
+ their `info` field.
100
+
101
+ A custom set without metadata adds no notice. It does not use the metadata of an installed set
102
+ with the same name. Pass the `info` option to `svgDirectory()` to add a notice for a set of SVG
103
+ files.
104
+
105
+ ## Options
106
+
107
+ The options block of the statement sets these options:
108
+
109
+ ```css
110
+ @plugin "@stillwind/plugin-iconify" {
111
+ prefix: i;
112
+ syntax: bracket;
113
+ scale: 1.2;
114
+ mode: mask;
115
+ hash-length: 4;
116
+ }
117
+ ```
118
+
119
+ - `prefix`: utility prefix without the trailing hyphen, such as `icon` or `i`. Defaults to `icon`.
120
+ The `--icon-size-*` tokens keep their names, so with `prefix: i`, `--icon-size-lg` adds `i-lg`.
121
+ - `syntax`: spellings that select an icon. `named` accepts `icon-mdi--close`, `bracket` accepts
122
+ `icon-[mdi--close]`, and `both`, the default, accepts both.
123
+ - `scale`: icon height in `em` when no size utility applies. Defaults to `1`.
124
+ - `mode`: `mask` paints the text color through the icon's shape, and `background` paints the
125
+ icon's own colors. `auto`, the default, selects `mask` for icons whose SVG uses
126
+ `currentColor`.
127
+ - `hash-length`: base36 hash length in generated CSS variable names. Accepts integers
128
+ from `1` to `7` and defaults to `4`. Increase it when using many icons to reduce collisions.
129
+
130
+ ### Options in TypeScript
131
+
132
+ To set options in TypeScript, add `iconify()` to the `plugins` list of the project, and keep
133
+ `@plugin "@stillwind/plugin-iconify";` in your stylesheet. The `collections` option adds custom
134
+ icon sets. A set can be data, an absolute JSON file path, a function that returns data, or an
135
+ SVG directory:
136
+
137
+ ```ts
138
+ import { iconify } from "@stillwind/plugin-iconify";
139
+ import { defineConfig } from "stillwind/config";
140
+
141
+ export default defineConfig({
142
+ projects: [
143
+ {
144
+ css: "src/stillwind.css",
145
+ files: ["src/**/*.{ts,tsx}"],
146
+ plugins: [
147
+ iconify({
148
+ collections: {
149
+ brand: "/abs/path/brand.json",
150
+ },
151
+ }),
152
+ ],
153
+ },
154
+ ],
155
+ });
156
+ ```
157
+
158
+ `iconify()` accepts the options of the `@plugin` block, with `hashLength` in place of
159
+ `hash-length`. When both set the same option, the `@plugin` block wins.
160
+
161
+ Only `iconify()` can set `collections` and [`svgo`](#svg-minification).
162
+
163
+ ### Custom icon set format
164
+
165
+ A custom icon set uses the Iconify JSON format, which the `IconifyJSON` type of
166
+ `@iconify/types` describes. This is the same format as the `icons.json` file of an
167
+ `@iconify-json/*` package:
168
+
169
+ ```json
170
+ {
171
+ "prefix": "brand",
172
+ "width": 24,
173
+ "height": 24,
174
+ "icons": {
175
+ "logo": {
176
+ "body": "<path fill=\"currentColor\" d=\"M4 4h16v16H4z\"/>"
177
+ },
178
+ "badge": {
179
+ "body": "<circle cx=\"12\" cy=\"12\" r=\"10\" fill=\"#e11d48\"/>",
180
+ "width": 32,
181
+ "height": 32
182
+ }
183
+ },
184
+ "aliases": {
185
+ "logo-flipped": {
186
+ "parent": "logo",
187
+ "hFlip": true
188
+ }
189
+ }
190
+ }
191
+ ```
192
+
193
+ - `icons` maps each icon name to its SVG content. `body` contains the elements inside the
194
+ `<svg>` element, without the `<svg>` element itself.
195
+ - `left`, `top`, `width`, and `height` define the icon's `viewBox`. An icon can set them, and
196
+ the top level sets the default values for every icon. Missing values default to `0`, `0`,
197
+ `16`, and `16`.
198
+ - `aliases` maps additional names to an existing icon in `parent`. An alias can override the
199
+ `viewBox` values and add `rotate` (quarter turns), `hFlip`, and `vFlip` transformations.
200
+ - The key in `collections` sets the set name in utilities, such as `icon-brand--logo`. The
201
+ plugin does not use the `prefix` field to find the set.
202
+
203
+ Set names and icon names must consist of lowercase letters and digits, separated by single
204
+ hyphens. Utilities cannot select other names, such as `Logo` or `logo_dark`.
205
+
206
+ With the default `mode: auto`, an icon whose `body` contains `currentColor` paints the text
207
+ color, and the other icons keep their own colors. In the example, `logo` follows the text
208
+ color and `badge` stays red.
209
+
210
+ The plugin does not validate the data. A JSON file must contain valid JSON, but the plugin
211
+ treats an icon that it cannot find in the data as an unknown utility.
212
+
213
+ ### Icon sets from SVG files
214
+
215
+ `svgDirectory()` creates an icon set from the SVG files in a directory. Each file becomes one
216
+ icon, and the file name without `.svg` becomes the icon name:
217
+
218
+ ```ts
219
+ import { iconify, svgDirectory } from "@stillwind/plugin-iconify";
220
+
221
+ iconify({
222
+ collections: {
223
+ brand: svgDirectory("src/icons/brand"),
224
+ ui: svgDirectory("src/icons/ui", {
225
+ recursive: true,
226
+ transform: (svg) => svg.replaceAll('fill="#000"', 'fill="currentColor"'),
227
+ }),
228
+ },
229
+ });
230
+ ```
231
+
232
+ The directory can be an absolute path or a path relative to the project directory. Each file
233
+ must contain an `<svg>` element with a `viewBox` attribute, which sets the icon's dimensions.
234
+ The plugin keeps the `style` attribute of the `<svg>` element and its attributes whose names
235
+ start with `fill` or `stroke`, such as `fill-rule`. It drops the other attributes of the
236
+ `<svg>` element.
237
+
238
+ - `recursive`: reads subdirectories. The default icon name joins the path segments with `-`,
239
+ such as `arrows-left` for `arrows/left.svg`. Defaults to `false`.
240
+ - `name`: maps the file path relative to the directory, without `.svg` and with `/` separators,
241
+ to an icon name. Returning `undefined` skips the file.
242
+ - `transform`: rewrites the SVG text of each file before the plugin parses it.
243
+ - `info`: the set's name, author, and license in the format of the Iconify `info` field. The
244
+ plugin uses it for the [license notice](#license-notices).
245
+
246
+ Loading fails when an icon name is invalid, two files have the same icon name, or a file has
247
+ no `viewBox`. The error names the file. Adding, removing, or editing an SVG file reloads the
248
+ icons while a development server or build watcher runs.
249
+
250
+ A function in `collections` receives the set name and the host's `read`, `list`, and `watch`
251
+ operations, so you can write similar loaders. Watch each file and directory that the function
252
+ reads, such as `context.watch(file)` and `context.watch(directory, "directory")`.
253
+
254
+ ### SVG minification
255
+
256
+ The plugin minifies the SVG of each icon with [SVGO](https://svgo.dev/) before it embeds the
257
+ SVG in CSS. The `svgo` TypeScript option controls this:
258
+
259
+ - `true`, the default, uses `preset-default` with `multipass` enabled.
260
+ - An SVGO configuration object replaces that default configuration.
261
+ - `false` embeds the SVG without minification.
262
+
263
+ ```ts
264
+ iconify({
265
+ svgo: {
266
+ multipass: true,
267
+ plugins: ["preset-default", "removeDimensions"],
268
+ },
269
+ });
270
+ ```
@@ -0,0 +1,26 @@
1
+ ---
2
+ title: "Official plugins"
3
+ description: "Add utilities to your stylesheet with the plugins that the Stillwind project maintains."
4
+ ---
5
+
6
+ # Official plugins
7
+
8
+ A plugin adds utilities and variants to your stylesheet. Each project that loads
9
+ a plugin can use its definitions in `style()`, and the editor and the CLI check them
10
+ like your own definitions.
11
+
12
+ | Plugin | Adds |
13
+ | ---------------------------------------------------- | -------------------------- |
14
+ | [`@stillwind/plugin-iconify`](iconify.md) | Iconify icons as utilities |
15
+
16
+ Install the package, and load it in your stylesheet with
17
+ [@plugin](../at-rules/plugin.md):
18
+
19
+ ```css
20
+ @import "stillwind";
21
+ @plugin "@stillwind/plugin-iconify";
22
+ ```
23
+
24
+ Tailwind CSS v4 JavaScript plugins use the same statement.
25
+ [Tailwind CSS compatibility](../guides/tailwind-compatibility.md) lists the tested
26
+ plugins.
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: "Built-in utilities and variants"
3
+ description: "Look up the CSS of a utility or variant, or find the canonical utility for CSS declarations."
4
+ ---
5
+
6
+ # Built-in utilities and variants
7
+
8
+ Type a utility to see its CSS, or type CSS declarations to find the utility that
9
+ produces them. Arbitrary values, such as `p-[16px]`, resolve to their canonical
10
+ spelling. Arbitrary variants resolve too, so `[&:focus]` finds `focus:`. Part of
11
+ a variant name or its CSS finds the variant: `:hover`, `@media (hover: hover)`,
12
+ and `media hover` all find `hover:`. The URL keeps your input, so you can share
13
+ the results.
14
+
15
+ ## Read the results
16
+
17
+ Each result shows one utility and its declarations. `&` stands for the styled
18
+ element. Comments show the resolved theme values and pixel sizes. A result for
19
+ CSS declarations names the declaration that it comes from. A variant result
20
+ shows where the variant places the declarations of a utility.
21
+
22
+ The results leave out the theme variables and other supporting CSS that the full
23
+ stylesheet contains. The [macro reference](macros/index.md) shows complete
24
+ generated stylesheets.
25
+
26
+ A declaration without a matching utility becomes an arbitrary property, such as
27
+ `[hyphens:manual]`. Variants and shorthand properties can change what a utility
28
+ does, so compare its declarations with your CSS before you replace it.
29
+
30
+ ## What the lookup covers
31
+
32
+ The lookup runs the Stillwind compiler in your browser with the default theme.
33
+ It downloads the compiler when the page opens. Utilities from your own `@theme`
34
+ tokens, such as `bg-brand`, do not resolve here. See
35
+ [Design systems](guides/design-systems.md) to add them. To check a utility in
36
+ your project, hover over it in the editor or run `stillwind utilities`.
37
+
38
+ The built-in utilities and variants follow Tailwind CSS, so see the
39
+ [Tailwind CSS documentation](https://tailwindcss.com/docs) for their usage.
40
+ [Tailwind CSS compatibility](guides/tailwind-compatibility.md#what-stillwind-adds)
41
+ lists what Stillwind adds.
42
+
43
+ The editor and the CLI report non-canonical spellings with
44
+ [prefer-canonical-utilities](lints/prefer-canonical-utilities.md).
45
+
46
+ ## Look up names from the command line
47
+
48
+ The lookup needs a browser. In a terminal or a coding agent, the
49
+ [CLI](cli.md#stillwind-utilities) shows the CSS of utilities and variants:
50
+
51
+ ```sh
52
+ vp exec stillwind utilities p-4 hover:underline
53
+ vp exec stillwind utilities 'bg-*'
54
+ vp exec stillwind variants hover 'group-*'
55
+ ```
56
+
57
+ The commands read the CSS of your project, so they also resolve utilities from
58
+ your own `@theme` tokens. An exact name shows its CSS, or the closest spelling
59
+ when the name is unknown.
60
+
61
+ A `*` pattern searches names only. It omits numeric and arbitrary values, so
62
+ `p-*` does not list `p-4`, and you check `p-4` with its exact name. The commands
63
+ do not search CSS, so `stillwind variants ':hover'` reports an unknown variant.
64
+
65
+ To find the utility for a CSS declaration, write the declaration as an arbitrary
66
+ property. Variants can precede it:
67
+
68
+ ```sh
69
+ vp exec stillwind utilities '[padding:16px]' '[&:focus]:[display:flex]'
70
+ ```
71
+
72
+ The output names the canonical spellings, `p-4` and `focus:flex`. You can also
73
+ write arbitrary properties in your source and run `stillwind lint --fix`, which
74
+ replaces them with the same spellings. An arbitrary property that stays has no
75
+ equivalent utility.
package/docs/why.md CHANGED
@@ -114,7 +114,7 @@ stillwind fmt
114
114
  ```
115
115
 
116
116
  AI agents can run the same commands as you, and CI can run them on every change.
117
- The VS Code extension shows the same findings while you edit.
117
+ The [VS Code extension](editors.md) shows the same findings while you edit.
118
118
 
119
119
  ## Ship static CSS
120
120
 
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "stillwind",
3
- "version": "0.1.0",
3
+ "version": "0.4.1",
4
4
  "description": "CSS definitions and framework adapters for Stillwind",
5
- "homepage": "https://stillwind.dev/",
5
+ "homepage": "https://stillwind.dev",
6
6
  "bugs": {
7
7
  "url": "https://github.com/SegaraRai/stillwind/issues"
8
8
  },
@@ -32,6 +32,11 @@
32
32
  "./templates.css": "./css/templates.css",
33
33
  "./theme.css": "./css/theme.css",
34
34
  "./utilities.css": "./css/utilities.css",
35
+ "./logical/divide.css": "./css/logical/divide.css",
36
+ "./logical/overflow.css": "./css/logical/overflow.css",
37
+ "./logical/overscroll.css": "./css/logical/overscroll.css",
38
+ "./logical/resize.css": "./css/logical/resize.css",
39
+ "./logical/snap.css": "./css/logical/snap.css",
35
40
  "./config": {
36
41
  "types": "./dist/config.d.ts",
37
42
  "default": "./dist/config.js"
@@ -115,13 +120,13 @@
115
120
  "./package.json": "./package.json"
116
121
  },
117
122
  "dependencies": {
118
- "@stillwind/config": "0.1.0",
119
- "@stillwind/native": "0.1.0",
120
- "@stillwind/projection": "0.1.0"
123
+ "@stillwind/config": "0.4.1",
124
+ "@stillwind/native": "0.4.1",
125
+ "@stillwind/projection": "0.4.1"
121
126
  },
122
127
  "devDependencies": {
123
128
  "@stillwind-internal/tools-workspace": "0.0.0",
124
- "@types/node": "^26.6.5",
129
+ "@types/node": "^26.6.6",
125
130
  "lit": "^3.3.3",
126
131
  "typescript": "^6.0.3",
127
132
  "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
@@ -53,7 +53,9 @@ next steps.
53
53
  CSS project, leave out the preflight reset until the old CSS is gone, as
54
54
  `docs/guides/migrating-from-css.md` describes.
55
55
  2. Migrate in batches, such as one directory or one group of components. After
56
- each batch, build the project and run `stillwind lint`.
56
+ each batch, build the project and run `stillwind lint`. To move a CSS
57
+ declaration, write it as an arbitrary property, such as `[padding:16px]`, and
58
+ run `stillwind lint --fix`, which replaces it when an equivalent utility exists.
57
59
  3. For many mechanical changes, you can write a one-off codemod for this
58
60
  project. Keep it outside the source directories, review its diff, and delete
59
61
  it afterward.