Urara-Blog/node_modules/.pnpm-store/v3/files/92/463c7ee42ac7f6db9ea094d01f6a6355364d4e262526d2fb7cc305ad32f5735fc7c8ce43bb0e91256ab34be6c8d90c5c0fd5256e2ad7db3928ae8df27507c1
2022-08-14 01:14:53 +08:00

77 lines
1.4 KiB
Text

# @unocss/preset-tagify
Tagify Mode for [UnoCSS](https://github.com/unocss/unocss).
## Installation
```bash
npm i -D @unocss/preset-tagify
```
```ts
import presetTagify from '@unocss/preset-tagify'
Unocss({
presets: [
presetTagify({ /* options */ }),
// ...other presets
],
})
```
## Tagify Mode
This preset can come in handy when you only need a single unocss rule to be apply on an element.
```html
<span class="text-red"> red text </span>
<div class="flex"> flexbox </div>
I'm feeling <span class="i-line-md-emoji-grin"></span> today!
```
With tagify mode, you can embed CSS styles into HTML tags:
```html
<text-red> red text </text-red>
<flex> flexbox </flex>
I'm feeling <i-line-md-emoji-grin /> today!
```
The HTML above works exactly as you would expect.
## With Prefix
```js
presetTagify({
prefix: 'un-'
})
```
```html
<!-- this will be matched -->
<un-flex> </un-flex>
<!-- this will not be matched -->
<flex> </flex>
```
## Extra Properties
You can inject extra properties to the matched rules:
```js
presetTagify({
// adds display: inline-block to matched icons
extraProperties: matched => matched.startsWith('i-')
? { display: 'inline-block' }
: { }
})
presetTagify({
// extraProperties can also be a plain object
extraProperties: { display: 'block' }
})
```
## License
MIT License &copy; 2022-PRESENT [Jeff Zou](https://github.com/zojize)
MIT License &copy; 2022-PRESENT [Anthony Fu](https://github.com/antfu)