stillwind 0.1.0-rc.0 → 0.3.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/README.md +19 -19
- package/css/builtin-utilities/tw-layout.css +2 -2
- package/css/logical/divide.css +67 -0
- package/css/logical/overflow.css +57 -0
- package/css/logical/overscroll.css +40 -0
- package/css/logical/resize.css +19 -0
- package/css/logical/snap.css +20 -0
- package/docs/at-rules/custom-variant.md +1 -1
- package/docs/at-rules/plugin.md +2 -3
- package/docs/at-rules/stillwind-undef-utility.md +7 -0
- package/docs/at-rules/utility.md +2 -1
- package/docs/cli.md +244 -0
- package/docs/concepts/stylesheets.md +89 -0
- package/docs/configuration.md +43 -5
- package/docs/editors.md +110 -0
- package/docs/errors/SW10002.md +1 -1
- package/docs/formatters.md +87 -0
- package/docs/guides/lint-adoption.md +3 -12
- package/docs/guides/migrating-from-css.md +2 -0
- package/docs/guides/style.md +4 -4
- package/docs/guides/tailwind-compatibility.md +3 -0
- package/docs/index.md +6 -4
- package/docs/integrations.md +3 -0
- package/docs/lints/{prefer-explicit-nesting-selector.md → implicit-nesting-selector.md} +3 -3
- package/docs/lints/index.md +43 -43
- package/docs/lints/prefer-canonical-utilities.md +14 -0
- package/docs/lints/prefer-logical-properties.md +18 -0
- package/docs/lints/unknown-utility.md +1 -1
- package/docs/lints/unknown-variant.md +1 -1
- package/docs/plugins/iconify.md +270 -0
- package/docs/plugins/index.md +26 -0
- package/docs/why.md +1 -1
- package/package.json +11 -6
- package/skills/stillwind/SKILL.md +4 -1
|
@@ -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.
|
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.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
119
|
-
"@stillwind/native": "0.
|
|
120
|
-
"@stillwind/projection": "0.
|
|
123
|
+
"@stillwind/config": "0.3.0",
|
|
124
|
+
"@stillwind/native": "0.3.0",
|
|
125
|
+
"@stillwind/projection": "0.3.0"
|
|
121
126
|
},
|
|
122
127
|
"devDependencies": {
|
|
123
128
|
"@stillwind-internal/tools-workspace": "0.0.0",
|
|
124
|
-
"@types/node": "^26.6.
|
|
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",
|
|
@@ -30,7 +30,10 @@ which lists the Markdown version of each page.
|
|
|
30
30
|
| Custom utilities and variants | `docs/at-rules/index.md`, then the page of the at-rule |
|
|
31
31
|
| Available utilities | `docs/utilities.md` |
|
|
32
32
|
| `stillwind.config.ts` | `docs/configuration.md` |
|
|
33
|
-
| CLI, CI, and lint presets | `docs/guides/lint-adoption.md`
|
|
33
|
+
| CLI, CI, and lint presets | `docs/guides/lint-adoption.md`, `docs/cli.md` |
|
|
34
|
+
| Editor setup and language server | `docs/editors.md` |
|
|
35
|
+
| Prettier and other formatters | `docs/formatters.md` |
|
|
36
|
+
| Official plugins and Iconify icons | `docs/plugins/index.md`, `docs/plugins/iconify.md` |
|
|
34
37
|
| A lint finding | `docs/lints/<rule>.md` |
|
|
35
38
|
| A compiler error such as `SW01001` | `docs/errors/<code>.md` |
|
|
36
39
|
| Shadow DOM and Web Components | `docs/guides/web-components.md` |
|