ColorModeSelect

A Select to switch between system, dark & light mode.

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:

app.config.ts
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:

vite.config.ts
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
trailingIconappConfig.pohon.icons.chevronDownstring | object

The icon displayed to open the menu.

color'primary'"primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral"
namestring

The 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"
avatarPAvatarProps

Display an avatar on the left side.

variant'outline'"ghost" | "outline" | "soft" | "subtle" | "none"
leadingIconstring | object

Display an icon on the left side.

loadingIconappConfig.pohon.icons.loadingstring | object

The icon when the loading prop is true.

bystring | (a: PSelectMenuItem[], b: PSelectMenuItem[]): boolean

Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.

defaultValuestring | 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.

multiplefalse

Whether multiple options can be selected or not.

idstring
placeholderstring

The placeholder text when the select is empty.

selectedIconappConfig.pohon.icons.checkstring | object

The icon displayed when an item is selected.

clearfalsefalse | 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.

clearIconappConfig.pohon.icons.closestring | object

The icon displayed in the clear button.

arrowfalseboolean | AAutocompleteArrowProps

Display an arrow alongside the menu.

portaltruestring | false | true | HTMLElement

Render the menu in a portal.

virtualizefalseboolean | { overscan?: number; estimateSize?: number | ((index: number) => number); }

Enable virtualization for large lists.

valueKeyundefinedundefined

When items is an array of objects, select the field to use as the value instead of the object itself.

labelKey'label'string

When items is an array of objects, select the field to use as the label.

descriptionKey'description'string

When items is an array of objects, select the field to use as the description.

modelModifiersOmit<ModelModifiers, "lazy">
createItemfalseboolean | "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.

autofocusDelaynumber
searchInputfalseboolean

Whether to display the search input or not. Can be an object to pass additional props to the input. { placeholder: 'Search...', variant: 'none' }

defaultOpenboolean

The open state of the combobox when it is initially rendered.
Use when you do not need to control its open state.

openboolean

The controlled open state of the Combobox. Can be binded with v-model:open.

highlightboolean

Highlight the ring color like a focus state.

trailingboolean

When true, the icon will be displayed on the right side.

loadingboolean

When true, the loading icon will be displayed.

requiredboolean
autofocusboolean
disabledboolean

When true, prevents the user from interacting with listbox

leadingboolean

When true, the icon will be displayed on the left side.

resetSearchTermOnBlur`true`boolean

Whether to reset the searchTerm when the Combobox input blurred

resetSearchTermOnSelect`true`boolean

Whether to reset the searchTerm when the Combobox value is selected

resetModelValueOnClearboolean

When true the modelValue will be reset to null (or [] if multiple)

highlightOnHoverboolean

When true, hover over item will trigger highlight

ignoreFilterfalseboolean

When true, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).

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; }

Changelog

No recent changes