LocaleSelect

A Select to switch between locales.

Usage

The LocaleSelect component extends the SelectMenu component, so you can pass any property such as color, variant, size, etc.

This component is meant to be used with the i18n system. Learn more about it in the guide.
This component is meant to be used with the i18n system. Learn more about it in the guide.

Locales

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)" />
</template>

You can pass only the locales you need in your application:

<script setup lang="ts">
import { en, es, fr } from '@nuxt/ui/locale'
</script>

<template>
  <ULocaleSelect :locales="[en, es, fr]" />
</template>

Dynamic locale

You can use it with Nuxt i18n:

<script setup lang="ts">
import * as locales from '@nuxt/ui/locale'

const { locale } = useI18n()
</script>

<template>
  <ULocaleSelect v-model="locale" :locales="locales" />
</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 } = useI18n()
</script>

<template>
  <ULocaleSelect v-model="locale" :locales="locales" />
</template>

API

Props

Prop Default Type
modelValue

string

locales

Locale[]

content

{ side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }

ComboboxContentProps

The content of the menu.

disabled

boolean

When true, prevents the user from interacting with listbox

trailingIcon

appConfig.ui.icons.chevronDown

string

The icon displayed to open the menu.

size

"md" | "xs" | "sm" | "lg" | "xl"

color

"error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral"

variant

"outline" | "soft" | "subtle" | "ghost" | "none"

portal

true

boolean

Render the menu in a portal.

arrow

false

boolean | ComboboxArrowProps

Display an arrow alongside the menu.

selectedIcon

appConfig.ui.icons.check

string

The icon displayed when an item is selected.

ui

PartialString<{ base: string[]; leading: string; leadingIcon: string; leadingAvatar: string; leadingAvatarSize: string; trailing: string; trailingIcon: string; value: string; placeholder: string; arrow: string; ... 15 more ...; input: string; }>