ColorModeButton 组件扩展了 Button 组件,因此你可以传递任何属性,例如 color、variant、size 等。
<template>
<UColorModeButton />
</template>
color="neutral" 和 variant="ghost"。使用 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'
}
}
})
]
})
由于按钮被包裹在ClientOnly组件中,你可以传递一个 fallback 插槽,在组件加载时显示一个占位符。
<template>
<UColorModeButton>
<template #fallback>
<UButton loading variant="ghost" color="neutral" />
</template>
</UColorModeButton>
</template>
| 属性 | 默认值 | 类型 |
|---|---|---|
as |
|
此组件在不是链接时应呈现的元素或组件。 |
color |
|
|
variant |
|
|
尺寸 |
|
|
disabled |
| |
ui |
|
| 插槽 | 类型 |
|---|---|
回退 |
|
5cb65— 特性:导入 @nuxt/ui-pro 组件