InputTag
A field whose value is a list of short strings, each shown as a removable tag, added with Enter, a separator or a paste.
Import
import { InputTag } from '@vitral/vue';Basic
Type and press Enter, or type a comma. Backspace in an empty box removes the last tag.
Checked as they are added
`validate` refuses a tag and leaves the text in the box to be fixed; `reject` says what happened, so the field can explain itself. Several separators are allowed: this one takes a comma, a semicolon or a space.
A maximum
`max` stops the list where it should stop; what is refused is reported rather than dropped quietly.
Sizes and states
The field chrome is the shared one: the same sizes, variants, invalid and disabled states as every other input.
API
Read from packages/vue/src/components/InputTag/types.ts, so it says what the component actually accepts.
Props
| Name | Type | Description |
|---|---|---|
| separator | string | readonly string[] | What ends a tag as it is typed, besides Enter. Defaults to a comma. |
| max | number | How many tags the field takes. |
| allowDuplicate | boolean | Keep a tag the list already has. Off by default. |
| addOnBlur | boolean | Add what is in the box when focus leaves the field. On by default. |
| validate | (tag: string) => boolean | Refuse a tag: the text stays in the box for the reader to fix. |
| placeholder | string | — |
| removeIcon | IconProp | — |
| size | Size | — |
| variant | InputVariant | Defaults to the plugin's `inputVariant`. |
| invalid | boolean | — |
| disabled | boolean | — |
| readonly | boolean | — |
| fluid | boolean | — |
| name | string | The name the field is submitted under; the tags are sent one by one. |
Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.
Emits
| Event | Payload | Description |
|---|---|---|
| add | event: { originalEvent: Event; value: string; tags: string[] } | A tag was added, by Enter, by a separator, by a paste or on blur. |
| remove | event: { originalEvent: Event; value: string; index: number; tags: string[] } | A tag was taken out, by its button or by a key. |
| reject | event: { originalEvent: Event; value: string; reason: 'duplicate' | 'max' | 'invalid' } | Something was refused: the list was full, the tag was already there, or `validate` said no. |
| focus | event: FocusEvent | — |
| blur | event: FocusEvent | — |
Slots
| Name | Slot props | Description |
|---|---|---|
| tag | (props: { value: string; index: number; remove: (event: Event) => void }) | Replaces a tag's content, inside the tag's own box. |
| removeicon | (props: { value: string; index: number }) | — |