Skip to content

VegaSelect ​

The VegaSelect component is a versatile tool that merges a dropdown list with a searchable input field. It allows users to select from predefined or dynamically loaded options, tailored for a variety of applications. Key features include customizable styling, support for infinite scrolling, and the ability to enable or disable user input through the searchable property.

Simple example:

vue
selected: <code>{{ value }}</code>
<VegaSelect
  v-model="value"
  :options="options"
  value-field="id"
  label-field="title"
>
</VegaSelect>

<script setup>
  import { VegaSelect } from 'vega-ui'
  const value = ref('')

  const options = ref([
    { id: 1, title: 'one' },
    { id: 2, title: '2S' },
  ])

</script>

Code above will give you a following result:

selected:

Props ​

Props ​

Prop NameTypeDefault ValueDescription
background-colorstring'var(--vega-secondary)'Background color of the input field.
background-color-dropdownstring'var(--vega-secondary)'Background color of the dropdown container.
border-colorstring'var(--vega-border-color)'Border color of the input field.
border-color-dropdownstring'var(--vega-border-color)'Border color of the dropdown container.
border-radiusstring'4px'Border radius of the input field.
border-radius-dropdownstring'4px'Border radius of the dropdown container.
clearablebooleantrueShows clear button inside the input.
delay-debouncenumber600Debounce delay for input/search updates (ms).
dropdown-auto-positionbooleanfalseEnables automatic dropdown repositioning.
dropdown-close-on-selectbooleantrueCloses dropdown after selecting an option.
dropdown-item-heightnumber34Height of each dropdown item (not actively used in logic).
dropdown-item-selected-colorstring'var(--vega-primary)'Color of selected dropdown option.
dropdown-max-widthstring—Maximum width of the dropdown.
dropdown-min-widthstring—Minimum width of the dropdown.
dropdown-placementstring'bottom-start'Dropdown placement relative to trigger element.
dropdown-scrollbar-colorstring'var(--vega-border-color)'Scrollbar color of the dropdown.
dropdown-z-indexnumber1Z-index of the dropdown container.
filtersobject—Additional params passed to remote handler (merged with search query).
focus-border-colorstring'var(--vega-border-color)'Border color when input is focused.
font-colorstring'var(--vega-text-color)'Text color of the input field.
font-sizestring'inherit'Font size of the input field.
font-size-dropdownstring'inherit'Font size inside dropdown.
font-weightstring—Font weight of the input text.
heightstring'auto'Height of the input field.
hide-empty-dropdownbooleanfalseHides dropdown when there are no options.
hover-border-colorstring'var(--vega-border-color)'Border color on hover.
hover-color-dropdownstring'var(--vega-primary)'Background color of option on hover.
hover-text-color-dropdownstring—Text color of option on hover.
infinite-scrollbooleanfalseEnables infinite scroll for dropdown (requires remote handler).
labelstring''Label displayed above the input.
label-fieldstring'label'Field used to display option label.
no-options-messagestring'No options available'Message shown when no options are available.
not-emptybooleanfalseAutomatically selects first option if model is empty.
option-padding-dropdownstring'8px 12px'Padding inside dropdown options.
optionsarray[]List of selectable options.
paddingstring'10px'Padding inside input field.
placeholderstring'Select value'Placeholder text.
placeholder-colorstring'var(--vega-gray)'Color of placeholder text.
readonlybooleanfalseMakes input read-only and disables dropdown interaction.
remote-handlerfunction—Async function to fetch options from server.
response-handlerfunction(res) => res.data.dataTransforms API response into options.
search-persistbooleanfalseKeeps search value after reopening dropdown.
search-query-keystring'search'Key used for search query in API requests.
searchablebooleanfalseEnables typing/search inside input.
text-alignstring'left'Text alignment inside input field.
text-color-dropdownstring—Text color of dropdown options.
tooltip-fieldstring—Field used for tooltip text in options.
transition-duration-dropdownstring'0.3s'Duration of dropdown animation.
value-fieldstring'value'Field used as option value.
widthstring'100%'Width of the input field.

API Response Format ​

The remoteHandler function should expect the following response format from the server:

json
{
  "data": {
    "data": [
      { "id": 1, "name": "Option 1" },
      { "id": 2, "name": "Option 2" }
    ],
    "meta": {
      "total": 2
    }
  }
}

Events ​

The component emits the following events:

Event NameDescription
selectedEmitted when the user selects a value from the dropdown. The event passes the selected value as a parameter, allowing you to handle the selection in your application logic.
clearEmitted when the clear button is pressed, allowing you to reset the input field or perform other cleanup actions.

Slots ​

The component provides several slots that allow for the insertion of custom content at various points within the component. These slots enable you to enhance functionality and tailor the appearance to better fit the design of your user interface.

Slot NameSlot PropsDescription
label-Use this slot to insert custom label content above the input field, such as an icon or additional text.
trigger-Used to insert custom trigger content, such as a button or input field, that opens the dropdown.
clear-icon-Slot for adding a custom icon for the clear action in the input component.
prefix-Slot for adding content before the input field content, typically used for icons or labels.
postfix-Slot for adding content after the input field content. Includes dynamic adjustment when the dropdown is opened.
option{ option: Object }Slot for inserting custom content for each option within the dropdown list