Skip to content

Presets

Presets are partial configurations that will be merged into the main configuration.

When authoring a preset, we usually export a constructor function that you could ask for some preset-specific options. For example:

my-preset.ts
ts
import { definePreset, Preset } 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:

uno.config.ts
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.

Released under the MIT License.