Skip to content

LeekJay/unocss-preset-component

 
 

Repository files navigation

unocss-preset-component

Easy to generate preset from css string, css in js object, postcss Rule

Installation

npm i -D unocss-preset-component

Usages

uno.config.ts

import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { defineConfig, presetUno } from 'unocss'
import postcssNested from 'postcss-nested'
import presetComponent from 'unocss-preset-component'

export default defineConfig({
  presets: [
    presetUno(),
    presetComponent({
      style: readFileSync(resolve(__dirname, './style/switch.css')),
      postcssPlugins: [postcssNested()],
    }),
  ],
})

Options

style

style string | css in js |Root object

layer

The layer name of this component

postcssPlugins

postcss plugins (do not support async plugin)

NOTE

Some special prefixes(e.g 'link-', 'file-') may conflict with variants in presetMini().

To avoid conflicts, it will be automatically added '_' as prefix (e.g 'link-' to '_link-')

Example

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 62.4%
  • CSS 20.4%
  • Vue 15.9%
  • HTML 1.3%