Skip to content

VPick API

Every prop, slot, event, and method in one place. Each prop links to the page that explains it in context.

Props

modelValueany default undefined

Selected value. Use v-model for two-way binding. In Vue 2 the prop is value.

optionsOptionOrGroup[] required

Array of options or option groups.

Read more

placeholderstring default undefined

Text shown when no value is selected.

disabledboolean default false

Disables the control.

loadingboolean default false

Shows a spinner and disables interaction.

errorstring default undefined

Error message. Applies error styling and aria-invalid.

idstring default undefined

HTML id, applied to the control itself so a <label for> resolves to it.

Read more

namestring default undefined

HTML name for form submission.

Read more

requiredboolean default false

HTML required attribute.

ariaLabelstring default undefined

aria-label, for when there is no visible label.

ariaDescribedbystring default undefined

aria-describedby, for wiring up hint or error text.

labelKeystring | string[] default "label"

Key to read each option's visible label from. An array acts as a fallback chain: the first key with a non-empty value wins.

Read more

valueKeystring default "value"

Key to read each option's value from.

Read more

disabledKeystring default "disabled"

Key to read each option's disabled flag from.

Read more

groupOptionsKeystring default "options"

Key for the options array inside a group.

Read more

childrenKeystring default "children"

Key for nested children. Any option carrying that array turns tree mode on.

Read more

separatorsboolean default false

Draws a divider between adjacent groups in the list.

rotateIconboolean default false

Rotates the trigger chevron 180 degrees while open.

animateboolean default true

Animates the multiselect chips. false adds and removes them outright.

Read more

searchableboolean default false

Swaps the button trigger for an input with type-ahead filtering. No effect with multiple, which always uses that trigger.

Read more

filter(option, query) => boolean default undefined

Replaces the built-in matcher. Receives each option and the current query.

Read more

searchNestedboolean default false

In tree mode, lets a multi-word query match across a node's ancestor path.

Read more

clearableboolean default false

Shows a clear button once a value is selected.

Read more

clearOnSelectboolean default true

Clears the search query after picking an option.

Read more

closeOnSelectboolean default see description

Closes the list after picking. Defaults to true in single-select and false in multiple; an explicit value applies to both.

Read more

searchKeysstring | string[] default undefined

Extra fields on your option objects to search, alongside the label.

Read more

fetchOptions(query: string, context: { signal?: AbortSignal }) => unknown[] | Promise<unknown[]> default undefined

Answers what the user types with options, from a server or an in-browser search engine, instead of filtering options.

Read more

searchDebouncenumber default 300

Milliseconds to wait after the last keystroke before calling fetchOptions. 0 asks on every keystroke.

Read more

searchingTextstring default "Searching..."

Shown while fetchOptions is working on the typed query.

Read more

searchErrorTextstring default "Could not search. Click to retry"

Shown when fetchOptions rejects. Clicking it asks again.

Read more

searchPromptTextstring default "Type to search"

Shown with fetchOptions when nothing is typed and options is empty.

Read more

noResultsTextstring default "No results"

Shown when a search query matches nothing.

Read more

noOptionsTextstring default "No options available"

Shown when there are no options at all.

Read more

multipleboolean default false

Allows more than one selection. v-model becomes an array and the trigger draws chips.

Read more

backspaceRemovesboolean default true

Backspace on an empty search input removes the last chip.

Read more

deleteRemovesboolean default true

Same as backspaceRemoves, for the Delete key.

Read more

sortValueBy"ORDER_SELECTED" | "LEVEL" | "INDEX" default "ORDER_SELECTED"

Order of the emitted array and of the chips.

Read more

defaultExpandLevelnumber default undefined

Levels to pre-expand on open. 1 opens top-level branches, 2 opens two levels, and so on.

Read more

disableBranchNodesboolean default false

Makes branches unselectable, so only leaves can be picked. Clicking a branch row expands it instead.

Read more

cascadeboolean default true

In multiple tree mode, selecting a branch selects its descendants. false gives independent nodes.

Read more

valueConsistsOf"LEAF_PRIORITY" | "ALL" | "BRANCH_PRIORITY" | "ALL_WITH_INDETERMINATE" default "LEAF_PRIORITY"

Which nodes end up in v-model while cascade is active.

Read more

flattenSearchResultsboolean default false

Drops the ancestor rows and the indent from search results, leaving a flat list.

Read more

noChildrenTextstring default "No sub-options"

Shown under an expanded branch whose children array is empty.

Read more

loadChildren(option: unknown) => Promise<unknown[]> default undefined

Fetches a branch's children when it first opens. Mark those branches with children: null.

Read more

loadingChildrenTextstring default "Loading..."

Shown under a branch while its children load.

Read more

loadChildrenErrorTextstring default "Could not load. Click to retry"

Shown under a branch whose children failed to load. Clicking it retries.

Read more

teleportTostring | HTMLElement default auto-detected

Where the panel is rendered. Naming a target skips auto-detection; <body> is the fallback.

Read more

strategy"auto" | "absolute" | "fixed" default "auto"

How the panel is anchored once it is rendered.

Read more

hideWhenDetachedboolean default true

Hides the panel while its trigger is scrolled out of view.

Read more

bodyLockboolean default see description

Locks scrolling while open. Unset, defaults to true in button mode and false in searchable mode.

Read more

alwaysOpenboolean default false

Renders the list inline in the page rather than as a dropdown. It cannot be closed.

Read more

valueFormat"id" | "object" default "id"

Whether v-model holds plain values or your original option objects.

Read more

Slots

SlotScopeDescription
iconnoneCustom chevron icon. Shown when not loading.
loadingnoneCustom loading indicator. Shown when loading is true.
clearnoneCustom clear button content. Shown when clearable and a value is selected.
empty{ query: string }Custom empty state, for no options at all or a search that matches nothing.
no-children{ option: OptionItem }Custom content for an expanded branch whose children array is empty. Defaults to noChildrenText.
no-children-icon{ option: OptionItem }Icon for that same row, rendered on the column the leaf checkboxes use.
value-label{ option: OptionItem }Custom label for the selected value: the trigger label in single mode, each chip in multiple mode.
option-label{ option: OptionItem, isBranch: boolean, isExpanded: boolean, depth: number }Custom label for each row in the list. The chevron, checkbox and check icon stay put.

Usage for each is on the Slots page.

Events

EventPayloadDescription
update:modelValueanyEmitted when the selection changes. Vue 2 emits input, which is what v-model listens for there.
searchstringEmitted on every keystroke in searchable mode.
selectobjectEmitted when an option is picked. Payload is your original option object.
deselectobjectEmitted when an option is unpicked in multiple mode. Same payload as select.
opennoneEmitted when the list opens. An alwaysOpen list starts open, so it does not emit this on mount.
closenoneEmitted when the list closes, whether by Escape, an outside click, a pick, or becoming disabled.

select and deselect hand back the exact object you passed in options. See when deselect fires for the two cases that are not obvious.

Methods

Reach these through a template ref.

MethodDescription
focus()Moves focus to the control. In searchable and multiple mode the list opens, the same as tabbing into it.
vue
<script setup>
import { ref } from "vue"

const pick = ref()
</script>

<template>
  <VPick ref="pick" :options="options" />
  <button @click="pick.focus()">Edit</button>
</template>

CSS custom properties

Theming is documented separately, since the variables are shared with VPickNative. See Theming.

Types

ts
interface OptionItem {
  label: string
  value: any
  disabled?: boolean
  // An array, even an empty one, marks this node as a branch.
  children?: OptionItem[]
  // Set by Vue Pick, not by you: the original object you passed in.
  // Handed back by `select`/`deselect` and available in slots.
  raw?: unknown
}

interface OptionGroup {
  label: string
  disabled?: boolean
  options: OptionItem[]
}

type OptionOrGroup = OptionItem | OptionGroup

See the Data Shape guide for reading your own shapes without transforming them.

Released under the MIT License.