Skip to content

Select

Native select dropdown with support for various option formats and type parsing. Normalizes arrays, objects, and grouped options into a consistent format.

Shared option API

Accepts the shared option formats — primitive arrays, object arrays with extractors, key-value objects and groups. See Option Extractors.

Import

typescript
import { Select } from 'vuiii'

Basic Usage

vue
<Select v-model="color" :options="['Red', 'Green', 'Blue']" />

Props

PropTypeDefaultDescription
modelValueany-Selected value (use with v-model)
optionsany[] | Record<string, any>-Options to display (see Option Parsing)
optionLabelstring | ((item) => any)-Key or function to extract the display label
optionValuestring | ((item) => any)-Key or function to extract the option value
optionDisabledstring | ((item) => any)-Key or function to determine if option is disabled
groupLabelstring | ((item) => any)-Key or function to extract the group label
groupOptionsstring | ((item) => any)-Key or function to extract the group's options
valueParserValueParser<string>-Custom parser to serialize/deserialize the value
type'string' | 'number' | 'boolean' | 'date''string'Built-in value type parsing
placeholderstring-Placeholder option text
size'small' | 'normal' | 'large''normal'Select size
requiredbooleanfalseMarks the select as required
invalidbooleanfalseApplies the invalid/error styling
disabledbooleanfalseDisables the select
pillbooleanfalseRounded pill shape
inputClassany-Class applied to the nested <select> element

Events

The Select uses v-model and emits no custom events.

Object Options

Point option-value and option-label at the properties to use. placeholder adds a leading empty option, which is how you offer "nothing selected".

vue
<script setup>
const countries = [
  { code: 'us', name: 'United States' },
  { code: 'uk', name: 'United Kingdom' },
]
</script>

<template>
  <Select
    v-model="country"
    :options="countries"
    option-value="code"
    option-label="name"
    placeholder="Select a country"
  />
</template>

Key-Value Options

A plain object needs no extractors — keys become values, values become labels. Handy for enums.

vue
<script setup>
const statuses = { draft: 'Draft', published: 'Published', archived: 'Archived' }
</script>

<template>
  <Select v-model="status" :options="statuses" />
</template>

Grouped Options

group-label and group-options render native <optgroup> elements.

vue
<script setup>
const vehicles = [
  { category: 'Cars', items: [{ id: 1, name: 'Sedan' }, { id: 2, name: 'SUV' }] },
  { category: 'Bikes', items: [{ id: 3, name: 'Mountain' }, { id: 4, name: 'Road' }] },
]
</script>

<template>
  <Select
    v-model="vehicle"
    :options="vehicles"
    group-label="category"
    group-options="items"
    option-value="id"
    option-label="name"
  />
</template>

Typed Values

A native select always reports a string. type parses the value back, so the model keeps the type your options actually had.

vue
<!-- quantity is a number, not '2' -->
<Select v-model="quantity" :options="[1, 2, 3, 4, 5]" type="number" />

Sizes and Validation State

vue
<Select v-model="color" :options="colors" size="small" />
<Select v-model="color" :options="colors" :invalid="!!errors.color" />
<Select v-model="color" :options="colors" disabled />

Storybook

For interactive examples with all variants, see Select in Storybook.

Released under the MIT License.