ColorModeSelect
Usage
The ColorModeSelect component extends the SelectMenu component, so you can pass any property such as color, variant, size, etc.
<template>
<PColorModeSelect />
</template>
Examples
With custom icons
Use the app.config.ts to customize the icon with the pohon.icons property:
export default defineAppConfig({
pohon: {
icons: {
system: 'i-ph:desktop',
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'
}
}
})
]
})
API
Props
| Prop | Default | Type |
|---|---|---|
trailingIcon | appConfig.pohon.icons.chevronDown | string | objectThe icon displayed to open the menu. |
color | 'primary' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
name | stringThe name of the field. Submitted with its owning form as part of a name/value pair. | |
content | { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' } | AAutocompleteContentProps & Partial<EmitsToProps<DismissableLayerEmits>>The content of the menu.
|
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
avatar | PAvatarPropsDisplay an avatar on the left side.
| |
variant | 'outline' | "ghost" | "outline" | "soft" | "subtle" | "none" |
leadingIcon | string | objectDisplay an icon on the left side. | |
loadingIcon | appConfig.pohon.icons.loading | string | objectThe icon when the |
by | string | (a: PSelectMenuItem[], b: PSelectMenuItem[]): booleanUse this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.
| |
defaultValue | string | number | bigint | false | true | { [key: string]: any; label?: string; description?: string; icon?: string | object; avatar?: PAvatarProps; chip?: PChipProps; type?: "item" | "label" | "separator"; disabled?: boolean; onSelect?: (event?: Event) => void; class?: any; pohon?: Pick<{ root?: ClassValue; base?: ClassValue; leading?: ClassValue; leadingIcon?: ClassValue; leadingAvatar?: ClassValue; leadingAvatarSize?: ClassValue; trailing?: ClassValue; trailingIcon?: ClassValue; value?: ClassValue; placeholder?: ClassValue; arrow?: ClassValue; content?: ClassValue; viewport?: ClassValue; group?: ClassValue; empty?: ClassValue; label?: ClassValue; separator?: ClassValue; item?: ClassValue; itemLeadingIcon?: ClassValue; itemLeadingAvatar?: ClassValue; itemLeadingAvatarSize?: ClassValue; itemLeadingChip?: ClassValue; itemLeadingChipSize?: ClassValue; itemTrailing?: ClassValue; itemTrailingIcon?: ClassValue; itemWrapper?: ClassValue; itemLabel?: ClassValue; itemDescription?: ClassValue; input?: ClassValue; focusScope?: ClassValue; trailingClear?: ClassValue; }, "item" | "label" | "separator" | "itemLeadingIcon" | "itemLeadingAvatar" | "itemLeadingAvatarSize" | "itemLeadingChip" | "itemLeadingChipSize" | "itemTrailing" | "itemTrailingIcon" | "itemWrapper" | "itemLabel" | "itemDescription">; }The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu.
| |
multiple | falseWhether multiple options can be selected or not. | |
id | string | |
placeholder | stringThe placeholder text when the select is empty. | |
selectedIcon | appConfig.pohon.icons.check | string | objectThe icon displayed when an item is selected. |
clear | false | false | false & Partial<Omit<PButtonProps, PLinkPropsKeys>>Display a clear button to reset the model value. Can be an object to pass additional props to the Button.
|
clearIcon | appConfig.pohon.icons.close | string | objectThe icon displayed in the clear button. |
arrow | false | boolean | AAutocompleteArrowPropsDisplay an arrow alongside the menu. |
portal | true | string | false | true | HTMLElementRender the menu in a portal.
|
virtualize | false | boolean | { overscan?: number; estimateSize?: number | ((index: number) => number); }Enable virtualization for large lists.
|
valueKey | undefined | undefinedWhen |
labelKey | 'label' | stringWhen |
descriptionKey | 'description' | stringWhen |
modelModifiers | Omit<ModelModifiers, "lazy"> | |
createItem | false | boolean | "always" | { position?: "top" | "bottom"; when?: "empty" | "always"; }Determines if custom user input that does not exist in options can be added.
|
filterFields | [labelKey] | string[]Fields to filter items by. |
autofocusDelay | number | |
searchInput | false | booleanWhether to display the search input or not.
Can be an object to pass additional props to the input.
|
defaultOpen | booleanThe open state of the combobox when it is initially rendered. | |
open | booleanThe controlled open state of the Combobox. Can be binded with | |
highlight | booleanHighlight the ring color like a focus state. | |
trailing | booleanWhen | |
loading | booleanWhen | |
required | boolean | |
autofocus | boolean | |
disabled | booleanWhen | |
leading | booleanWhen | |
resetSearchTermOnBlur | `true` | booleanWhether to reset the searchTerm when the Combobox input blurred |
resetSearchTermOnSelect | `true` | booleanWhether to reset the searchTerm when the Combobox value is selected |
resetModelValueOnClear | booleanWhen | |
highlightOnHover | booleanWhen | |
ignoreFilter | false | booleanWhen |
pohon | { root?: ClassValue; base?: ClassValue; leading?: ClassValue; leadingIcon?: ClassValue; leadingAvatar?: ClassValue; leadingAvatarSize?: ClassValue; trailing?: ClassValue; trailingIcon?: ClassValue; value?: ClassValue; placeholder?: ClassValue; arrow?: ClassValue; content?: ClassValue; viewport?: ClassValue; group?: ClassValue; empty?: ClassValue; label?: ClassValue; separator?: ClassValue; item?: ClassValue; itemLeadingIcon?: ClassValue; itemLeadingAvatar?: ClassValue; itemLeadingAvatarSize?: ClassValue; itemLeadingChip?: ClassValue; itemLeadingChipSize?: ClassValue; itemTrailing?: ClassValue; itemTrailingIcon?: ClassValue; itemWrapper?: ClassValue; itemLabel?: ClassValue; itemDescription?: ClassValue; input?: ClassValue; focusScope?: ClassValue; trailingClear?: ClassValue; } |