Usage
The ColorModeButton component extends the Button component, so you can pass any property such as color, variant, size, etc.
<template>
<PColorModeButton />
</template>
color="neutral" and variant="ghost".Examples
With custom icons
Use the app.config.ts to customize the icon with the pohon.icons property:
export default defineAppConfig({
pohon: {
icons: {
light: 'i-ph:sun',
dark: 'i-ph:moon'
}
}
})
Use the vite.config.ts to customize the icon with the pohon.icons property:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'
export default defineConfig({
plugins: [
vue(),
pohon({
pohon: {
icons: {
light: 'i-ph:sun',
dark: 'i-ph:moon'
}
}
})
]
})
With fallback slot
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>
<PColorModeButton>
<template #fallback>
<PButton loading variant="ghost" color="neutral" />
</template>
</PColorModeButton>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
as | 'button' | anyThe element or component this component should render as when not a link. |
color | 'neutral' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
variant | 'ghost' | "link" | "ghost" | "solid" | "outline" | "soft" | "subtle" |
trailingIcon | string | objectDisplay an icon on the right side. | |
name | string | |
trailing | boolean When | |
loading | boolean When | |
icon | string | objectDisplay an icon based on the | |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
avatar | PAvatarPropsDisplay an avatar on the left side.
| |
autofocus | false | true | "true" | "false" | |
disabled | boolean | |
type | 'button' | "reset" | "submit" | "button"The type of the button when not a link. |
label | string | |
activeColor | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | |
activeVariant | "link" | "ghost" | "solid" | "outline" | "soft" | "subtle" | |
square | boolean Render the button with equal padding on all sides. | |
block | boolean Render the button full width. | |
loadingAuto | boolean Set loading state automatically based on the | |
leading | boolean When | |
leadingIcon | string | objectDisplay an icon on the left side. | |
loadingIcon | appConfig.pohon.icons.loading | string | objectThe icon when the |
pohon | { base?: ClassValue; label?: ClassValue; leadingIcon?: ClassValue; leadingAvatar?: ClassValue; leadingAvatarSize?: ClassValue; trailingIcon?: ClassValue; } |
Slots
| Slot | Type |
|---|---|
fallback | object |