Skip to content

Presets

Presets là các cấu hình một phần sẽ được hợp nhất vào cấu hình chính.

Khi tạo một preset, chúng tôi thường xuất một hàm khởi tạo mà bạn có thể yêu cầu một số tùy chọn cụ thể cho preset. Ví dụ:

ts
import { definePreset, Preset } from 'unocss'

export default definePreset((options?: MyPresetOptions) => {
  return {
    name: 'my-preset',
    rules: [
      // ...
    ],
    variants: [
      // ...
    ],
    // nó hỗ trợ hầu hết các cấu hình bạn có thể có trong cấu hình gốc
  }
})

Sau đó người dùng có thể sử dụng nó như thế này:

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

export default defineConfig({
  presets: [
    myPreset({ /* các tùy chọn preset */ }),
  ],
})

Bạn có thể kiểm tra presets chính thứcpresets cộng đồng để biết thêm ví dụ.

Released under the MIT License.