Skip to content

Select

A dropdown select component with search and custom option rendering.

Basic Usage

Select...
vue
<script setup>
import { ref } from 'vue'

const value = ref(null)
const options = [
  { label: 'Option 1', value: '1' },
  { label: 'Option 2', value: '2' },
  { label: 'Option 3', value: '3' }
]
</script>

<template>
  <MSelect v-model="value" :options="options" placeholder="Select..." />
</template>

Filterable

Enable search functionality within the dropdown:

vue
<template>
  <MSelect 
    v-model="value" 
    :options="options" 
    filterable 
    placeholder="Search and select..."
  />
</template>

Disabled Options

vue
<script setup>
const options = [
  { label: 'Available', value: '1' },
  { label: 'Disabled', value: '2', disabled: true },
  { label: 'Available', value: '3' }
]
</script>

<template>
  <MSelect v-model="value" :options="options" />
</template>

Custom Keys

Use custom property names for value and label:

vue
<script setup>
const users = [
  { id: 1, name: 'John Doe' },
  { id: 2, name: 'Jane Smith' }
]
</script>

<template>
  <MSelect 
    v-model="userId" 
    :options="users" 
    value-key="id"
    label-key="name"
  />
</template>

Props

NameTypeDefaultDescription
modelValuestring | number | null-Binding value (v-model)
optionsOption[][]Array of options
valueKeystring'value'Property name for option value
labelKeystring'label'Property name for option label
placeholderstring'请选择'Placeholder text
disabledbooleanfalseWhether the select is disabled
filterablebooleanfalseEnable search functionality
errorbooleanfalseError state styling

Events

NameParametersDescription
update:modelValue(value: string | number | null)Triggered when selection changes
change(value, option)Triggered when selection changes with full option object

Slots

NameScopeDescription
option{ option }Custom option content

Released under the MIT License.