creatable adds a last row offering to create the typed text when no option or chosen value has that label. Choosing it adds the text to v-model and emits create, where you can add the matching option. With nothing to show, the list stays hidden, so :options="[]" gives a free tags input.
vue
Vue
Type a new tag and press Enter to create it
<script setup lang="ts">
import { ref } from 'vue'
import { VCombobox, type ComboboxOption } from 'vectis-ui'
const tags = ref(['vue'])
const suggestions = ref<ComboboxOption[]>([
{ value: 'vue', label: 'Vue' },
{ value: 'nuxt', label: 'Nuxt' },
{ value: 'vite', label: 'Vite' },
])
function addSuggestion(text: string) {
suggestions.value.push({ value: text, label: text })
}
</script>
<template>
<div class="column">
<VCombobox
v-model="tags"
:options="suggestions"
multiple
creatable
label="Tags"
hint="Type a new tag and press Enter to create it"
placeholder="Add a tag"
@create="addSuggestion"
/>
<output class="value" aria-label="Chosen values">{{ tags.join(', ') || 'none' }}</output>
</div>
</template>
<style scoped>
.column {
display: grid;
gap: var(--vectis-space-3);
max-inline-size: 26rem;
}
.value {
font-family: var(--vectis-text-family-code);
font-size: var(--vectis-text-body-sm-size);
color: var(--vectis-color-text-muted);
}
</style>
Values as text
display="text" joins selected labels on one line. Deselect options in the list, or remove the last value with Backspace when the search is empty.
vue
France, Belgium, Switzerland, Luxembourg
One line of labels, cut short when it runs out of room
<script setup lang="ts">
import { ref } from 'vue'
import { VCombobox } from 'vectis-ui'
const served = ref(['fr', 'be', 'ch', 'lu'])
const countries = [
{ value: 'be', label: 'Belgium' },
{ value: 'ca', label: 'Canada' },
{ value: 'ci', label: "Côte d'Ivoire" },
{ value: 'fr', label: 'France' },
{ value: 'lu', label: 'Luxembourg' },
{ value: 'mc', label: 'Monaco', disabled: true },
{ value: 're', label: 'Réunion' },
{ value: 'ch', label: 'Switzerland' },
]
</script>
<template>
<div class="column">
<VCombobox
v-model="served"
:options="countries"
multiple
display="text"
clearable
label="Served countries"
hint="One line of labels, cut short when it runs out of room"
placeholder="Add a country"
/>
</div>
</template>
<style scoped>
.column {
max-inline-size: 20rem;
}
</style>
Visible selection limit
max limits visible values while the field is unfocused. Focus reveals all values. Customize the hidden count with overflowText or #overflow.
vue
FranceBelgium+3
Two chips, the rest counted until the field is focused
Set :filter="false" for server-filtered options. searchDebounce delays search events.
vue
The list is narrowed by the source, so local filtering is turned off
No reference matches
<script setup lang="ts">
import { ref } from 'vue'
import { VCombobox, type ComboboxOption } from 'vectis-ui'
const CATALOGUE: ComboboxOption[] = Array.from({ length: 120 }, (_, i) => ({
value: `ref-${i + 1}`,
label: `Reference ${String(i + 1).padStart(3, '0')}`,
}))
function fetchReferences(query: string): Promise<ComboboxOption[]> {
const found = CATALOGUE.filter((option) =>
option.label.toLowerCase().includes(query.toLowerCase()),
)
return new Promise((resolve) => setTimeout(() => resolve(found.slice(0, 20)), 400))
}
const reference = ref('')
const options = ref<ComboboxOption[]>([])
const loading = ref(false)
/* Ignore stale responses when a newer query has started. */
let latest = 0
async function onSearch(query: string) {
const current = ++latest
loading.value = true
const found = await fetchReferences(query)
if (current !== latest) return
options.value = found
loading.value = false
}
</script>
<template>
<div class="column">
<VCombobox
v-model="reference"
:options="options"
:loading="loading"
:filter="false"
label="Reference"
hint="The list is narrowed by the source, so local filtering is turned off"
placeholder="Search for a reference"
empty-text="No reference matches"
clearable
@search="onSearch"
/>
</div>
</template>
<style scoped>
.column {
max-inline-size: 26rem;
}
</style>
Infinite scroll
hasMore enables load-more when the list end becomes visible. Append the next page to options.
vue
Scroll to the foot of the list: the next page is asked for as the end comes into view
No results
<script setup lang="ts">
import { computed, ref } from 'vue'
import { VCombobox, type ComboboxOption } from 'vectis-ui'
const PAGE_SIZE = 20
const CATALOGUE: ComboboxOption[] = Array.from({ length: 120 }, (_, i) => ({
value: `ref-${i + 1}`,
label: `Reference ${String(i + 1).padStart(3, '0')}`,
}))
function fetchPage(query: string, page: number) {
const found = CATALOGUE.filter((option) =>
option.label.toLowerCase().includes(query.toLowerCase()),
)
return new Promise<{ items: ComboboxOption[]; total: number }>((resolve) =>
setTimeout(
() =>
resolve({
items: found.slice(page * PAGE_SIZE, (page + 1) * PAGE_SIZE),
total: found.length,
}),
400,
),
)
}
const reference = ref('')
const options = ref<ComboboxOption[]>([])
const loading = ref(false)
const total = ref(0)
const page = ref(0)
const query = ref('')
const hasMore = computed(() => options.value.length < total.value)
async function onSearch(term: string) {
query.value = term
page.value = 0
loading.value = true
const result = await fetchPage(term, 0)
options.value = result.items
total.value = result.total
loading.value = false
}
/* Append results before allowing the sentinel to request another page. */
async function onLoadMore() {
loading.value = true
const result = await fetchPage(query.value, page.value + 1)
page.value += 1
options.value = [...options.value, ...result.items]
loading.value = false
}
</script>
<template>
<div class="column">
<VCombobox
v-model="reference"
:options="options"
:loading="loading"
:has-more="hasMore"
:filter="false"
label="Reference"
hint="Scroll to the foot of the list: the next page is asked for as the end comes into view"
placeholder="Search for a reference"
@search="onSearch"
@load-more="onLoadMore"
/>
<output class="count" aria-label="Options loaded"
>{{ options.length }} loaded of {{ total }}</output
>
</div>
</template>
<style scoped>
.column {
display: grid;
gap: var(--vectis-space-3);
max-inline-size: 26rem;
}
.count {
font-family: var(--vectis-text-family-code);
font-size: var(--vectis-text-body-sm-size);
color: var(--vectis-color-text-muted);
}
</style>
Long lists
virtual renders only the options near the visible part of the panel, for lists of thousands. Rows are measured as they render, so a custom #option may vary in height.
Built-in accent-insensitive filtering, disabled filtering, or a custom function receiving the option and trimmed query.
creatable
boolean
false
Offers to create the typed text as a new value when it matches no option or chosen value. The list stays hidden instead of showing an empty state, and the chevron is removed while there are no options.
searchDebounce
number
250
Delay in milliseconds before emitting a typed search. Zero emits immediately.
loading
boolean
false
Shows a field spinner and a panel loading state: full panel with no options, or list footer with existing options.
loadingText
string
none
Loading text announced to screen readers. Keep it consistent with custom #loading content.
hasMore
boolean
false
Enables requests for another page when the list end becomes visible.
virtual
boolean
false
Renders only the rows near the visible part of the panel, for lists of thousands. Options then carry their position in the list.