unocss 0.50.5 โ†’ 0.50.7

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 (2) hide show
  1. package/README.md +26 -559
  2. package/package.json +21 -21
package/README.md CHANGED
@@ -19,8 +19,9 @@ The instant on-demand Atomic CSS engine.
19
19
 
20
20
  <br>
21
21
  <p align="center">
22
- <a href="https://uno.antfu.me/">๐Ÿง‘โ€๐Ÿ’ป Interactive Docs <sup>Beta</sup></a> |
23
- <a href="https://uno.antfu.me/play/">๐Ÿคนโ€โ™‚๏ธ Playground</a>
22
+ <a href="https://unocss.dev/">๐Ÿ“š Documentation</a> |
23
+ <a href="https://unocss.dev/interactive/">๐Ÿง‘โ€๐Ÿ’ป Interactive Docs</a> |
24
+ <a href="https://unocss.dev/play/">๐Ÿคนโ€โ™‚๏ธ Playground</a>
24
25
  </p>
25
26
  <br>
26
27
 
@@ -28,574 +29,40 @@ The instant on-demand Atomic CSS engine.
28
29
 
29
30
  Inspired by [Windi CSS](http://windicss.org/), [Tailwind CSS](https://tailwindcss.com/), and [Twind](https://github.com/tw-in-js/twind), but:
30
31
 
31
- - [Fully customizable](#configurations) - no core utilities, all functionalities are provided via presets.
32
+ - [Fully customizable](https://unocss.dev/config/) - no core utilities, all functionalities are provided via presets.
32
33
  - No parsing, no AST, no scanning, it's **INSTANT** (5x faster than Windi CSS or Tailwind JIT).
33
34
  - ~6kb min+brotli - zero deps and browser friendly.
34
- - [Shortcuts](#shortcuts) - aliasing utilities, dynamically.
35
- - [Attributify mode](https://github.com/unocss/unocss/tree/main/packages/preset-attributify/) - group utilities in attributes.
36
- - [Pure CSS Icons](https://github.com/unocss/unocss/tree/main/packages/preset-icons/) - use any icon as a single class.
37
- - [Variant Groups](https://github.com/unocss/unocss/tree/main/packages/transformer-variant-group) - shorthand for group utils with common prefixes.
38
- - [CSS Directives](https://github.com/unocss/unocss/tree/main/packages/transformer-directives) - reuse utils in CSS with `@apply` directive.
39
- - [Compilation mode](https://github.com/unocss/unocss/tree/main/packages/transformer-compile-class/) - synthesizes multiple classes into one at build time.
40
- - [Inspector](#inspector) - inspect and debug interactively.
41
- - [CSS-in-JS Runtime build](https://github.com/unocss/unocss/tree/main/packages/runtime) - use UnoCSS with one line of CDN import.
35
+ - [Shortcuts](https://unocss.dev/config/shortcuts) - aliasing utilities, dynamically.
36
+ - [Attributify mode](https://unocss.dev/presets/attributify/) - group utilities in attributes.
37
+ - [Pure CSS Icons](https://unocss.dev/presets/icons/) - use any icon as a single class.
38
+ - [Variant Groups](https://unocss.dev/transformers/variant-group) - shorthand for group utils with common prefixes.
39
+ - [CSS Directives](https://unocss.dev/transformers/directives) - reuse utils in CSS with `@apply` directive.
40
+ - [Compilation mode](https://unocss.dev/transformers/compile-class/) - synthesizes multiple classes into one at build time.
41
+ - [Inspector](https://unocss.dev/tools/inspector) - inspect and debug interactively.
42
+ - [CSS-in-JS Runtime build](https://unocss.dev/integrations/runtime) - use UnoCSS with one line of CDN import.
42
43
  - [VS Code extension](https://marketplace.visualstudio.com/items?itemName=antfu.unocss)
43
44
  - Code-splitting for CSS - ships minimal CSS for MPA.
44
45
 
45
- ## Installation
46
-
47
- - [Vite](https://github.com/unocss/unocss/blob/main/packages/vite)
48
- - [Nuxt](https://github.com/unocss/unocss/blob/main/packages/nuxt)
49
- - [Astro](https://github.com/unocss/unocss/blob/main/packages/astro)
50
- - [Webpack](https://github.com/unocss/unocss/blob/main/packages/webpack)
51
- - [CDN Runtime](https://github.com/unocss/unocss/blob/main/packages/runtime)
52
- - [CLI](https://github.com/unocss/unocss/blob/main/packages/cli)
53
- - [VS Code extension](https://github.com/unocss/unocss/blob/main/packages/vscode)
54
- - [ESLint Config](https://github.com/unocss/unocss/blob/main/packages/eslint-config)
55
- - [PostCSS](https://github.com/unocss/unocss/blob/main/packages/postcss)
56
-
57
- ## Configurations
58
-
59
- UnoCSS is an atomic-CSS engine instead of a framework. Everything is designed with flexibility and performance in mind. There are no core utilities in UnoCSS, all functionalities are provided via presets.
60
-
61
- By default, UnoCSS applies [the default preset](https://github.com/unocss/unocss/tree/main/packages/preset-uno), which provides a common superset of the popular utilities-first frameworks Tailwind CSS, Windi CSS, Bootstrap, Tachyons, etc.
62
-
63
- ### Presets
64
-
65
- Presets are the heart of UnoCSS. They let you make your own custom framework in minutes.
66
-
67
- ###### Official Presets
68
-
69
- - [@unocss/preset-uno](https://github.com/unocss/unocss/tree/main/packages/preset-uno) - The default preset (right now it's equivalent to `@unocss/preset-wind`).
70
- - [@unocss/preset-mini](https://github.com/unocss/unocss/tree/main/packages/preset-mini) - The minimal but essential rules and variants.
71
- - [@unocss/preset-wind](https://github.com/unocss/unocss/tree/main/packages/preset-wind) - Tailwind / Windi CSS compact preset.
72
- - [@unocss/preset-attributify](https://github.com/unocss/unocss/tree/main/packages/preset-attributify) - Provides [Attributify Mode](https://github.com/unocss/unocss/tree/main/packages/preset-attributify#attributify-mode) to other presets and rules.
73
- - [@unocss/preset-icons](https://github.com/unocss/unocss/tree/main/packages/preset-icons) - Use any icon as a class utility.
74
- - [@unocss/preset-web-fonts](https://github.com/unocss/unocss/tree/main/packages/preset-web-fonts) - Web fonts at ease.
75
- - [@unocss/preset-typography](https://github.com/unocss/unocss/tree/main/packages/preset-typography) - The typography preset.
76
- - [@unocss/preset-tagify](https://github.com/unocss/unocss/tree/main/packages/preset-tagify) - Tagify Mode for UnoCSS.
77
- - [@unocss/preset-rem-to-px](https://github.com/unocss/unocss/tree/main/packages/preset-rem-to-px) - Converts rem to px for utils.
78
-
79
- ###### Community Presets
80
-
81
- - [unocss-preset-scalpel](https://github.com/macheteHot/unocss-preset-scalpel) - Scalpel Preset by [@macheteHot](https://github.com/macheteHot/).
82
- - [unocss-preset-chroma](https://github.com/chu121su12/unocss-preset-chroma) - Gradient Preset by [@chu121su12](https://github.com/chu121su12).
83
- - [unocss-preset-scrollbar](https://github.com/action-hong/unocss-preset-scrollbar) - Scrollbar Preset by [@action-hong](https://github.com/action-hong).
84
- - [unocss-applet](https://github.com/unocss-applet/unocss-applet) - Using UnoCSS in applet (UniApp / Taro) by [@zguolee](https://github.com/zguolee).
85
- - [unocss-preset-weapp](https://github.com/MellowCo/unocss-preset-weapp) - Wechat MiniProgram Preset for [UniApp](https://uniapp.dcloud.io) and [Taro](https://taro-docs.jd.com/taro/docs) by [@MellowCo](https://github.com/MellowCo).
86
- - [unocss-preset-heropatterns](https://github.com/Julien-R44/unocss-preset-heropatterns) - Preset that integrates [Hero Patterns](https://heropatterns.com/) by [@Julien-R44](https://github.com/Julien-R44).
87
- - [unocss-preset-flowbite](https://github.com/Julien-R44/unocss-preset-flowbite) - Port of of [Flowbite Tailwind plugin](https://github.com/themesberg/flowbite) for UnoCSS by [@Julien-R44](https://github.com/Julien-R44).
88
- - [unocss-preset-forms](https://github.com/Julien-R44/unocss-preset-forms) - Port of [@tailwindcss/forms](https://github.com/tailwindlabs/tailwindcss-forms) for UnoCSS by [@Julien-R44](https://github.com/Julien-R44).
89
- - [unocss-preset-extra](https://github.com/MoomFE/unocss-preset-extra) - [Animate.css](https://animate.style) Preset and some other rules by [@Zhang-Wei-666](https://github.com/Zhang-Wei-666).
90
- - [unocss-preset-daisy](https://github.com/kidonng/unocss-preset-daisy) - daisyUI Preset by [@kidonng](https://github.com/kidonng).
91
- - [unocss-preset-primitives](https://github.com/zirbest/unocss-preset-primitives) - Like [headlessui-tailwindcss](https://github.com/tailwindlabs/headlessui/tree/main/packages/%40headlessui-tailwindcss) , radix-ui , custom for UnoCSS By [@zirbest](https://github.com/zirbest).
92
- - [unocss-preset-theme](https://github.com/Dunqing/unocss-preset-theme) - Preset for automatic theme switching by [@Dunqing](https://github.com/Dunqing).
93
- - [unocss-preset-chinese](https://github.com/kirklin/unocss-preset-chinese) - Preset for Chinese fonts by [@kirklin](https://github.com/kirklin).
94
- - [unocss-preset-autoprefixer](https://github.com/zouhangwithsweet/unocss-preset-autoprefixer) - Autoprefixer Preset by [@zouhang](https://github.com/zouhangwithsweet).
95
- - [unocss-preset-scrollbar-hide](https://github.com/reslear/unocss-preset-scrollbar-hide) - Hide scrollbars, although the element can still be scrolled by [@reslear](https://github.com/reslear).
96
- - [unocss-preset-radix](https://github.com/endigma/unocss-preset-radix) - Use the Radix UI color palette with UnoCSS by [@endigma](https://github.com/endigma)
97
- - [unocss-preset-glyph](https://github.com/chu121su12/unocss-preset-glyph) - Embed subset of glyphs from fonts by [@chu121su12](https://github.com/chu121su12).
98
-
99
- ###### Community Frameworks
100
-
101
- - [Anu](https://github.com/jd-solanki/anu) - DX focused utility based vue component library by [@jd-solanki](https://github.com/jd-solanki).
102
- - [OnuUI](https://github.com/onu-ui/onu-ui) - Popular, beautiful and fast UnoCSS component library by [@zyyv](https://github.com/zyyv), [@yzh990918](https://github.com/yzh990918).
103
-
104
- ### Using Presets
105
-
106
- To set presets to your project:
107
-
108
- ```ts
109
- // vite.config.ts
110
- import UnoCSS from 'unocss/vite'
111
- import { presetAttributify, presetUno } from 'unocss'
112
-
113
- export default {
114
- plugins: [
115
- UnoCSS({
116
- presets: [
117
- presetAttributify({ /* preset options */}),
118
- presetUno(),
119
- // ...custom presets
120
- ],
121
- }),
122
- ],
123
- }
124
- ```
125
-
126
- When the `presets` option is specified, the default preset will be ignored.
127
-
128
- To disable the default preset, you can set `presets` to an empty array:
129
-
130
- ```ts
131
- // vite.config.ts
132
- import UnoCSS from 'unocss/vite'
133
-
134
- export default {
135
- plugins: [
136
- UnoCSS({
137
- presets: [], // disable default preset
138
- rules: [
139
- // your custom rules
140
- ],
141
- }),
142
- ],
143
- }
144
- ```
145
-
146
- ### Custom Rules
147
-
148
- ###### Static Rules
149
-
150
- Writing custom rules for UnoCSS is super easy. For example:
151
-
152
- ```ts
153
- rules: [
154
- ['m-1', { margin: '0.25rem' }],
155
- ]
156
- ```
157
-
158
- You will have the following CSS generated whenever `m-1` is detected in users' codebase:
159
-
160
- ```css
161
- .m-1 { margin: 0.25rem; }
162
- ```
163
-
164
- ###### Dynamic Rules
165
-
166
- To make it smarter, change the matcher to a RegExp and the body to a function:
167
-
168
- ```ts
169
- rules: [
170
- [/^m-(\d+)$/, ([, d]) => ({ margin: `${d / 4}rem` })],
171
- [/^p-(\d+)$/, match => ({ padding: `${match[1] / 4}rem` })],
172
- ]
173
- ```
174
-
175
- The first argument of the body function is the match result, you can destructure it to get the matched groups.
176
-
177
- For example, with the following usage:
178
-
179
- ```html
180
- <div class="m-100">
181
- <button class="m-3">
182
- <icon class="p-5" />
183
- My Button
184
- </button>
185
- </div>
186
- ```
187
-
188
- the corresponding CSS will be generated:
189
-
190
- ```css
191
- .m-100 { margin: 25rem; }
192
- .m-3 { margin: 0.75rem; }
193
- .p-5 { padding: 1.25rem; }
194
- ```
195
-
196
- Congratulations! Now you got your own powerful atomic CSS utilities, enjoy!
197
-
198
- ###### Full Controlled Rules
199
-
200
- <details>
201
- <summary>This is an advanced feature, you don't need it in most of the cases.</summary>
202
-
203
- <br>
204
-
205
- When you really need some advanced rules that can't be covered by the combination of [Dynamic Rules](#dynamic-rules) and [Variants](#custom-variants), we also provide a way to give you full control to generate the CSS.
206
-
207
- By returning a `string` from the dynamic rule's body function, it will be directly passed to the generated CSS. That also means you would need to take care of things like CSS escaping, variants applying, CSS constructing, and so on.
208
-
209
- ```ts
210
- import UnoCSS, { toEscapedSelector as e } from 'unocss'
211
-
212
- UnoCSS({
213
- rules: [
214
- [/^custom-(.+)$/, ([, name], { rawSelector, currentSelector, variantHandlers, theme }) => {
215
- // discard mismatched rules
216
- if (name.includes('something'))
217
- return
218
-
219
- // if you want, you can disable the variants for this rule
220
- if (variantHandlers.length)
221
- return
222
- const selector = e(rawSelector)
223
- // return a string instead of an object
224
- return `
225
- ${selector} {
226
- font-size: ${theme.fontSize.sm};
227
- }
228
- /* you can have multiple rules */
229
- ${selector}::after {
230
- content: 'after';
231
- }
232
- .foo > ${selector} {
233
- color: red;
234
- }
235
- /* or media queries */
236
- @media (min-width: ${theme.breakpoints.sm}) {
237
- ${selector} {
238
- font-size: ${theme.fontSize.sm};
239
- }
240
- }
241
- `
242
- }],
243
- ],
244
- })
245
- ```
246
-
247
- You might need to read some code to take the full power of it.
248
-
249
- </details>
250
-
251
- ### Ordering
252
-
253
- UnoCSS respects the order of the rules you defined in the generated CSS. Latter ones come with higher priority.
254
-
255
- ### Shortcuts
256
-
257
- The shortcuts functionality that UnoCSS provides is similar to [Windi CSS's](https://windicss.org/features/shortcuts.html) one
258
-
259
- <!--eslint-skip-->
260
-
261
- ```ts
262
- shortcuts: {
263
- // shortcuts to multiple utilities
264
- 'btn': 'py-2 px-4 font-semibold rounded-lg shadow-md',
265
- 'btn-green': 'text-white bg-green-500 hover:bg-green-700',
266
- // single utility alias
267
- 'red': 'text-red-100'
268
- }
269
- ```
270
-
271
- In addition to the plain mapping, UnoCSS also allows you to define dynamic shortcuts.
272
-
273
- Similar to [Rules](#custom-rules), a dynamic shortcut is the combination of a matcher RegExp and a handler function.
274
-
275
- ```ts
276
- shortcuts: [
277
- // you could still have object style
278
- {
279
- btn: 'py-2 px-4 font-semibold rounded-lg shadow-md',
280
- },
281
- // dynamic shortcuts
282
- [/^btn-(.*)$/, ([, c]) => `bg-${c}-400 text-${c}-100 py-2 px-4 rounded-lg`],
283
- ]
284
- ```
285
-
286
- With this, we could use `btn-green` and `btn-red` to generate the following CSS:
287
-
288
- ```css
289
- .btn-green {
290
- padding-top: 0.5rem;
291
- padding-bottom: 0.5rem;
292
- padding-left: 1rem;
293
- padding-right: 1rem;
294
- --un-bg-opacity: 1;
295
- background-color: rgba(74, 222, 128, var(--un-bg-opacity));
296
- border-radius: 0.5rem;
297
- --un-text-opacity: 1;
298
- color: rgba(220, 252, 231, var(--un-text-opacity));
299
- }
300
- .btn-red {
301
- padding-top: 0.5rem;
302
- padding-bottom: 0.5rem;
303
- padding-left: 1rem;
304
- padding-right: 1rem;
305
- --un-bg-opacity: 1;
306
- background-color: rgba(248, 113, 113, var(--un-bg-opacity));
307
- border-radius: 0.5rem;
308
- --un-text-opacity: 1;
309
- color: rgba(254, 226, 226, var(--un-text-opacity));
310
- }
311
- ```
312
-
313
- ### Rules Merging
314
-
315
- By default, UnoCSS will merge CSS rules with the same body to minimize the CSS size.
316
-
317
- For example, `<div class="m-2 hover:m2">` will generate
318
-
319
- ```css
320
- .hover\:m2:hover, .m-2 { margin: 0.5rem; }
321
- ```
322
-
323
- instead of two separate rules:
324
-
325
- ```css
326
- .hover\:m2:hover { margin: 0.5rem; }
327
- .m-2 { margin: 0.5rem; }
328
- ```
329
-
330
- ### Style Resetting
331
-
332
- UnoCSS does not provide style resetting or preflight by default for maximum flexibility and does not populate your global CSS. If you use UnoCSS along with other CSS frameworks, they probably already do the resetting for you. If you use UnoCSS alone, you can use resetting libraries like [Normalize.css](https://necolas.github.io/normalize.css/).
333
-
334
- We also provide a small collection for you to grab them quickly:
46
+ ## Documentation
335
47
 
336
- ```bash
337
- npm i @unocss/reset
338
- ```
48
+ Read the [documentation](https://unocss.dev/) for more details.
339
49
 
340
- ```ts
341
- // main.js
342
- // pick one of the following
343
-
344
- // normalize.css
345
- import '@unocss/reset/normalize.css'
346
- // reset.css by Eric Meyer https://meyerweb.com/eric/tools/css/reset/index.html
347
- import '@unocss/reset/eric-meyer.css'
348
- // preflights from tailwind
349
- import '@unocss/reset/tailwind.css'
350
- // https://github.com/unocss/unocss/blob/main/packages/reset/tailwind-compat.md
351
- import '@unocss/reset/tailwind-compat.css'
352
- ```
353
-
354
- Learn more at [@unocss/reset](https://github.com/unocss/unocss/tree/main/packages/reset).
355
-
356
- ### Preflight
357
-
358
- You can inject raw css as preflights from the configuration. The resolved `theme` is available to customize the css.
359
-
360
- <!--eslint-skip-->
361
-
362
- ```ts
363
- preflights: [
364
- {
365
- getCSS: ({ theme }) => `
366
- * {
367
- color: ${theme.colors.gray?.[700] ?? '#333'};
368
- padding: 0;
369
- margin: 0;
370
- }
371
- `
372
- }
373
- ]
374
- ```
375
-
376
- ### Custom Variants
377
-
378
- [Variants](https://windicss.org/utilities/general/variants.html) allows you to apply some variations to your existing rules. For example, to implement the `hover:` variant from Tailwind:
379
-
380
- <!--eslint-skip-->
381
-
382
- ```ts
383
- variants: [
384
- // hover:
385
- (matcher) => {
386
- if (!matcher.startsWith('hover:'))
387
- return matcher
388
- return {
389
- // slice `hover:` prefix and passed to the next variants and rules
390
- matcher: matcher.slice(6),
391
- selector: s => `${s}:hover`,
392
- }
393
- }
394
- ],
395
- rules: [
396
- [/^m-(\d)$/, ([, d]) => ({ margin: `${d / 4}rem` })],
397
- ]
398
- ```
399
-
400
- - `matcher` controls when the variant is enabled. If the return value is a string, it will be used as the selector for matching the rules.
401
- - `selector` provides the availability of customizing the generated CSS selector.
402
-
403
- Let's have a tour of what happened when matching for `hover:m-2`:
404
-
405
- - `hover:m-2` is extracted from users usages
406
- - `hover:m-2` send to all variants for matching
407
- - `hover:m-2` is matched by our variant and returns `m-2`
408
- - the result `m-2` will be used for the next round of variants matching
409
- - if no other variant is matched, `m-2` will then goes to match the rules
410
- - our first rule get matched and generates `.m-2 { margin: 0.5rem; }`
411
- - finally, we apply our variants' transformation to the generated CSS. In this case, we prepended `:hover` to the `selector` hook
412
-
413
- As a result, the following CSS will be generated:
414
-
415
- ```css
416
- .hover\:m-2:hover { margin: 0.5rem; }
417
- ```
418
-
419
- With this, we could have `m-2` applied only when users hover over the element.
420
-
421
- The variant system is very powerful and can't be covered fully in this guide, you can check [the default preset's implementation](https://github.com/unocss/unocss/tree/main/packages/preset-mini/src/_variants) to see more advanced usages.
422
-
423
- ### Extend Theme
424
-
425
- UnoCSS also supports the theming system that you might be familiar with in Tailwind / Windi. At the user level, you can specify the `theme` property in your config, and it will be deep merged to the default theme.
426
-
427
- <!--eslint-skip-->
428
-
429
- ```ts
430
- theme: {
431
- // ...
432
- colors: {
433
- 'veryCool': '#0000ff', // class="text-very-cool"
434
- 'brand': {
435
- 'primary': 'hsla(var(--hue, 217), 78%, 51%)', //class="bg-brand-primary"
436
- }
437
- },
438
- }
439
- ```
440
-
441
- To consume the theme in rules:
442
-
443
- ```ts
444
- rules: [
445
- [/^text-(.*)$/, ([, c], { theme }) => {
446
- if (theme.colors[c])
447
- return { color: theme.colors[c] }
448
- }],
449
- ]
450
- ```
451
-
452
- One exception is that UnoCSS gives full control of `breakpoints` to users. When a custom `breakpoints` is provided, the default will be overridden instead of merging. For example:
453
-
454
- <!--eslint-skip-->
455
-
456
- ```ts
457
- theme: {
458
- // ...
459
- breakpoints: {
460
- sm: '320px',
461
- md: '640px',
462
- },
463
- }
464
- ```
465
-
466
- Right now, you can only use the `sm:` and `md:` breakpoint variants.
467
-
468
- `verticalBreakpoints` is same as `breakpoints` but for vertical layout.
469
-
470
- ### Layers
471
-
472
- The order of CSS will affect their priorities. While we will [retain the order of rules](#ordering), sometimes you may want to group some utilities to have more explicit control of their order.
473
-
474
- Unlike Tailwind, which offers 3 fixed layers (`base`, `components`, `utilities`), UnoCSS allows you to define the layers as you want. To set the layer, you can pass the metadata as the third item of your rules:
475
-
476
- ```ts
477
- rules: [
478
- [/^m-(\d)$/, ([, d]) => ({ margin: `${d / 4}rem` }), { layer: 'utilities' }],
479
- // when you omit the layer, it will be `default`
480
- ['btn', { padding: '4px' }],
481
- ]
482
- ```
483
-
484
- This will generate:
485
-
486
- ```css
487
- /* layer: default */
488
- .btn { padding: 4px; }
489
- /* layer: utilities */
490
- .m-2 { margin: 0.5rem; }
491
- ```
492
-
493
- Layering also can be set on each preflight:
494
-
495
- ```ts
496
- preflights: [
497
- {
498
- layer: 'my-layer',
499
- getCSS: async () => (await fetch('my-style.css')).text(),
500
- },
501
- ]
502
- ```
503
-
504
- You can control the order of layers by:
505
-
506
- <!--eslint-skip-->
507
-
508
- ```ts
509
- layers: {
510
- components: -1,
511
- default: 1,
512
- utilities: 2,
513
- 'my-layer': 3,
514
- }
515
- ```
516
-
517
- Layers without specified order will be sorted alphabetically.
518
-
519
- When you want to have your custom CSS between layers, you can update your entry module:
520
-
521
- ```ts
522
- // 'uno:[layer-name].css'
523
- import 'uno:components.css'
524
- // layers that are not 'components' and 'utilities' will fallback to here
525
- import 'uno.css'
526
- // your own CSS
527
- import './my-custom.css'
528
- // "utilities" layer will have the highest priority
529
- import 'uno:utilities.css'
530
- ```
531
-
532
- ### Utilities Preprocess & Prefixing
533
-
534
- UnoCSS also provides the ability to preprocess and transform extracted utilities before processing to the matcher. For example, the following example allows you to add a global prefix to all utilities:
535
-
536
- <!--eslint-skip-->
537
-
538
- ```ts
539
- preprocess(matcher) {
540
- return matcher.startsWith('prefix-')
541
- ? matcher.slice(7)
542
- : undefined // ignore
543
- }
544
- ```
545
-
546
- ### Scanning
547
-
548
- Please note that UnoCSS works **at build time**, meaning only statically presented utilities will be generated and shipped to your app. Utilities that used dynamically or fetched from external resources at runtime might not be applied.
549
-
550
- By default, UnoCSS will extract the utilities usage from files in your build pipeline with extension `.jsx`, `.tsx`, `.vue`, `.md`, `.html`, `.svelte`, `.astro`. And then generate the CSS on demand.
551
-
552
- `.js` and `.ts` files are **NOT included by default**. You can add `@unocss-include`, per-file basis, anywhere in the file that you want UnoCSS to scan, or add `*.js` or `*.ts` in the configuration to include all js/ts files as scan targets. Similarly, you can also add `@unocss-ignore` to bypass the scanning and transforming for a file.
553
-
554
- ### Safelist
555
-
556
- Sometimes you might want have to use dynamic concatenations like:
557
-
558
- ```html
559
- <div class="p-${size}"></div> <!-- this won't work! -->
560
- ```
561
-
562
- Due the fact that UnoCSS works in build time using static extracting, at the compile time we can't possibility know all the combination of the utilities. For that, you can configure the `safelist` option.
563
-
564
- ```ts
565
- safelist: 'p-1 p-2 p-3 p-4'.split(' ')
566
- ```
567
-
568
- the corresponding CSS will always be generated:
569
-
570
- ```css
571
- .p-1 { padding: 0.25rem; }
572
- .p-2 { padding: 0.5rem; }
573
- .p-3 { padding: 0.75rem; }
574
- .p-4 { padding: 1rem; }
575
- ```
576
-
577
- Or more flexible:
578
-
579
- ```ts
580
- safelist: [
581
- ...Array.from({ length: 4 }, (_, i) => `p-${i + 1}`),
582
- ]
583
- ```
584
-
585
- If you are seaking for the true dynamic generation at the runtime, you may check the [@unocss/runtime](https://github.com/unocss/unocss/tree/main/packages/runtime) package.
586
-
587
- ### Inspector
588
-
589
- From v0.7.0, our Vite plugin now ships with a dev inspector ([@unocss/inspector](https://github.com/unocss/unocss/tree/main/packages/inspector)) for you to view, play and analyse your custom rules and setup. Visit `http://localhost:3000/__unocss` in your Vite dev server to see it.
590
-
591
- <img src="https://user-images.githubusercontent.com/11247099/140885990-1827f5ce-f12a-4ed4-9d63-e5145a65fb4a.png">
592
-
593
- ### Runtime (CSS-in-JS)
50
+ ## Installation
594
51
 
595
- See [@unocss/runtime](https://github.com/unocss/unocss/tree/main/packages/runtime)
52
+ - [Vite](https://unocss.dev/integrations/vite)
53
+ - [Nuxt](https://unocss.dev/integrations/nuxt)
54
+ - [Astro](https://unocss.dev/integrations/astro)
55
+ - [Webpack](https://unocss.dev/integrations/webpack)
56
+ - [CDN Runtime](https://unocss.dev/integrations/runtime)
57
+ - [CLI](https://unocss.dev/integrations/cli)
58
+ - [VS Code extension](https://unocss.dev/integrations/vscode)
59
+ - [ESLint Config](https://unocss.dev/integrations/eslint-config)
60
+ - [PostCSS](https://unocss.dev/integrations/postcss)
596
61
 
597
62
  ## Acknowledgement
598
63
 
64
+ UnoCSS is made possible thanks to the insprations from the following projects:
65
+
599
66
  > in alphabet order
600
67
 
601
68
  - [ACSS](https://acss.io/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unocss",
3
- "version": "0.50.5",
3
+ "version": "0.50.7",
4
4
  "description": "The instant on-demand Atomic CSS engine.",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -103,7 +103,7 @@
103
103
  "node": ">=14"
104
104
  },
105
105
  "peerDependencies": {
106
- "@unocss/webpack": "0.50.5"
106
+ "@unocss/webpack": "0.50.7"
107
107
  },
108
108
  "peerDependenciesMeta": {
109
109
  "@unocss/webpack": {
@@ -111,27 +111,27 @@
111
111
  }
112
112
  },
113
113
  "dependencies": {
114
- "@unocss/astro": "0.50.5",
115
- "@unocss/cli": "0.50.5",
116
- "@unocss/core": "0.50.5",
117
- "@unocss/postcss": "0.50.5",
118
- "@unocss/preset-attributify": "0.50.5",
119
- "@unocss/preset-icons": "0.50.5",
120
- "@unocss/preset-mini": "0.50.5",
121
- "@unocss/preset-tagify": "0.50.5",
122
- "@unocss/preset-typography": "0.50.5",
123
- "@unocss/preset-uno": "0.50.5",
124
- "@unocss/preset-web-fonts": "0.50.5",
125
- "@unocss/preset-wind": "0.50.5",
126
- "@unocss/reset": "0.50.5",
127
- "@unocss/transformer-attributify-jsx": "0.50.5",
128
- "@unocss/transformer-compile-class": "0.50.5",
129
- "@unocss/transformer-directives": "0.50.5",
130
- "@unocss/transformer-variant-group": "0.50.5",
131
- "@unocss/vite": "0.50.5"
114
+ "@unocss/astro": "0.50.7",
115
+ "@unocss/cli": "0.50.7",
116
+ "@unocss/core": "0.50.7",
117
+ "@unocss/postcss": "0.50.7",
118
+ "@unocss/preset-attributify": "0.50.7",
119
+ "@unocss/preset-icons": "0.50.7",
120
+ "@unocss/preset-mini": "0.50.7",
121
+ "@unocss/preset-tagify": "0.50.7",
122
+ "@unocss/preset-typography": "0.50.7",
123
+ "@unocss/preset-uno": "0.50.7",
124
+ "@unocss/preset-web-fonts": "0.50.7",
125
+ "@unocss/preset-wind": "0.50.7",
126
+ "@unocss/reset": "0.50.7",
127
+ "@unocss/transformer-attributify-jsx": "0.50.7",
128
+ "@unocss/transformer-compile-class": "0.50.7",
129
+ "@unocss/transformer-directives": "0.50.7",
130
+ "@unocss/transformer-variant-group": "0.50.7",
131
+ "@unocss/vite": "0.50.7"
132
132
  },
133
133
  "devDependencies": {
134
- "@unocss/webpack": "0.50.5"
134
+ "@unocss/webpack": "0.50.7"
135
135
  },
136
136
  "scripts": {
137
137
  "build": "unbuild",