The ColorModeButton component extends the Button component, so you can pass any property such as color, variant, size, etc.
<template>
<UColorModeButton />
</template>
color="neutral" and variant="ghost".Use the app.config.ts to customize the icon with the ui.icons property:
export default defineAppConfig({
ui: {
icons: {
light: 'i-ph-sun',
dark: 'i-ph-moon'
}
}
})
Use the vite.config.ts to customize the icon with the ui.icons property:
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 the button is wrapped in a ClientOnly component, you can pass a fallback slot to display a placeholder while the component is loading.
<template>
<UColorModeButton>
<template #fallback>
<UButton loading variant="ghost" color="neutral" />
</template>
</UColorModeButton>
</template>
| Prop | Default | Type |
|---|---|---|
as |
The element or component this component should render as when not a link. | |
color |
| |
variant |
|
|
trailingIcon |
Display an icon on the right side. | |
name |
| |
active |
Force the link to be active independent of the current route. | |
trailing |
When | |
loading |
When | |
referrerpolicy |
| |
icon |
Display an icon based on the | |
size |
|
|
avatar |
Display an avatar on the left side.
| |
to |
Route Location the link should navigate to when clicked on.
| |
target |
Where to display the linked URL, as the name for a browsing context. | |
trailingSlash |
An option to either add or remove trailing slashes in the | |
autofocus | ||
disabled |
| |
form |
| |
formaction |
| |
formenctype |
| |
formmethod |
| |
formnovalidate |
| |
formtarget |
| |
type |
|
The type of the button when not a link. |
value |
| |
download |
| |
hreflang |
| |
media |
| |
ping |
| |
label |
| |
activeColor |
| |
activeVariant |
| |
square |
Render the button with equal padding on all sides. | |
block |
Render the button full width. | |
loadingAuto |
Set loading state automatically based on the | |
leading |
When | |
leadingIcon |
Display an icon on the left side. | |
loadingIcon |
|
The icon when the |
ui |
|
| Slot | Type |
|---|---|
fallback |
|
5cb65 — feat: import @nuxt/ui-pro components