NbSelect is a custom dropdown that replaces the native <select>. It shares the same design language as NbTextInput: two variants (default / fluid), error/warning states, multi-select support, and full keyboard navigation.
<template>
<NbSelect
v-model="locale"
label="Locale"
:options="[
{ label: 'English', value: 'en' },
{ label: 'Portuguese', value: 'pt' },
{ label: 'Spanish', value: 'es' },
]"
/>
</template>Variants
Default
The label sits above the field. Helper/error/warning messages appear below.
Fluid
The label is rendered inside the field at the top. Useful in dense forms or inline editors.
<template>
<NbSelect
v-model="value"
variant="fluid"
label="Status"
:options="statusOptions"
/>
</template>Validation states
Disabled
Multi-select
Set :multiple="true" and bind to an array. The trigger displays the item label when 1 is selected, a comma-separated list for 2, and N selected for 3 or more.
<template>
<NbSelect
v-model="selected"
label="Target locales"
:options="localeOptions"
:multiple="true"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const selected = ref<string[]>([])
</script>Creatable
Set :creatable="true" to show a text input at the bottom of the dropdown. When the user types a value and presses Enter, the create event fires with the entered string. You can then add it to your options array.
<template>
<NbSelect
v-model="locale"
label="Locale"
:options="options"
creatable
create-placeholder="New locale..."
@create="onCreate"
/>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const locale = ref('en')
const options = ref([
{ label: 'English', value: 'en' },
{ label: 'Portuguese', value: 'pt' },
])
function onCreate(value: string) {
options.value.push({ label: value, value: value.toLowerCase() })
}
</script>