Usage
The LocaleSelect component extends the SelectMenu component, so you can pass any property such as color, size, etc.
Locales
Use the locales prop with an array of locales from @bitrix24/b24ui-nuxt/locale.
<script setup lang="ts">
import * as locales from '@bitrix24/b24ui-nuxt/locale'
const locale = ref('en')
</script>
<template>
<B24LocaleSelect 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, ru, tr, ar } from '@bitrix24/b24ui-nuxt/locale'
const locale = ref('en')
</script>
<template>
<B24LocaleSelect v-model="locale" :locales="[en, es, ru, tr, ar]" />
</template>
Dynamic locale
You can use it with Nuxt i18n:
<script setup lang="ts">
import * as locales from '@bitrix24/b24ui-nuxt/locale'
const { locale, setLocale } = useI18n()
</script>
<template>
<B24LocaleSelect
: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 { useI18n } from 'vue-i18n'
import * as locales from '@bitrix24/b24ui-nuxt/locale'
const { locale, setLocale } = useI18n()
</script>
<template>
<B24LocaleSelect
:model-value="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
modelValue | string | |
locales | Locale<any>[]
| |
name | stringThe name of the field. Submitted with its owning form as part of a name/value pair. | |
avatar | AvatarPropsDisplay an avatar on the left side.
| |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" | "xss" |
loading | boolean When | |
icon | IconComponentDisplay an icon on the left side. | |
trailingIcon | icons.chevronDown | IconComponentThe icon displayed to open the menu. |
color | 'air-primary' | "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" |
autofocus | boolean | |
disabled | boolean When | |
open | boolean The controlled open state of the Combobox. Can be binded 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 |
resetSearchTermOnSelect | `true` | boolean Whether to reset the searchTerm when the Combobox value is selected |
resetModelValueOnClear | boolean When | |
highlightOnHover | boolean When | |
by | string | (a: Locale<any>[], b: Locale<any>[]): booleanUse this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.
| |
defaultValue | stringThe 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. | |
required | false | boolean |
id | string | |
placeholder | stringThe placeholder text when the select is empty. | |
searchInput | false | boolean | InputProps<AcceptableValue, ModelModifiers> Whether to display the search input or not.
Can be an object to pass additional props to the input.
|
noPadding | false | boolean Removes padding from input |
noBorder | false | boolean Removes all borders (rings) |
underline | false | boolean Removes all borders (rings) except the bottom one |
rounded | false | boolean Rounds the corners of the select |
tag | string | |
tagColor | 'air-primary' | "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-tertiary" | "air-selection" |
selectedIcon | icons.check | IconComponentThe icon displayed when an item is selected. |
clear | false | false | false & Partial<Omit<ButtonProps, LinkPropsKeys>>Display a clear button to reset the model value. Can be an object to pass additional props to the Button.
|
clearIcon | icons.close | IconComponentThe icon displayed in the clear button. |
content | { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' } | ComboboxContentProps & Partial<EmitsToProps<DismissableLayerEmits>>The content of the menu.
|
arrow | false | boolean | ComboboxArrowProps 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. Note: when enabled, all groups are flattened into a single list due to a limitation of Reka UI (https://github.com/unovue/reka-ui/issues/1885).
|
valueKey | 'code' | "code"When |
labelKey | 'name' | "name" | "code" | "dir" | "locale" | "messages"When |
descriptionKey | 'description' | "name" | "code" | "dir" | "locale" | "messages"When |
modelModifiers | Omit<ModelModifiers, "lazy"> | |
highlight | boolean Highlight the ring color like a focus state. | |
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 |
autofocusDelay | number | |
trailing | boolean When | |
b24ui | { root?: ClassNameValue; base?: ClassNameValue; leading?: ClassNameValue; leadingIcon?: ClassNameValue; leadingAvatar?: ClassNameValue; leadingAvatarSize?: ClassNameValue; trailing?: ClassNameValue; trailingIcon?: ClassNameValue; tag?: ClassNameValue; value?: ClassNameValue; placeholder?: ClassNameValue; content?: ClassNameValue; viewport?: ClassNameValue; arrow?: ClassNameValue; group?: ClassNameValue; empty?: ClassNameValue; label?: ClassNameValue; separator?: ClassNameValue; item?: ClassNameValue; itemLeadingIcon?: ClassNameValue; itemLeadingAvatar?: ClassNameValue; itemLeadingAvatarSize?: ClassNameValue; itemLeadingChip?: ClassNameValue; itemLeadingChipSize?: ClassNameValue; itemTrailing?: ClassNameValue; itemTrailingIcon?: ClassNameValue; itemWrapper?: ClassNameValue; itemLabel?: ClassNameValue; itemDescription?: ClassNameValue; input?: ClassNameValue; focusScope?: ClassNameValue; trailingClear?: ClassNameValue; } |