Basic Select
Build a single-select component from simple string options to a full-featured clearable select with object data.
String Options
The simplest possible select: an array of strings bound with v-model.
API Setup (String Options)
<script setup>
import { ref } from 'vue'
import {
SelectRoot,
SelectControl,
SelectInput,
SelectContent,
SelectOption,
} from 'vue-superselect'
const selected = ref(null)
const fruits = ['Apple', 'Banana', 'Cherry', 'Orange']
</script>Minimal Pattern
<SelectRoot v-model="selected">
<SelectControl>
<SelectInput placeholder="Pick a fruit..." />
</SelectControl>
<SelectContent>
<SelectOption
v-for="fruit in fruits"
:key="fruit"
:value="fruit"
:label="fruit"
>
{{ fruit }}
</SelectOption>
</SelectContent>
</SelectRoot>For string options, :value and :label are the same string. The label prop is used for filtering. When a user types in the input, options are matched against their label.
Need the full setup/import boilerplate? See Quick Start.
Object Options
When your options are objects, use label-key and value-key on SelectRoot to tell the component which fields to use.
How Object Binding Works
<SelectRoot
v-model="selected"
:items="countries"
label-key="name"
value-key="code"
>| Prop | Purpose |
|---|---|
:items | The full array of option objects. Used for label resolution when the dropdown is closed. |
label-key | Which field to display and filter by (e.g. "name") |
value-key | Which field becomes the v-model value (e.g. "code") |
With value-key="code", the v-model value will be "au", "br", etc., not the full object.
Each SelectOption still receives the individual :value and :label:
<SelectOption
v-for="country in countries"
:key="country.code"
:value="country.code"
:label="country.name"
>
{{ country.name }}
</SelectOption>Clearable with Trigger and Empty State
Add a clear button, a dropdown toggle trigger, and a "no results" message for a complete select experience.
Additional Components
| Component | Purpose |
|---|---|
SelectClear | Button that resets the value to null. Renders as <button> by default. |
SelectTrigger | Button that toggles the dropdown open/closed. |
SelectEmpty | Shown when filtering produces zero visible options. |
<SelectControl>
<SelectInput />
<SelectClear v-if="selected">x</SelectClear>
<SelectTrigger>
<!-- chevron icon -->
</SelectTrigger>
</SelectControl>SelectClear is conditionally rendered with v-if. Show it only when there's a value to clear.
SelectEmpty goes inside SelectContent:
<SelectContent>
<SelectOption v-for="..." />
<SelectEmpty>No results found</SelectEmpty>
</SelectContent>Scoped Slot Props
Every SelectOption exposes scoped slot props for conditional styling:
<SelectOption v-slot="{ selected, active, disabled, option }">
{{ option }}
</SelectOption>| Prop | Type | Description |
|---|---|---|
selected | boolean | Whether this option is currently selected |
active | boolean | Whether this option is keyboard-highlighted |
disabled | boolean | Whether this option is disabled |
option | unknown | The raw value passed to :value |