Presets
预加载 Presets 是部分配置,将合并到主配置中。
当创作预加载 Preset 时,我们通常导出一个构造函数,你可以要求一些特定于预加载 Preset 的选项。例如:
ts
// my-preset.ts
import { Preset, definePreset } from 'unocss'
export default definePreset((options?: MyPresetOptions) => {
return {
name: 'my-preset',
rules: [
// ...
],
variants: [
// ...
],
// it supports most of the configuration you could have in the root config
}
})Then the user can use it like this:
ts
// uno.config.ts
import { defineConfig } from 'unocss'
import myPreset from './my-preset'
export default defineConfig({
presets: [
myPreset({ /* preset options */ }),
],
})You can check official presets and community presets for more examples.