Autocomplete
Extended input that provide suggestions while the user types
Class props
Autocomplete component
Extended input that provide suggestions while the user types
html
<o-autocomplete></o-autocomplete>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
animation | Transition name to apply on dropdown list | string | - | From config: autocomplete: { |
autocomplete | Native options to use in HTML5 validation | string | - | From config: autocomplete: { |
checkScroll | Makes the component check if list reached scroll start or end and emit scroll events. | boolean | - | From config: autocomplete: { |
clearIcon | Icon name to be added on the clear button | string | - | From config: autocomplete: { |
clearOnSelect | Clear input text on select | boolean | - | From config: autocomplete: { |
clearable | Add a button/icon to clear the inputed text | boolean | - | From config: autocomplete: { |
confirmKeys | Array of keys (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) which will add a tag when typing (default tab and enter) | string[] | - | From config: autocomplete: { |
customValidity | Custom HTML 5 validation error to set on the form control | string | ((currentValue: unknown, state: ValidityState) => string) | - | |
debounce | Number of milliseconds to delay before to emit input event | number | - | From config: autocomplete: { |
disabled | Same as native input disabled | boolean | - | false |
expanded | Makes input full width when inside a grouped or addon field | boolean | - | false |
filter | Function to filter the option based on the input value - default is label string comparison | ((option: unknown, value: string) => boolean) | - | |
icon | Icon to be shown | string | - | From config: autocomplete: { |
iconClickable | Makes the icon clickable | boolean | - | false |
iconPack | Icon pack to use | string | mdi , fa , fas and any other custom icon pack | From config: autocomplete: { |
iconRight | Icon to be added on the right side | string | - | From config: autocomplete: { |
iconRightClickable | Make the icon right clickable | boolean | - | false |
iconRightVariant | Variant of right icon | string | - | |
input | The value of the inner input, use v-model:input to make it two-way binding | string | - | "" |
itemTag | Menu item tag name | DynamicComponent | - | From config: autocomplete: { |
keepFirst | The first option will always be pre-selected (easier to just hit enter or tab) | boolean | - | From config: autocomplete: { |
keepOpen | Keep open dropdown list after select | boolean | - | From config: autocomplete: { |
maxHeight | Max height of dropdown content | string | number | - | From config: autocomplete: { |
maxlength | Same as native maxlength, plus character counter | string | number | - | |
menuTag | Menu tag name | DynamicComponent | - | From config: autocomplete: { |
mobileModal | Dropdown content (items) are shown into a modal on mobile | boolean | - | From config: autocomplete: { |
v-model | The selected option value, use v-model to make it two-way binding | string|number|object | - | |
openOnFocus | Open dropdown list on focus | boolean | - | From config: autocomplete: { |
options | Autocomplete options | OptionsPropWithGroups<unknown> | - | |
override | Override existing theme classes completely | boolean | - | |
placeholder | Input placeholder | string | - | |
position | Position of the dropdown | "auto" | "top" | "bottom" | auto , top , bottom | From config: autocomplete: { |
rounded | Makes the element rounded | boolean | - | false |
selectOnClickOutside | Trigger the select event for the first pre-selected option when clicking outside and keep-first is enabled | boolean | - | false |
selectableFooter | Allows the footer in the autocomplete to be selectable | boolean | - | false |
selectableHeader | Allows the header in the autocomplete to be selectable | boolean | - | false |
size | Size of the control | string | small , medium , large | From config: autocomplete: { |
statusIcon | Show status icon using field and variant prop | boolean | - | From config: { |
teleport | Append the component to another part of the DOM. Set true to append the component to the body.In addition, any CSS selector string or an actual DOM node can be used. | string | boolean | object | - | From config: autocomplete: { |
type | Input type | string | - | "text" |
useHtml5Validation | Enable HTML 5 native validation | boolean | - | From config: { |
Events
Event name | Properties | Description |
---|---|---|
icon-click | event Event - native event | on icon click event |
update:modelValue | value string | number | object - updated modelValue prop | modelValue prop two-way binding |
update:input | value string - updated input prop | input prop two-way binding |
input | value string - input valueevent Event - native event | on input change event |
select | value string | number | object - selected valueevent Event - native event | selected element changed event |
select-header | event Event - native event | header is selected |
select-footer | event Event - native event | footer is selected |
focus | event Event - native event | on input focus event |
blur | event Event - native event | on input blur event |
invalid | event Event - native event | on input invalid event |
icon-right-click | event Event - native event | on icon right click event |
scroll-start | the list inside the dropdown reached the start | |
scroll-end | the list inside the dropdown reached it's end |
Slots
Name | Description | Bindings |
---|---|---|
header | Define an additional header | |
group | Override the option grpup | group object - options groupindex number - option index |
default | Override the select option | option object - option objectvalue unknown - option valueindex number - option index |
empty | Define content for empty state | |
footer | Define an additional footer |
Sass variables
Current theme ➜ Oruga
SASS Variable | Default |
---|---|
$autocomplete-item-hover-background-color | #f5f5f5 |
See ➜ 📄 Full scss file
Current theme ➜ Bootstrap
SASS Variable | Default |
---|---|
$autocomplete-menu-max-height | 200px |
See ➜ 📄 Full scss file