The LocaleSelect component extends the SelectMenu component, so you can pass any property such as color, variant, size, etc.
Use the locales prop with an array of locales from @nuxt/ui/locale.
<script setup lang="ts">
import * as locales from '@nuxt/ui/locale'
const locale = ref('en')
</script>
<template>
<ULocaleSelect 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 '@nuxt/ui/locale'
const locale = ref('en')
</script>
<template>
<ULocaleSelect v-model="locale" :locales="[en, es, fr]" />
</template>
You can use it with Nuxt i18n:
<script setup lang="ts">
import * as locales from '@nuxt/ui/locale'
const { locale, setLocale } = useI18n()
</script>
<template>
<ULocaleSelect
v-model="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 '@nuxt/ui/locale'
const { locale, setLocale } = useI18n()
</script>
<template>
<ULocaleSelect
v-model="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
| Prop | Default | Type |
|---|---|---|
modelValue |
| |
locales |
| |
name |
The name of the field. Submitted with its owning form as part of a name/value pair. | |
avatar |
Display an avatar on the left side.
| |
size |
|
|
loading |
When | |
icon |
Display an icon based on the | |
color |
|
|
autofocus |
| |
disabled |
When | |
form |
| |
formaction |
| |
formenctype |
| |
formmethod |
| |
formnovalidate |
| |
formtarget |
| |
value |
| |
open |
The controlled open state of the Combobox. Can be binded with with | |
defaultOpen |
The open state of the combobox when it is initially rendered. | |
resetSearchTermOnBlur |
Whether to reset the searchTerm when the Combobox input blurred | |
resetSearchTermOnSelect |
|
Whether to reset the searchTerm when the Combobox value is selected |
highlightOnHover |
When | |
defaultValue |
The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu. | |
multiple |
Whether multiple options can be selected or not. | |
required |
| |
id |
| |
placeholder |
The placeholder text when the select is empty. | |
searchInput |
|
Whether to display the search input or not.
Can be an object to pass additional props to the input.
|
variant |
|
|
trailingIcon |
|
The icon displayed to open the menu. |
selectedIcon |
|
The icon displayed when an item is selected. |
content |
|
The content of the menu.
|
arrow |
|
Display an arrow alongside the menu. |
portal |
|
Render the menu in a portal. |
virtualize |
|
Enable 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 |
|
When |
labelKey |
| When |
descriptionKey |
|
When |
highlight |
Highlight the ring color like a focus state. | |
createItem |
|
Determines if custom user input that does not exist in options can be added.
|
filterFields |
|
Fields to filter items by. |
ignoreFilter |
|
When |
autofocusDelay |
| |
leading |
When | |
leadingIcon |
Display an icon on the left side. | |
trailing |
When | |
loadingIcon |
|
The icon when the |
ui |
|
5cb65 — feat: import @nuxt/ui-pro components