SelectField
Form field component for selecting an option from a dropdown.
Component
Help text example
Props
| Props | Required | Default | Type |
|---|---|---|---|
id | true | — | string |
label | — | — | string |
helpText | — | 'Text' | string |
helpTextPosition | — | Position.BOTTOM | Position |
required | — | false | boolean |
showOptionalLabel | — | true | boolean |
optionalLabel | — | — | string |
options | — | [] | SelectOption[] |
placeholder | — | 'Select an option' | string |
modelValue | — | null | string | number | (string | number)[] | null |
type | — | SelectType.TEXT | SelectType |
size | — | SelectSize.MD | SelectSize |
activeStyle | — | SelectActiveStyle.CHECK | SelectActiveStyle |
dropdownPosition | — | Position.BOTTOM | Position |
filterable | — | false | boolean |
searchFieldPlaceholder | — | 'Search...' | string |
noResultsFoundText | — | 'No results found' | string |
disabled | — | false | boolean |
validator | — | () => null | function |
error | — | '' | string |
hasSeparator | — | false | boolean |
multiple | — | false | boolean |
hasBadgeStack | — | false | boolean |
allowDeselect | — | false | boolean |
showLoadingState | — | true | boolean |
isLoading | — | true | boolean |
loadingText | — | 'Loading options...' | string |
loadingOptionsPlaceholder | — | 'Options are being loaded' | |
selectBoxClass | — | — | string |
clearSelectionAriaLabel | — | 'Clear selection' | string |
transparent | — | false | boolean |
shouldTeleport | — | false | boolean |
teleportTo | — | 'body' | string |
Usage
id
Sets the id of the field.
<template>
<SelectField id="field-id" />
</template>
label
Sets the label of the field.
<template>
<SelectField label="Label text" />
</template>
helpText
Sets the help text of the field.
<template>
<SelectField helpText="Help text example" />
</template>
helpTextPosition
Sets the position of the help text relative to the field. It uses the Position enum.
<template>
<SelectField helpTextPosition="top" helpText="Appears above the field" />
</template>
Options
| Value | Description |
|---|---|
TOP | top |
BOTTOM | bottom |
required
Sets whether the field is required or not.
<template>
<SelectField required />
</template>
showOptionalLabel
When the field is not required, shows an "(optional)" hint next to the label. Set to false to hide it. The hint text defaults to a global setting that can be overridden project-wide, and can also be overridden per field with the optionalLabel prop.
<template>
<SelectField label="Country" :showOptionalLabel="false" />
</template>
optionalLabel
Overrides the "(optional)" hint text for this specific field, taking priority over the global default.
<template>
<SelectField label="Country" optionalLabel="(not required)" />
</template>
options
Sets the options of the field. The array of options must be of type SelectOption.
<template>
<SelectField :options="items" />
</template>
<script setup lang="ts">
const items: SelectOption[] = [
{
value: 1,
text: 'Option 1',
},
{
value: 2,
text: 'Option 2',
},
{
value: 3,
text: 'Option 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
}
placeholder
Sets the placeholder text of the field.
<template>
<SelectField placeholder="Select an option" />
</template>
modelValue
Sets the value of the field. The value can be a string, number, or an array of strings or numbers.
<template>
<SelectField v-model="selectedValue" />
</template>
<script setup lang="ts">
const selectedValue = ref<string | number | (string | number)[]>(null)
</script>
type
Sets the type of the field. It uses the SelectType enum.
<template>
<SelectField
:type="SelectType.ICON"
:options="items"
/>
</template>
<script setup lang="ts">
const items: SelectOption[] = [
{
value: 'home',
text: 'Home',
icon: 'mdi:home-outline',
},
{
value: 'settings',
text: 'Settings',
icon: 'mdi:cog-outline',
},
{
value: 'profile',
text: 'Profile',
icon: 'mdi:account-outline',
},
]
</script>
Options
| Value | Description |
|---|---|
TEXT | Displays a select with text options |
ICON | Displays a select with icon and text options |
USER | Displays a select with user avatar and username options |
IMAGE | Displays a select with image and text options |
size
Sets the size of the input field. It uses the InputSize enum.
<template>
<SelectField :size="InputSize.MD" />
</template>
Options
| Value | Description |
|---|---|
MD | md |
LG | lg |
activeStyle
Sets the active style of the selected option. It uses the SelectActiveStyle enum.
<template>
<SelectField :activeStyle="SelectActiveStyle.FILL" />
</template>
Options
| Value | Description |
|---|---|
CHECK | Displays a checkmark next to the selected option |
FILL | Fills the background of the selected option |
dropdownPosition
Sets the position of the dropdown. It uses the Position enum.
<template>
<SelectField :dropdownPosition="Position.TOP" />
</template>
Options
| Value | Description |
|---|---|
TOP | Displays the dropdown above the select field |
BOTTOM | Displays the dropdown below the select field |
filterable
Sets whether the select field is filterable or not.
<template>
<SelectField filterable />
</template>
searchFieldPlaceholder
Sets the placeholder text of the search field.
<template>
<SelectField searchFieldPlaceholder="Search..." />
</template>
noResultsFoundText
Sets the text displayed when no results are found in the search.
<template>
<SelectField noResultsFoundText="No results found" />
</template>
disabled
Sets whether the select field is disabled or not.
<template>
<SelectField disabled />
</template>
validator
Sets the validator function for the field, which controls its internal validation state.
<template>
<InputField :validator="validateField" />
</template>
error (v-model:error)
Sets the error message of the field. This prop is bindable via v-model:error, allowing two-way syncing of the validation state.
<template>
<SelectField v-model:error="errorMessage" />
</template>
hasSeparator
Adds a separator between options in the dropdown.
<template>
<SelectField hasSeparator />
</template>
multiple
Enables multiple selection mode.
<template>
<SelectField multiple />
</template>
hasBadgeStack
Enables badge stack for multiple selected options.
<template>
<SelectField hasBadgeStack multiple />
</template>
allowDeselect
Allows deselecting the selected option.
<template>
<SelectField allowDeselect />
</template>
showLoadingState
Sets whether to show the loading state when options are being loaded.
<template>
<SelectField showLoadingState />
</template>
isLoading
Sets whether the options are currently being loaded.
<template>
<SelectField :isLoading="true" />
</template>
loadingText
Sets the loading text displayed when options are being loaded.
<template>
<SelectField loadingText="Loading options..." />
</template>
loadingOptionsPlaceholder
Sets the placeholder text displayed when options are being loaded.
<template>
<SelectField loadingOptionsPlaceholder="Options are being loaded" />
</template>
selectBoxClass
Allows passing custom classes to the select box for additional styling.
<template>
<SelectField selectBoxClass="custom-select-box" />
</template>
clearSelectionAriaLabel
Sets the accessible label for the clear selection button in multi-select mode. Useful for i18n.
<template>
<SelectField clearSelectionAriaLabel="Limpiar selección" />
</template>
transparent
When true, removes the default bg-background-container-surface background from the select box, making it transparent.
<template>
<SelectField transparent />
</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 field is used inside a container with overflow-hidden/overflow-auto (such as Table), otherwise the dropdown panel gets clipped by that ancestor.
<template>
<SelectField
id="field-id"
shouldTeleport
/>
</template>
teleportTo
Sets the teleport target selector used when shouldTeleport is true.
<template>
<SelectField
id="field-id"
shouldTeleport
teleportTo="body"
/>
</template>