Attributify Mode for UnoCSS.
npm i @unocss-applet/transformer-attributify --save-dev # with npm
yarn add @unocss-applet/transformer-attributify -D # with yarn
pnpm add @unocss-applet/transformer-attributify -D # with pnpm
import { defineConfig } from 'unocss'
import transformerAttributify from '@unocss-applet/transformer-attributify'
export default defineConfig({
// ...
transformers: [
transformerAttributify(),
],
})
export interface TransformerAttributifyOptions {
/**
* Enable attributify, only build applet should be true
* e.g. In uniapp set `enable: !(process.env.UNI_PLATFORM === 'h5')` to disable for h5
* @default true
*/
enable?: boolean
/**
* @default 'un-'
*/
prefix?: string
/**
* Only match for prefixed attributes
*
* @default false
*/
prefixedOnly?: boolean
/**
* Support matching non-valued attributes
*
* For example
* ```html
* <div mt-2 />
* ```
*
* @default true
*/
nonValuedAttribute?: boolean
/**
* A list of attributes to be ignored from extracting.
*/
ignoreAttributes?: string[]
/**
* Delete attributes that added in `class=""`
* @default false
*/
deleteClass?: boolean
}
Attributes will be retained unless
deleteClass
is set totrue
, but deletion is not recommended.
<div h-80 text-center flex flex-col align-center select-none all:transition-400>
py-3
</div>
<div h-80 text-center flex flex-col align-center select-none all:transition-400 class="h-80 text-center flex flex-col select-none all:transition-400">
py-3
</div>
MIT License © 2022-PRESENT Neil Lee