ColorModeSwitch (ColorModeSwitch)
Usage
ColorModeSwitch 구성 요소는 Switch 구성 요소를 확장하므로 color, size 등의 속성을 전달할 수 있습니다.
<template>
<UColorModeSwitch />
</template>예
사용자 정의 아이콘 포함
app.config.ts를 사용하여 ui.icons 속성을 사용하여 아이콘을 사용자 정의합니다.
export default defineAppConfig({
ui: {
icons: {
light: 'i-lucide-sun-medium',
dark: 'i-lucide-moon-star'
}
}
})
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-lucide-sun-medium',
dark: 'i-lucide-moon-star'
}
}
})
]
})
API 파일
Props (### Props)
| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
color | 'primary' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
highlight | boolean Highlight the ring color like a focus state. | |
name | stringThe name of the field. Submitted with its owning form as part of a name/value pair. | |
loading | boolean When | |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
autofocus | false | true | "true" | "false" | |
disabled | boolean When | |
label | string | |
loadingIcon | appConfig.ui.icons.loading | anyThe icon when the |
defaultValue | boolean The state of the switch when it is initially rendered. Use when you do not need to control its state. | |
required | boolean When | |
id | string | |
value | stringThe value given as data when submitted with a | |
description | string | |
trueValue | boolean The value used when the switch is on. Defaults to | |
falseValue | boolean The value used when the switch is off. Defaults to | |
ui | { root?: SlotClass; base?: SlotClass; container?: SlotClass; thumb?: SlotClass; icon?: SlotClass; wrapper?: SlotClass; label?: SlotClass; description?: SlotClass; } |