Taginput
A simple tag input field that can have autocomplete functionality
Examples
Base
Show code
Autocomplete
Show code
Custom selected
Show code
Limits
Show code
Variants
Show code
Class props
Taginput component
A simple tag input field that can have autocomplete functionality
html
<o-taginput></o-taginput>
Props
Prop name | Description | Type | Values | Default |
---|---|---|---|---|
allowDuplicates | Allows adding the same item multiple time | boolean | - | From config: taginput: { |
allowNew | Allows adding new items | boolean | - | From config: taginput: { |
ariaCloseLabel | Accessibility label for the close button | string | - | From config: taginput: { |
autocomplete | Native options to use in HTML5 validation | string | - | From config: taginput: { |
checkScroll | Makes the component check if list reached scroll start or end and emit scroll events. | boolean | - | From config: taginput: { |
closable | Add close/delete button to the item | boolean | - | From config: taginput: { |
closeIcon | Icon name of close icon on selected item | string | - | From config: taginput: { |
confirmKeys | Array of keys (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) which will add a item when typing | string[] | - | From config: taginput: { |
counter | Show counter when maxlength or maxtags props are passed | boolean | - | From config: taginput: { |
createItem | Function to create a new item to push into v-model (items) | (value: string | object) => string | object | - | Default function (see source code) |
disabled | Same as native input disabled | boolean | - | false |
expanded | Makes input full width when inside a grouped or addon field | boolean | - | false |
field | Property of the object (if data is array of objects) to use as display text | string | - | "value" |
filter | Function to filter the options based on the input value - default is display text comparison | (options: (string | object)[], value: string) => (string | object)[] | - | |
formatter | Function to format an option to a string for display it in the input (as alternative to field prop) | (value: unknown, option: string | object) => string | - | |
groupField | Property of the object (if data is array of objects) to use as display text of group | string | - | |
groupOptions | Property of the object (if data is array of objects) to use as key to get items array of each group | string | - | |
icon | Icon to be shown | string | - | From config: taginput: { |
iconPack | Icon pack to use | string | mdi , fa , fas and any other custom icon pack | From config: taginput: { |
keepFirst | The first option will always be pre-selected (easier to just hit enter or tab) | boolean | - | false |
keepOpen | Keep open dropdown list after select | boolean | - | From config: taginput: { |
maxitems | Limits the number of items, plus item counter | string | number | - | |
maxlength | Same as native maxlength, plus character counter | string | number | - | |
v-model | The input value state | string[]|object[] | - | Default function (see source code) |
openOnFocus | Opens a dropdown with choices when the input field is focused | boolean | - | false |
options | Items data | string[]|object[] | - | Default function (see source code) |
override | Override existing theme classes completely | boolean | - | |
placeholder | Input placeholder | string | - | |
removeOnKeys | Allow removing last item when pressing given keys (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values), if input is empty | string[] | - | From config: taginput: { |
separators | Array of chars used to split when pasting a new string | string[] | - | From config: taginput: { |
size | Vertical size of the input control | string | small , medium , large | From config: taginput: { |
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 | Record<string, any> | - | From config: taginput: { |
useHtml5Validation | Enable html 5 native validation | boolean | - | From config: { |
validateItem | Function to validate the value of a new item before it got added | (value: string | object) => boolean | - | Default function (see source code) |
validationMessage | The message which is shown when a validation error occurs | string | - | |
variant | Color of the each item | string | primary , info , success , warning , danger , and any other custom color | From config: taginput: { |
Events
Event name | Properties | Description |
---|---|---|
scroll-start | the list inside the dropdown reached the start | |
scroll-end | the list inside the dropdown reached it's end | |
icon-click | event Event - native event | on icon click event |
icon-right-click | event Event - native event | on icon right click event |
update:modelValue | value string[] | object[] - updated modelValue prop | modelValue prop two-way binding |
input | value string - input value | on input change event |
add | value string | object - added item | new item got added |
remove | value string | object - removed item | item got removed |
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 |
Slots
Name | Description | Bindings |
---|---|---|
selected | Override selected items | items (string, object)[] - selected items |
header | Define an additional header | |
default | Override the select option | option object - option objectindex number - option indexvalue unknown - option value |
empty | Define content for empty state | |
footer | Define an additional footer | |
counter | Override the counter | items number - items counttotal number - total count |
Sass variables
Current theme ➜ Oruga
SASS Variable | Default |
---|---|
$taginput-counter-font-size | 0.75rem |
$taginput-counter-margin | 0.25rem 0 0 0.5rem |
$taginput-item-background-color | var(--#{$prefix}primary) |
$taginput-item-color | var(--#{$prefix}primary-invert) |
$taginput-item-border-radius | var(--#{$prefix}base-border-radius) |
$taginput-item-margin | 0.275em |
$taginput-item-padding | 0 0.75em 0 0.75em |
$taginput-margin-icon-to-text | 0.1875em |
See ➜ 📄 Full scss file
Current theme ➜ Bulma
The theme does not have any custom variables for this component.
Current theme ➜ Bootstrap
SASS Variable | Default |
---|---|
$taginput-badge-bg | $light |
$taginput-badge-color | $dark |
$taginput-badge-font-size | 0.9em |
$taginput-badge-margin | 0.25em |
$taginput-badge-icon-space | 0.25em |
$taginput-counter-margin | 0.25rem 0 0 0.5rem |
$taginput-counter-font-size | 0.75rem |
See ➜ 📄 Full scss file