ColorModeSwitch 组件扩展了 Switch 组件,因此您可以传递任何属性,例如 color、size 等。
<template>
<UColorModeSwitch />
</template>
使用 app.config.ts 通过 ui.icons 属性来自定义图标。
export default defineAppConfig({
ui: {
icons: {
light: 'i-ph-sun',
dark: 'i-ph-moon'
}
}
})
使用 vite.config.ts 通过 ui.icons 属性来自定义图标。
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
icons: {
light: 'i-ph-sun',
dark: 'i-ph-moon'
}
}
})
]
})
| 属性 | 默认值 | 类型 |
|---|---|---|
as | 'div' | any此组件应渲染为的元素或组件。 |
color | 'primary' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
name | string字段的名称。作为名称/值对的一部分随其所属表单提交。 | |
loading | boolean当为 | |
尺寸 | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
autofocus | false | true | "true" | "false" | |
disabled | boolean当为 | |
label | string | |
loadingIcon | appConfig.ui.icons.loading | any当 |
defaultValue | boolean开关在初次渲染时的状态。当您不需要控制其状态时使用。 | |
required | boolean当为 | |
id | string | |
value | string当与 | |
description | string | |
ui | { root?: ClassNameValue; base?: ClassNameValue; container?: ClassNameValue; thumb?: ClassNameValue; icon?: ClassNameValue; wrapper?: ClassNameValue; label?: ClassNameValue; description?: ClassNameValue; } |