コンテンツにスキップ

プリセット

プリセットは、メイン構成にマージされる部分的な構成です。

プリセットを作成する場合、通常はプリセット固有のいくつかのオプションを要求できるコンストラクタ関数を出力します。例

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
  }
})

その後、ユーザーは次のように使用できます

uno.config.ts
ts
import { defineConfig } from 'unocss'
import myPreset from './my-preset'

export default defineConfig({
  presets: [
    myPreset({ /* preset options */ }),
  ],
})

公式プリセットコミュニティープリセットで、その他の例を確認できます。

MITライセンスに基づいてリリースされました。