Dropdown select
Displays a dropdown list for selecting a single option or multiple option, commonly used in filtering or configuration panels. For form usage, prefer the SelectField component instead.
Component
Props
| Props | Default | Type |
|---|---|---|
id | — | string |
options | An example array | SelectOption[] |
placeholder | Select an option | string |
type | SelectType.TEXT | SelectType |
size | SelectSize.MD | SelectSize |
activeStyle | SelectActiveStyle.CHECK | SelectActiveStyle |
modelValue | — | string | number | (string | number)[] | null |
dropdownPosition | DropdownPosition.BOTTOM | DropdownPosition |
selectBoxClass | — | string |
filterable | false | boolean |
searchFieldPlaceholder | Search... | string |
noResultsFoundText | No results found | string |
disabled | false | boolean |
hasSeparator | false | boolean |
multiple | false | boolean |
allowDeselect | false | boolean |
isLoading | false | boolean |
loadingText | 'Loading options...' | string |
clearSelectionAriaLabel | 'Clear selection' | string |
shouldTeleport | false | boolean |
teleportTo | 'body' | string |
Usage
id
Sets an id for the component.
<template>
<DropdownSelect
id=""
/>
</template>
options
Sets the options for the component.
You can add non-interactive section headers by setting sectionTitle: true on an option.
<template>
<DropdownSelect
:options="exampleOptions"
/>
</template>
<script setup lang="ts">
const exampleOptions = ref<SelectOption[]>([
{
sectionTitle: true,
text: "Basic options",
value: "section-basic",
icon: "mdi:shape-outline",
},
{
text: "Item 1",
value: "item-1",
},
{
text: "Item 2",
value: "item-2",
},
{
text: "Item 3",
value: "item-3",
},
])
</script>
TypeScript interface
interface SelectOption {
id?: string | number
value: string | number
sectionTitle?: boolean
text?: string
icon?: string
userDisplayName?: string
userProfileImg?: string
imgUrl?: string
alt?: string
helpText?: string
to?: string
isExternal?: boolean
disabled?: boolean
}
placeholder
Sets the placeholder text for the select. This text appears when no option is selected.
<template>
<DropdownSelect
placeholder="Select an option"
/>
</template>
type
Sets the type of the select. Uses the SelectType enum.
<template>
<DropdownSelect
type="SelectType.TEXT"
/>
</template>
Options
| Value | Description |
|---|---|
TEXT | Uses the following keys from the options array: text, value |
ICON | Uses the following keys from the options array: text, value, icon |
USER | Uses the following keys from the options array: userDisplayName, userProfileImg, value |
IMAGE | Uses the following keys from the options array: text, value, imgUrl, alt |
size
Sets the size of the select. Uses the SelectSize enum.
<template>
<DropdownSelect
size="SelectSize.LG"
/>
</template>
Options
| Value | Description |
|---|---|
MD | Medium size |
LG | Large size |
activeStyle
Sets the active style of the select. Uses the SelectActiveStyle enum.
<template>
<DropdownSelect
activeStyle="SelectActiveStyle.FILL"
/>
</template>
Options
| Value | Description |
|---|---|
CHECK | Check style |
FILL | Fill style |
modelValue
Sets the model value of the select.
<template>
<DropdownSelect
:modelValue="selectedValue"
/>
</template>
<script setup lang="ts">
const selectedValue = ref("item-1")
</script>
dropdownPosition
Sets the position of the dropdown. It is usefull to avoid dropdown menu overflow when reaching the container limit. Uses the DropdownPosition enum
<template>
<DropdownSelect
dropdownPosition="DropdownPosition.TOP"
/>
</template>
Options
| Value | Description |
|---|---|
TOP | Top position |
BOTTOM | Bottom position |
selectBoxClass
Sets the class of the select box. Customizes and overrides the select box styles.
<template>
<DropdownSelect
selectBoxClass="bg-background-container-surface"
/>
</template>
filterable
Enables or disables filterable dropdown items. Those items can be filtered using a search field that appear on top of the list items.
<template>
<DropdownSelect
filterable
/>
</template>
searchFieldPlaceholder
Sets the placeholder text for the filtered DropdownSelect search field. It requires the prop filterable to be true helpful.
<template>
<DropdownSelect
filterable
searchFieldPlaceholder="Search..."
/>
</template>
noResultsFoundText
Sets the text to display when there are no results found while filtering. It requires the prop filterable to be true helpful.
<template>
<DropdownSelect
filterable
noResultsFoundText="No results found"
/>
</template>
disabled
Enables or disables the select.
<template>
<DropdownSelect
disabled
/>
</template>
hasSeparator
Shows or hides the separator between the dropdown menu items.
<template>
<DropdownSelect
hasSeparator
/>
</template>
multiple
Allows multiple selection of items. This requires the modelValue to be an array.
<template>
<DropdownSelect
multiple
/>
</template>
allowDeselect
Allows the user to deselect items. Can be used with single and multiple selections.
<template>
<DropdownSelect
allowDeselect
/>
</template>
isLoading
Shows a loading state for the select box and dropdown.
<template>
<DropdownSelect
isLoading
/>
</template>
loadingText
Sets the text to display while the select box is loading. It requires the isLoading prop in order to be useful.
<template>
<DropdownSelect
isLoading
loadingText="Loading options..."
/>
</template>
clearSelectionAriaLabel
The clearSelectionAriaLabel prop sets the accessible label for the clear selection button. Override it for i18n.
<template>
<DropdownSelect
clearSelectionAriaLabel="Borrar seleccion"
/>
</template>
shouldTeleport
Teleports the dropdown panel to teleportTo (body by default) instead of rendering it as an absolutely-positioned descendant of the select box. Enable this when the select is used inside a container with overflow-hidden/overflow-auto (such as Table), otherwise the dropdown panel gets clipped by that ancestor.
<template>
<DropdownSelect
shouldTeleport
/>
</template>
teleportTo
Sets the teleport target selector used when shouldTeleport is true.
<template>
<DropdownSelect
shouldTeleport
teleportTo="body"
/>
</template>