Select

Select component based on Headless UI Listbox. Support multiple selection.

Usage

Use <VSelect /> component to create select input.

View Code
<script setup lang="ts">
const items = ref([
  { value: 1, text: "Wade Cooper" },
  { value: 2, text: "Arlene Mccoy" },
  { value: 3, text: "Devon Webb" },
  { value: 4, text: "Tom Cook" },
  { value: 5, text: "Tanya Fox" },
  { value: 6, text: "Hellen Schmidt" },
]);

const selected = ref();
</script>

<template>
  <VSelect
    v-model="selected"
    placeholder="Choose..."
    :items="items"
  />
</template>

Multiple

Use multiple prop to enable multiple selection to the select component.

View Code
<script setup lang="ts">
const items = ref([
  { value: 1, text: "Wade Cooper" },
  { value: 2, text: "Arlene Mccoy" },
  { value: 3, text: "Devon Webb" },
  { value: 4, text: "Tom Cook" },
  { value: 5, text: "Tanya Fox" },
  { value: 6, text: "Hellen Schmidt" },
]);

const selected = ref();
</script>

<template>
  <VSelect
    v-model="selected"
    placeholder="Choose..."
    :items="items"
    multiple
  />
</template>

Props

PropertyTypeRequiredDefaultDescription
modelValueVSelectItemYes-The selected item in the dropdown list.
itemsVSelectItem[]Yes[]An array of VSelectItem objects to display in the dropdown list.
placeholderstringNo'Choose'The placeholder text to display when no item is selected.
hideCheckIconbooleanNofalseSpecifies whether to hide the check icon when an item is selected.
outlinedbooleanNofalseSpecifies whether the dropdown list should be displayed with an outlined border.
largebooleanNofalseSpecifies whether the dropdown list should be displayed with a large size.
smallbooleanNofalseSpecifies whether the dropdown list should be displayed with a small size.

Events

NamePayloadDescription
update:modelValue{value: VSelectItem}Triggered when modelValue prop changed

Types

export type VSelectItem = {
  text: string;
  value: string | number;
  divider?: boolean;
};