Skip to content

Combobox ​

Combobox is a searchable select built on reka-ui. Type to filter the options, then pick one (or several); the input carries role="combobox" and the standard aria-expanded / aria-controls / aria-autocomplete wiring. Reach for it when a list is too long to scan — for short lists use Select, and for a tree use TreeSelect.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { Combobox } from '@myghf/ui'

const unit = ref('')
const options = [
  { label: 'Cardiology', value: 'cardio' },
  { label: 'Neurology', value: 'neuro' },
]
</script>

<template>
  <Combobox v-model="unit" :options="options" placeholder="Search units…" />
</template>

Examples ​

Single and multiple, with clear ​

Single-select shows the chosen label in the input and resets the search on select. Set multiple to collect several values as removable Tags; clearable adds a button that clears the whole selection.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { Combobox } from '@myghf/ui'

const unit = ref('cardio')
const units = ref(['sepsis'])

const options = [
  { label: 'Cardiology', value: 'cardio' },
  { label: 'Neurology', value: 'neuro' },
  { label: 'Oncology', value: 'onco' },
  { label: 'Paediatrics', value: 'paeds' },
  { label: 'Radiology', value: 'radio' },
]
</script>

<template>
  <div class="grid max-w-md gap-5">
    <Combobox v-model="unit" :options="options" placeholder="Search units…" clearable />
    <Combobox v-model="units" multiple :options="options" placeholder="Add a unit…" />
  </div>
</template>

Props ​

PropTypeDefaultDescription
modelValueAcceptableValue | AcceptableValue[]—Selected value (an array when multiple).
optionsunknown[]—The choices. Objects by default (see optionLabel/optionValue), or primitives.
optionLabelstring'label'Object key to read each option's label from.
optionValuestring'value'Object key to read each option's value from.
placeholderstring—Placeholder for the search input.
searchPlaceholderstring—Overrides placeholder; wins when both are set.
emptyLabelstring'No results'Message shown when filtering yields nothing.
multiplebooleanfalseCollect several values, rendered as removable tags.
disabledbooleanfalseDisables the control.
clearablebooleanfalseShows a button that clears the selection.
invalidbooleanfalseMarks the control invalid. Falls through to the FormField context when omitted.
requiredbooleanfalseMarks the control required. Falls through to the FormField context when omitted.
size'sm' | 'default''default'Control size.
idstring—Applied to the search input so an external <label for> matches.
namestring—Submitted with the owning form as a name/value pair.

Events ​

EventPayloadDescription
update:modelValueunknownEmitted with the new value (a single value, or an array when multiple).

Exposed methods ​

None. Combobox does not call defineExpose.

Accessibility ​

  • reka-ui renders the search input as role="combobox" with aria-expanded, aria-controls, and aria-autocomplete="list", and gives the popup role="listbox" with role="option" items. Arrow keys move the highlight, Enter selects, and Esc closes.
  • Provide an accessible name with a FormField label (its <label for> points at the input's id) or an aria-label.
  • Inside a FormField the input picks up id, aria-describedby, aria-invalid, and aria-required through the shared useFieldControl composable.

Dark mode & RTL ​

  • The anchor, popup, and items style from semantic tokens (bg-surface, border-border, bg-surface-muted), so they adapt to dark mode automatically. The focus ring uses bg-surface surfaces and the shared focus-within ring.
  • Layout is direction-safe: the anchor is a flex row with logical gap, the item indicator is positioned with end-2, and the selected tags flow with logical spacing, so everything mirrors under dir="rtl".

Released under the MIT License.