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
Disabled
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: unknown) => unknown) | - | item as T |
customValidity | Custom HTML 5 validation error to set on the form control | string | ((currentValue: unknown, state: ValidityState) => string) | - | |
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 options based on the input value - default is label string comparison | ((options: unknown, value: string) => boolean) | - | |
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: { |
input | The value of the inner input, use v-model:input to make it two-way binding | string | - | "" |
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 selected items, use v-model to make it two-way binding binding | unknown[] | - | |
openOnFocus | Opens a dropdown with choices when the input field is focused | boolean | - | false |
options | Taginput options | OptionsPropWithGroups<unknown> | - | |
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 | object | - | 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: unknown) => boolean) | - | true |
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[] | 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 value | on input change event |
add | value string | number | object - added item | new item got added |
remove | value string | number | 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 itemsoptions object[] - selected options |
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
SASS Variable | Default |
---|---|
$taginput-height | 2em |
$taginput-tag-size | 0.9em |
See ➜ 📄 Full scss file
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