Skip to content

Select

Dropdown selector with keyboard navigation. The panel opens with ease-out animation, options support hover highlight and arrow key navigation.

Basic Usage

Value: null

vue
<script setup>
import { ref } from 'vue'
const value = ref(null)
const options = [
  { label: 'Apple', value: 'apple' },
  { label: 'Banana', value: 'banana' }
]
</script>

<template>
  <ASelect v-model="value" :options="options" placeholder="Choose a fruit" />
</template>

Clearable

Set clearable to show a clear button when a value is selected.

vue
<ASelect v-model="value" :options="options" clearable />

Disabled Item & Disabled Select

vue
<ASelect :options="options" disabled placeholder="Not selectable" />

Size

vue
<ASelect v-model="value" :options="options" size="sm" />
<ASelect v-model="value" :options="options" size="md" />
<ASelect v-model="value" :options="options" size="lg" />

API

Props

NameTypeDefaultDescription
modelValuestring | number | nullnullCurrently selected value
optionsSelectOption[][]Options array
placeholderstring'请选择'Placeholder when nothing selected
disabledbooleanfalseDisable entire select
clearablebooleanfalseShow clear button
size'sm' | 'md' | 'lg''md'Size

SelectOption

ts
interface SelectOption {
  label: string
  value: string | number
  disabled?: boolean
}

Emits

NameParametersDescription
update:modelValuevalueSelected value changed
change(value, option)Selection changed, returns full option object

Keyboard Interaction

KeyBehavior
Space / EnterOpen panel; confirm highlighted item when open
ArrowDown / ArrowUpMove highlight, skip disabled items
EscapeClose panel
TabClose panel and focus next element

Accessibility

  • Trigger uses native <button>, aria-haspopup="listbox" and aria-expanded reflect state
  • Panel uses role="listbox", options use role="option" with aria-selected
  • Disabled items exposed via aria-disabled
  • Auto-closes on outside click or Escape

MIT License