happy play with preset-attributify in jsx/tsx
npm i -D @unocss/transformer-attributify-jsx
// uno.config.js
import {defineConfig} from 'unocss'
import transformerAttributifyJsx from "@unocss/transformer-attributify-jsx"
import {presetAttributify} from "unocss/src";
export default defineConfig({
// ...
transformers: [
transformerAttributifyJsx(),
],
presets: [
// ...
presetAttributify()
]
})
⚠️ The rules are almost the same as those ofpreset-attributify
, but there are several precautions
<div translate-x-100% /> // cannot end with `%`
<div hover:text-2xl /> // cannot contain `:`
<div translate-x-[100px] /> // cannot contain `[` or `]`
<div text-5xl animate-bounce>
unocss
</div>
Will be compiled to:
<div text-5xl="" animate-bounce="">
unocss
</div>
MIT License © 2021-PRESENT Anthony Fu