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
| Prop | Type | Default | Description |
|---|---|---|---|
modelValue | AcceptableValue | AcceptableValue[] | — | Selected value (an array when multiple). |
options | unknown[] | — | The choices. Objects by default (see optionLabel/optionValue), or primitives. |
optionLabel | string | 'label' | Object key to read each option's label from. |
optionValue | string | 'value' | Object key to read each option's value from. |
placeholder | string | — | Placeholder for the search input. |
searchPlaceholder | string | — | Overrides placeholder; wins when both are set. |
emptyLabel | string | 'No results' | Message shown when filtering yields nothing. |
multiple | boolean | false | Collect several values, rendered as removable tags. |
disabled | boolean | false | Disables the control. |
clearable | boolean | false | Shows a button that clears the selection. |
invalid | boolean | false | Marks the control invalid. Falls through to the FormField context when omitted. |
required | boolean | false | Marks the control required. Falls through to the FormField context when omitted. |
size | 'sm' | 'default' | 'default' | Control size. |
id | string | — | Applied to the search input so an external <label for> matches. |
name | string | — | Submitted with the owning form as a name/value pair. |
Events
| Event | Payload | Description |
|---|---|---|
update:modelValue | unknown | Emitted 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"witharia-expanded,aria-controls, andaria-autocomplete="list", and gives the popuprole="listbox"withrole="option"items. Arrow keys move the highlight, Enter selects, and Esc closes. - Provide an accessible name with a
FormFieldlabel (its<label for>points at the input'sid) or anaria-label. - Inside a
FormFieldthe input picks upid,aria-describedby,aria-invalid, andaria-requiredthrough the shareduseFieldControlcomposable.
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 usesbg-surfacesurfaces and the sharedfocus-withinring. - Layout is direction-safe: the anchor is a flex row with logical
gap, the item indicator is positioned withend-2, and the selected tags flow with logical spacing, so everything mirrors underdir="rtl".
