Skills and labels
Capture short, removable strings without building chip behavior.
Components / Forms
Enter, paste, validate, remove, and submit multiple string values in one field.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add tags-inputImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import { ref } from 'vue'
import TagsInput from './components/ui/tags-input/TagsInput.vue'
const skills = ref(['Vue', 'TypeScript'])
</script>
<template>
<TagsInput
v-model="skills"
aria-label="Skills"
placeholder="Add a skill"
:max="6"
class="w-full max-w-xl"
/>
</template>Press Enter or the separator to add a tag. Paste comma- or newline-separated text to add several values, and use FormData.getAll(name) to read repeated form values.
Capture short, removable strings without building chip behavior.
Validate each address and cap how many values can be added.
Reject invalid drafts and stop at five entries.
<script setup lang="ts">
import { ref } from 'vue'
import TagsInput from './components/ui/tags-input/TagsInput.vue'
const recipients = ref<string[]>([])
</script>
<template>
<TagsInput
v-model="recipients"
name="recipient"
placeholder="Add an email address"
:validate="value => value.includes('@')"
:max="5"
aria-label="Recipients"
/>
</template>Override all built-in text without adding a provider.
<script setup lang="ts">
import { ref } from 'vue'
import TagsInput from './components/ui/tags-input/TagsInput.vue'
const labels = ref(['Urgent'])
</script>
<template>
<TagsInput
v-model="labels"
aria-label="Étiquettes"
placeholder="Ajouter une étiquette"
:locale-text="{
removeTag: value => `Supprimer ${value}`,
added: value => `${value} ajouté`,
removed: value => `${value} supprimé`,
}"
/>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
idprop | string | undefined | Not set | Give the control an ID so a label or description can refer to it. |
nameprop | string | undefined | Not set | Name used when this control submits a value with a form. |
formprop | string | undefined | Not set | Associate the control with a form by its ID. |
placeholderprop | string | undefined | Not set | Hint shown when no value has been entered or selected. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
readonlyprop | boolean | undefined | Not set | Show the value while preventing edits. |
requiredprop | boolean | undefined | Not set | Ask the browser to require a value before form submission. |
invalidprop | boolean | undefined | Not set | Show the invalid state; also provide a visible error message. |
sizeprop | ControlSize | undefined | "md" | Choose the visual size. Medium is the usual default where available. |
maxprop | number | undefined | Not set | Largest allowed value. |
separatorprop | string | undefined | "," | Controls the separator behavior of TagsInput. |
addOnBlurprop | boolean | undefined | true | Controls the add on blur behavior of TagsInput. |
allowDuplicatesprop | boolean | undefined | false | Controls the allow duplicates behavior of TagsInput. |
caseSensitiveprop | boolean | undefined | false | Controls the case sensitive behavior of TagsInput. |
validateprop | ((value: string) => boolean) | undefined | Not set | Controls the validate behavior of TagsInput. |
localeTextprop | Partial<TagsInputLocaleText> | undefined | Not set | Controls the locale text behavior of TagsInput. |
modelValuemodel | string[] | undefined | [] | Current value. Use v-model to keep it in sync with your page. |
addevent | [value: string] | — | Emitted when add happens. |
update:modelValueevent | [value: string[]] | — | Requests a new model value from the parent. |
rejectevent | [value: string, reason: TagsInputRejectReason] | — | Emitted when reject happens. |
removeevent | [value: string, index: number] | — | Emitted when remove happens. |
prefixslot | (() => unknown) | undefined | Optional | Content shown before the main label or value. |
tagslot | ((props: { value: string; index: number; remove: () => void; }) => unknown) | undefined | Optional | Content for the tag area of TagsInput. |
suffixslot | (() => unknown) | undefined | Optional | Content shown after the main label or value. |
errorslot | ((props: { message: string; messages: string[]; }) => unknown) | undefined | Optional | Content for the error area of TagsInput. |
elementexposed | HTMLInputElement | null | — | Reference to the underlying HTML element. |
focusexposed | () => void | undefined | — | Move keyboard focus to this control. |
addexposed | (value: string) => boolean | — | Access add from a component template ref. |
removeexposed | (index: number) => void | — | Access remove from a component template ref. |
clearexposed | () => void | — | Access clear from a component template ref. |
// packages/frameworks/vue/components/tags-input/types.ts
import type { TagsInputRejectReason } from '@getweini/vue/primitives/tags-input'
import type { ControlSize } from '@getweini/vue/types'
export type { TagsInputRejectReason } from '@getweini/vue/primitives/tags-input'
export interface TagsInputLocaleText {
removeTag: (value: string) => string
added: (value: string) => string
removed: (value: string) => string
}
export interface TagsInputProps {
id?: string
name?: string
form?: string
placeholder?: string
disabled?: boolean
readonly?: boolean
required?: boolean
invalid?: boolean
size?: ControlSize
max?: number
separator?: string
addOnBlur?: boolean
allowDuplicates?: boolean
caseSensitive?: boolean
validate?: (value: string) => boolean
localeText?: Partial<TagsInputLocaleText>
}
export interface TagsInputRejectEvent {
value: string
reason: TagsInputRejectReason
}
// packages/frameworks/vue/dist/vue/primitives/tags-input/index.d.ts
import { type Ref } from 'vue';
export type TagsInputRejectReason = 'duplicate' | 'max' | 'validation';
export interface TagsInputBehaviorProps {
disabled?: boolean;
readonly?: boolean;
max?: number;
separator?: string;
addOnBlur?: boolean;
allowDuplicates?: boolean;
caseSensitive?: boolean;
validate?: (value: string) => boolean;
}
export interface TagsInputBehaviorCallbacks {
onAdd?: (value: string) => void;
onRemove?: (value: string, index: number) => void;
onReject?: (value: string, reason: TagsInputRejectReason) => void;
}
export declare function useTagsInputBehavior(props: TagsInputBehaviorProps, model: Ref<string[]>, input: Readonly<Ref<HTMLInputElement | null>>, callbacks?: TagsInputBehaviorCallbacks): {
tags: import("vue").ComputedRef<string[]>;
tagRows: import("vue").ComputedRef<{
tag: string;
key: string;
}[]>;
draft: Ref<string, string>;
announcement: Ref<string, string>;
canAdd: import("vue").ComputedRef<boolean>;
focus: () => void | undefined;
add: (value: string) => boolean;
remove: (index: number) => void;
clear: () => void;
commitDraft: () => boolean;
handleInput: (event: Event) => void;
handleKeydown: (event: KeyboardEvent) => void;
handlePaste: (event: ClipboardEvent) => void;
handleBlur: () => void;
};
// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
label: string;
value: T;
disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
/** Popup name when no aria-label or aria-labelledby is supplied. */
listboxLabel: string;
empty: string;
clearSelection: string;
}
export interface ListboxProps<T> {
options: readonly SelectOption<T>[];
messages: ListboxMessages;
id?: string;
disabled?: boolean;
required?: boolean;
invalid?: boolean;
name?: string;
form?: string;
placeholder?: string;
size?: ControlSize;
clearable?: boolean;
gap?: number;
/** Supply stable equality for object values. Values must be unique. */
by?: (a: T, b: T) => boolean;
/** Required for meaningful form submission of object values. */
serialize?: (value: T) => string;
}
// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
variant?: Variant;
size?: Size;
disabled?: boolean;
loading?: boolean;
type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
as?: 'button' | 'a' | Component;
asChild?: boolean;
}