LocaleSelect
Usage
The LocaleSelect component extends the SelectMenu component, so you can pass any property such as color, variant, size, etc.
Locales
Use the locales prop with an array of locales from pohon-ui/locale.
<script setup lang="ts">
import * as locales from 'pohon-ui/locale';
import { ref } from 'vue';
const locale = ref('en');
</script>
<template>
<PLocaleSelect
v-model="locale"
:locales="Object.values(locales)"
class="w-48"
/>
</template>
You can pass only the locales you need in your application:
<script setup lang="ts">
import { en, es, fr } from 'pohon-ui/locale';
const locale = ref('en');
</script>
<template>
<PLocaleSelect
v-model="locale"
:locales="[en, es, fr]"
/>
</template>
Dynamic locale
You can use it with Nuxt i18n:
<script setup lang="ts">
import * as locales from 'pohon-ui/locale';
const { locale, setLocale } = useI18n();
</script>
<template>
<PLocaleSelect
:model-value="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
You can use it with Vue i18n:
<script setup lang="ts">
import * as locales from 'pohon-ui/locale';
import { useI18n } from 'vue-i18n';
const { locale, setLocale } = useI18n();
</script>
<template>
<PLocaleSelect
:model-value="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
modelValue* | string | |
locales | PLocale<any>[]
| |
autofocus | boolean | |
disabled | boolean When | |
name | stringThe name of the field. Submitted with its owning form as part of a name/value pair. | |
placeholder | stringThe placeholder text when the select is empty. | |
required | boolean | |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
id | string | |
color | 'primary' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
variant | 'outline' | "outline" | "soft" | "subtle" | "ghost" | "none" |
autofocusDelay | number | |
highlight | boolean Highlight the ring color like a focus state. | |
defaultValue | stringThe value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu. | |
modelModifiers | Omit<ModelModifiers<string>, "lazy"> | |
icon | string | objectDisplay an icon based on the | |
avatar | PAvatarPropsDisplay an avatar on the left side.
| |
leading | boolean When | |
leadingIcon | string | objectDisplay an icon on the left side. | |
trailing | boolean When | |
trailingIcon | appConfig.pohon.icons.chevronDown | string | objectThe icon displayed to open the menu. |
loading | boolean When | |
loadingIcon | appConfig.pohon.icons.loading | string | objectThe icon when the |
open | boolean The controlled open state of the Combobox. Can be binded with with | |
defaultOpen | boolean The open state of the combobox when it is initially rendered. | |
resetSearchTermOnBlur | `true` | boolean Whether to reset the searchTerm when the Combobox input blurred |
resetModelValueOnClear | boolean When | |
resetSearchTermOnSelect | `true` | boolean Whether to reset the searchTerm when the Combobox value is selected |
highlightOnHover | boolean When | |
multiple | falseWhether multiple options can be selected or not. | |
searchInput | true | boolean | PInputProps<AcceptableValue> Whether to display the search input or not.
Can be an object to pass additional props to the input.
|
selectedIcon | appConfig.pohon.icons.check | string | objectThe icon displayed when an item is selected. |
clear | false | boolean | 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. |
content | { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' } | AComboboxContentProps & Partial<EmitsToProps<DismissableLayerEmits>>The content of the menu.
|
arrow | false | boolean | AComboboxArrowProps Display 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) | undefined; } | undefinedEnable virtualization for large lists.
|
valueKey | 'code' | "code"When |
labelKey | 'name' | "name" | "code" | "dir" | "messages" | `messages.${string}`When |
descriptionKey | 'description' | "name" | "code" | "dir" | "messages" | `messages.${string}`When |
createItem | false | boolean | "always" | { position?: "top" | "bottom" ; when?: "empty" | "always" | undefined; } | undefinedDetermines if custom user input that does not exist in options can be added.
|
filterFields | [labelKey] | string[]Fields to filter items by. |
ignoreFilter | false | boolean When |
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; } |