Localidad Select
xph0000xUso
El componente LocaleSelect extiende el componente SelectMenu, de modo que puede pasar cualquier propiedad como color, variant, size, etc.
Locales
Utilice el prop locales con una matriz de locales de @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>
<script setup lang="ts">
import { ref } from 'vue'
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>
Puede pasar solo las localidades que necesita en su solicitud:
<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>
Localización dinámica
Puedes usarlo con Nuxt i18n:
<script setup lang="ts">
import * as locales from '@nuxt/ui/locale'
const { locale, setLocale } = useI18n()
</script>
<template>
<ULocaleSelect
:model-value="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
Puedes usarlo con 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
:model-value="locale"
:locales="Object.values(locales)"
@update:model-value="setLocale($event)"
/>
</template>
API (Edición española)
Accesorios
| 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" |
loading | boolean When | |
icon | anyDisplay an icon based on the | |
color | 'primary' | "error" | "neutral" | "primary" | "secondary" | "success" | "info" | "warning" |
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 | boolean | |
id | string | |
placeholder | stringThe placeholder text when the select is empty. | |
searchInput | false | boolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue"> Whether to display the search input or not.
Can be an object to pass additional props to the input.
|
variant | 'outline' | "outline" | "soft" | "subtle" | "ghost" | "none" |
trailingIcon | appConfig.ui.icons.chevronDown | anyThe icon displayed to open the menu. |
selectedIcon | appConfig.ui.icons.check | anyThe 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 | appConfig.ui.icons.close | anyThe 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" | "messages"When |
descriptionKey | 'description' | "name" | "code" | "dir" | "messages"When |
modelModifiers | Omit<ModelModifiers, "lazy"> | |
highlight | boolean Highlight the ring color like a focus state. | |
fixed | boolean Keep the mobile text size on all breakpoints. | |
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 | |
leading | boolean When | |
leadingIcon | anyDisplay an icon on the left side. | |
trailing | boolean When | |
loadingIcon | appConfig.ui.icons.loading | anyThe icon when the |
ui | { base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; value?: SlotClass; placeholder?: SlotClass; arrow?: SlotClass; content?: SlotClass; viewport?: SlotClass; group?: SlotClass; empty?: SlotClass; label?: SlotClass; separator?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemDescription?: SlotClass; input?: SlotClass; focusScope?: SlotClass; trailingClear?: SlotClass; } |