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.

Import

typescript
import { Select } from 'vuiii'

Basic Usage

vue
// Basic usage with string array import { Select } from 'vuiii'

<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.

More Examples

vue
// With object array and extractors const countries = [ { code: 'us', name: 'United States' }, { code: 'uk', name:
'United Kingdom' } ]

<Select v-model="country" :options="countries" option-value="code" option-label="name" placeholder="Select a country" />
vue
// With key-value object options const statuses = { draft: 'Draft', published: 'Published', archived: 'Archived' }

<Select v-model="status" :options="statuses" />
vue
// With grouped options (optgroup) const vehicles = [ { category: 'Cars', items: [{ id: 1, name: 'Sedan' }, { id: 2,
name: 'SUV' }] }, { category: 'Bikes', items: [{ id: 3, name: 'Mountain' }, { id: 4, name: 'Road' }] } ]

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

Storybook

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

Released under the MIT License.