Skip to content

Select API

API reference docs for the Stash Select component. Learn about the props, CSS, and other APIs of this exported module.

Import

ts
import Select from '@leaflink/stash/Select.vue';

Props

NameTypeDefaultDescription
addBottomSpacebooleanfalsePassed to the addBottomSpace prop in the Field component; it adds spacing under the field that is consistent whether or not hint/error text is displayed.
allowEmptystring | boolean | nullnull
disableFilteringbooleanfalsePrevents the options from being filtered when the search term changes. Allows the parent to filter the options.
disabledbooleanfalseDisables the component, if true
displayBystring 'name' If `options` are an object, this is what prop to use for display.
enableTeleportbooleanfalseEnables teleporting the dropdown
errorstring ''
errorTextstring '' Error text that is displayed below the field.
hideCheckbooleanfalseHides the "check" icon if truthy
hideSearchbooleanfalseHides the search input
hintstring ''
hintTextstring '' Hint text that is displayed below the field.
iconstring | booleancaret-downSets a custom icon.
idstring ''
labelstring '' The label for the component.
lazyTSFunctionTypeundefinedLazily evaluate and set component `options`. Will execute upon user mouseover.
loadingbooleanfalseOn an ajaxed request when the dropdown is open, we may be experiencing slower load times. This flag will drop a loader into the dropdown. Note: This has never been design reviewed.
Placementbottom-startSets the placement of the dropdown
modelValueSelectedOptions() => []Sets the currently-selected value(s) for the component. Accepts an array of Objects, or a single Object (if `single` is true), or a string
namestringundefinedSets a name attribute on the native (hidden) select element Setting the default value to `undefined` so the attribute isn't rendered if not explicitly provided to ensure backwards compatibility with MP django forms
noTruncatebooleanfalsePrevents the Selected Option from being truncated, if true
onSearchTSFunctionTypeundefinedEquivalent to emitting a "search" event, except this prop can be used to populate the list of `options` using an HTTP request because a prop's return value can be received and awaited, unlike an event. **Tip:** to show a loading indicator while searching, return a Promise that resolves after the search is complete. **Warning:** the search input is debounced so there is no need to debounce this function.
optionsArray | TSTypeOperator() => []The list of all options to select from.
placeholderstring 'Select option' Placeholder text.
preserveSearchTermbooleanfalseIf true, prevents the search term from being cleared when the drawer is dismissed.
preventEmptybooleanfalseIf there is only 1 option selected, it prevents that option from being de-selected
searchByArray() => []List of one or more fields to search on. When empty, displayBy will be used
searchLoadingbooleanfalse
searchPlaceholderstring 'Search'
searchablestring | boolean | nullnull
selectItemTypestring '' In the selection text we use this to give more visual distinction to what type of item(s) are selected E.g. 2 customers selected. An empty string will result in `2 selected`.
showOptionalInLabelbooleanfalseRender "(optional)" to the right of the label text
singlebooleanfalseFunctions as a single select, if true
teleportTostring | HTMLElement`#${DEFAULT_MENUS_PLUGIN_NODE_ID}`The selector or element to which the dropdown should be teleported
trackBystring 'id' Default field to track selected options by.
useFuzzySearchbooleanfalseUses the "fuzzy search" algorithm when searching, if true
valueSelectedOptions | nullnull

Slots

NameDescription
selectedSelected value(s) custom text. Exposes the option object.
optionSelect custom option text. Exposes the option object.
no-optionsNo options text.
hint

Events

NameDescription
update:model-valueEmitted when the model value changes.
clearEmitted the selected value(s) a cleared.
addEmitted when an option is added.
removeEmitted when an option is removed.
openedEmitted when the select is opened.
closedEmitted when the select is closed.