Skip to content

Components API

vue-superselect provides a set of compound components that compose together via provide/inject. Each component is headless -- it renders no styles and gives you full control over markup and styling.

For a renderless alternative, see the Composable API.

Complete Example

SelectRoot

The root provider component. Wraps all other Select components and manages state via provide/inject. Renders no DOM element -- only its default slot.

Props

PropTypeDefaultDescription
modelValueT | T[] | nullundefinedControlled selected value. Use with v-model.
defaultValueT | T[] | nullnullInitial value for uncontrolled usage.
multiplebooleanfalseEnable multi-select mode. When true, modelValue must be an array.
disabledbooleanfalseDisables all interaction: input, trigger, clear, and option clicks.
itemsT[]undefinedRoot-level data source for option items. Alternative to using SelectOption children.
labelKeykeyof TundefinedWhich field on each item object to use as the display label.
valueKeykeyof TundefinedWhich field on each item object to use as the v-model value.
filterFilterFnundefinedCustom filter function. See FilterFn type below. Defaults to case-insensitive label matching.
debouncenumberundefinedDebounce delay in milliseconds for the filter function.
resolveLabel(value: T) => stringundefinedResolves a display label for a selected value when option components are not mounted.
selectOnTabbooleanfalseWhen true, pressing Tab selects the highlighted option before closing.
maxnumberundefinedMaximum number of selections in multi-select mode. Has no effect when multiple is false.
hideSelectedbooleanfalseHides already-selected options from the dropdown list in multi-select mode.
openbooleanundefinedControlled open state. Use with v-model:open for two-way binding.
defaultOpenbooleanfalseInitial open state for uncontrolled usage.
loopbooleantrueWhether keyboard navigation wraps around from last to first option and vice versa.
placeholderstringundefinedPlaceholder text displayed on the input when empty.
idstringauto-generatedCustom ID for the root element. Used as a base for ARIA IDs.

Events

EventPayloadDescription
update:modelValueT | T[] | nullEmitted when the selected value changes. Used by v-model.
update:openbooleanEmitted when the open state changes. Used by v-model:open.

Slots

SlotPropsDescription
default--Content to render. Must contain other Select components.

Exposed Methods

MethodSignatureDescription
open() => voidOpens the dropdown
close() => voidCloses the dropdown
toggle() => voidToggles the dropdown open/closed
clear() => voidClears the current selection and query
focus() => voidFocuses the input element

TypeScript Types

ts
type FilterFn<T> = (item: CollectionItem<T>, query: string) => boolean

interface CollectionItem<T> {
  id: string
  value: T
  label: string
  disabled: boolean
  element: HTMLElement | null
}

type SelectLabelResolver<T> = (value: T) => string | undefined

SelectControl

Visual wrapper around the input and tags. Serves as the positioning reference for the dropdown. Renders as a div by default.

Props

PropTypeDefaultDescription
asstring | Component'div'The element or component to render as.

Slots

SlotPropsDescription
default{ selectedItems, removeItem, multiple }Scoped slot providing selected items data for multi-select rendering.

Slot props detail:

PropTypeDescription
selectedItemsArray<{ value: T; label: string }>Selected items with resolved labels (multi-select only)
removeItem(value: T) => voidRemoves a specific item from the selection
multiplebooleanWhether multi-select mode is active

SelectInput

Search/filter input element. Renders as an input by default. Handles typing, keyboard navigation, and focus management.

Props

PropTypeDefaultDescription
asstring | Component'input'The element or component to render as.

Accessibility

Always provide an accessible label for the input. Use aria-label, aria-labelledby, or an associated <label> element. A dev-only warning is shown if no label is detected.


SelectContent

Dropdown listbox container. Only renders when the select is open. Renders as a ul by default. Integrates with @floating-ui/vue for smart positioning when available.

Props

PropTypeDefaultDescription
asstring | Component'ul'The element or component to render as.
placementstring'bottom-start'Preferred placement of the dropdown relative to the control.
collisionStrategyFloatingCollisionStrategy'flip'How to handle collisions with viewport edges. 'flip' moves to opposite side; 'none' disables collision handling.
forceAbsolutebooleanfalseDisables Floating UI and uses simple CSS absolute positioning instead.
teleportboolean | stringfalseTeleports the dropdown to a target element. true teleports to body; a string specifies a CSS selector.

Slots

SlotPropsDescription
default--Dropdown content. Typically contains SelectOption components.

TypeScript Types

ts
type FloatingCollisionStrategy = 'flip' | 'none'

Data Attributes

AttributeValuesDescription
data-side'top', 'bottom', 'left', 'right'Which side the dropdown is positioned on
data-align'start', 'center', 'end'Alignment within the chosen side

SelectOption

Individual option item within the dropdown. Self-registers with the collection and handles selection, highlighting, and visibility. Renders as a li by default.

Props

PropTypeDefaultDescription
valueT-- (required)The value of this option.
labelstringString(value)Display label for this option. Falls back to string conversion of value.
disabledbooleanfalseWhether this option is disabled and cannot be selected.
idstringauto-generatedCustom ID for this option element.
asstring | Component'li'The element or component to render as.

Slots

SlotPropsDescription
default{ selected, active, disabled, option }Custom option rendering. Falls back to label prop or String(value).

Slot props detail:

PropTypeDescription
selectedbooleanWhether this option is currently selected
activebooleanWhether this option is currently highlighted (via keyboard or mouse)
disabledbooleanWhether this option is disabled
optionTThe raw value of this option

Data Attributes

AttributeValuesDescription
data-selected'true', 'false'Whether the option is selected
data-highlighted'true', 'false'Whether the option is highlighted
data-disabled'true', 'false'Whether the option is disabled

SelectTag

Multi-select tag/chip for displaying selected items. Provides a built-in remove button and emits a remove event. Renders as a span by default.

Props

PropTypeDefaultDescription
valueT-- (required)The value this tag represents.
labelstring-- (required)Display text for the tag.
disabledbooleanfalseWhen true, the remove button is disabled.
asstring | Component'span'The element or component to render as.

Events

EventPayloadDescription
removeTEmitted when the remove button is clicked. Payload is the tag value.

Slots

SlotPropsDescription
default{ value, label, disabled, remove }Custom tag rendering. Defaults to label text and a remove button.

Slot props detail:

PropTypeDescription
valueTThe raw value of this tag
labelstringThe display label
disabledbooleanWhether the tag is disabled
remove(event: Event) => voidCall to remove this tag

Data Attributes

AttributeValuesDescription
data-part'tag'Identifies the tag element
data-disabled'true', undefinedPresent when the tag is disabled

SelectTrigger

Toggle button that opens/closes the dropdown. Renders as a button by default. Automatically sets aria-expanded and aria-controls.

Props

PropTypeDefaultDescription
asstring | Component'button'The element or component to render as.

Slots

SlotPropsDescription
default--Button content. Typically a chevron icon or toggle indicator.

SelectClear

Clear button that resets the selection and query. Renders as a button by default. Automatically disabled when the select is disabled.

Props

PropTypeDefaultDescription
asstring | Component'button'The element or component to render as.

Slots

SlotPropsDescription
default--Button content. Typically an "x" icon.

SelectEmpty

Conditional empty state that only renders when no options match the current filter query. Renders as a div by default.

Props

PropTypeDefaultDescription
asstring | Component'div'The element or component to render as.

Slots

SlotPropsDescription
default--Custom empty state content. Defaults to "No results".

SelectLiveRegion

Screen reader live region that announces selection changes, dropdown state, and result counts. Renders a visually hidden div with aria-live="polite".

Props

PropTypeDefaultDescription
messagesPartial<SelectMessages>defaultSelectMessagesCustom message functions for screen reader announcements.

TypeScript Types

ts
interface SelectMessages {
  /** Announced when the dropdown opens */
  listExpanded: () => string
  /** Announced when the dropdown closes */
  listCollapsed: () => string
  /** Announced when the filtered result count changes */
  resultsCount: (count: number) => string
  /** Announced when an item is added in multi-select */
  itemAdded: (label: string) => string
  /** Announced when an item is removed in multi-select */
  itemRemoved: (label: string) => string
}

Default messages:

MessageDefault
listExpanded"List expanded"
listCollapsed"List collapsed"
resultsCount"3 results" (pluralized)
itemAdded"Added Apple"
itemRemoved"Removed Apple"

Primitive as Prop

All components accept an as prop that controls the rendered element. This enables rendering as custom components or different HTML elements:

vue
<!-- Render SelectContent as an <ol> instead of <ul> -->
<SelectContent as="ol">
  <SelectOption as="li" ... />
</SelectContent>

<!-- Render SelectControl as a custom component -->
<SelectControl :as="MyCustomWrapper">
  ...
</SelectControl>