TagInput
A list of short values typed into one field. Enter or a comma adds what is typed (a pasted "a, b, c" adds three), Backspace in the empty field removes the last tag, and every tag has a remove button named "Remove <tag>". Duplicates and anything over max are refused with a reason. Each add and remove is announced through useAnnouncer. With suggestions, the field is an APG combobox with a listbox: the arrows move the active option, Enter adds it, Escape closes the list and then clears the text.
Install: pnpm add-component Fields/TagInput
Basic usage
Type and press Enter, or type a comma. Backspace in the empty field removes the last tag; the arrow toward the tags moves onto their remove buttons.
Suggestions
An APG combobox: Down opens the list, Up and Down move, Enter adds the active option, Escape closes it.
Limit
A fourth label is refused, and the reason is shown and announced.
Error
In AppForm, type: "tags" fills the error from the schema; items become the suggestions and max the limit.
API
modelValue(string[]): The tags (use v-model).label(string): Visible label; it also names the list of tags and the listbox.placeholder(string): Shown while there are no tags.description(string): Help below the field. A refusal ("vue is already added.") takes its place until the next keystroke.error(string): Shown below with an icon; the frame gets a danger edge, the input aria-invalid and aria-describedby.max(number): Most tags allowed. A counter ("2 of 3") shows and is linked to the input.allowDuplicates(boolean): Let the same tag appear twice. Off, tags are compared without case.suggestions(string[]): Offered in a listbox as the user types; ones already added are left out.addOnBlur(boolean): Add what is typed when the field loses focus, so a submit does not drop it.disabled(boolean): Disables the input and the remove buttons.