Tags Input
Installation
Section titled “Installation”Copy editable source into an initialized application:
pnpm dlx @simurgh-ui/cli add tags-inputFor package consumption, import from the component subpath and load its optional recipe CSS:
import { TagsInput, TagsInputProps,} from '@simurgh-ui/react/tags-input';import '@simurgh-ui/styles/tags-input.css';import { TagsInput } from '@simurgh-ui/vue/tags-input';import '@simurgh-ui/styles/tags-input.css';Angular
Section titled “Angular”import { TagsInputComponent } from '@simurgh-ui/angular/tags-input';import '@simurgh-ui/styles/tags-input.css';Omit the component stylesheet for fully headless styling. CLI-copied components use the local path
written to simurgh.json and the copied application styles instead of these package imports.
Purpose
Section titled “Purpose”Tags Input turns short text values into removable tokens while retaining native text entry and form submission. Press Enter or comma to add the current value, Backspace on an empty control to remove the last tag, or use each tag’s labelled remove button.
Default presentation: styled
Section titled “Default presentation: styled”The optional component stylesheet provides a complete default recipe, including visual hierarchy and interaction states. Consumers can override semantic tokens or omit the recipe.
Basic usage
Section titled “Basic usage”Anatomy
Section titled “Anatomy”The public component parts are listed in API surface below. Use only the parts needed by the example; compound components depend on their documented parent/child nesting.
State model
Section titled “State model”Controlled state remains the application’s source of truth and must be updated from every change event. Uncontrolled state reads its default only when the component mounts. Do not pass both forms of the same state at once.
| Framework | Exact state contract and reset behavior |
|---|---|
| React | Controlled: value + onValueChange. Uncontrolled: defaultValue. Reset controlled state by assigning the initial value; reset uncontrolled state by changing a React key. |
| Vue | Controlled: v-model (modelValue + update:modelValue). Uncontrolled: defaultValue. Reset the model ref to its initial value; reset uncontrolled state with a changed Vue :key. |
| Angular | Controlled two-way binding: [(value)] (value + valueChange). Angular exposes no separate default input; initialize and reset the bound class field explicitly. |
React
const initialValue = '';const [value, setValue] = useState(initialValue);const [resetKey, setResetKey] = useState(0);
<TagsInput value={value} onValueChange={setValue}>…</TagsInput><button onClick={() => setValue(initialValue)}>Reset controlled</button><TagsInput key={resetKey} defaultValue={initialValue}>…</TagsInput><button onClick={() => setResetKey((key) => key + 1)}>Reset uncontrolled</button>Vue
<script setup lang="ts">import { ref } from 'vue';const initial = '';const state = ref(initial);const resetKey = ref(0);</script>
<TagsInput v-model="state">…</TagsInput><button @click="state = initial">Reset controlled</button><TagsInput :key="resetKey" :defaultValue="initial">…</TagsInput><button @click="resetKey++">Reset uncontrolled</button>Angular
initial = '';value = this.initial;reset() { this.value = this.initial; }<simurgh-tags-input [(value)]="value">…</simurgh-tags-input><button type="button" (click)="reset()">Reset</button>Duplicate and blank values are ignored. maxTags defaults to 20 and is capped at 100 to keep rendering bounded. When name is provided, every tag produces a hidden input with that name, so FormData.getAll(name) returns the complete list. Use required when at least one tag must be supplied, and provide localized input and removal labels where needed.
Examples
Section titled “Examples”<TagsInput aria-label="Skills" inputLabel="Add skill" name="skills" defaultValue={['TypeScript']} onValueChange={setSkills} /><TagsInput v-model="skills" aria-label="Skills" input-label="Add skill" name="skills" /><simurgh-tags-input aria-label="Skills" inputLabel="Add skill" name="skills" [value]="skills" (valueChange)="skills = $event" />Keyboard interactions
Section titled “Keyboard interactions”These keys describe behavior implemented by the adapters. Native Tab, Enter, and Space behavior still applies to descendant links, buttons, and form controls unless the component overrides it.
| Concern / keys | Behavior |
|---|---|
| Focus entry and exit (Tab / Shift+Tab) | Tab enters the text input and leaves normally; remove buttons remain in DOM order. |
| Navigation and activation | Enter commits input; Backspace removes the last tag when input is empty. |
| Escape | Not handled by the component. |
| RTL differences | No RTL-specific key mapping. |
| Typeahead | Not supported. |
Accessibility
Section titled “Accessibility”Preserve the documented composition and accessible names when wrapping or restyling this component. See accessibility and RTL guidance for keyboard, focus, labeling, and directionality requirements.
API surface
Section titled “API surface”- React exports:
TagsInput,TagsInputProps - Vue exports:
TagsInput - Angular exports:
TagsInputComponent
Import these public symbols from the component subpath shown in Installation. Framework-specific props, events, slots, directives, methods, defaults, and native-attribute behavior belong in the API tables on this page; use the linked source only to verify the current implementation.
React API reference
An inherited-attributes entry means the component accepts the complete named React native interface, including its event handlers and ARIA and data attributes. Remaining attributes are forwarded to the rendered element unless the component behavior described on this page overrides them.
TagsInput
Section titled “TagsInput”Inherited attributes: HTMLAttributes<HTMLDivElement> & RefAttributes<HTMLInputElement>.
| Prop | Type | Default / requirement |
|---|---|---|
children | ReactNode | undefined |
defaultValue | string[] | [] |
disabled | boolean | undefined |
getRemoveLabel | (tag: string) => string | (tag) => `Remove ${tag}` |
inputLabel | string | 'Add a tag' |
maxTags | number | 20 |
name | string | undefined |
onValueChange | (value: string[]) => void | undefined |
placeholder | string | 'Add a tag' |
readOnly | boolean | undefined |
ref | Ref<HTMLInputElement> | undefined | undefined |
required | boolean | undefined |
value | string[] | undefined |
TagsInputProps
Section titled “TagsInputProps”Exported type: Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" \| "onChange"> & { value?: string[]; defaultValue?: string[]; name?: string; disabled?: boolean; readOnly?: boolean; required?: boolean; maxTags?: number; placeholder?: string; inputLabel?: string; getRemoveLabel?: (tag: string) => string; onValueChange?: (value: string[]) => void; }.
Vue API reference
Boolean props without explicit defaults use Vue’s false default. Undeclared attributes follow
the fallthrough behavior stated for each component.
TagsInput
Section titled “TagsInput”Automatic fallthrough is disabled; attrs are manually forwarded to the rendered root.
| Prop | Type | Default / requirement |
|---|---|---|
modelValue | string[] | undefined |
defaultValue | string[] | () => [] |
name | string | undefined |
disabled | boolean | false |
readonly | boolean | false |
required | boolean | false |
maxTags | number | 20 |
placeholder | string | 'Add a tag' |
inputLabel | string | 'Add a tag' |
getRemoveLabel | (tag: string) => string | (tag: string) => `Remove ${tag}` |
| Event | Payload |
|---|---|
update:modelValue | string[] |
Slots: none.
Exposed methods: none.
Angular API reference
Angular
Section titled “Angular”Inputs and outputs use their public template names. Public methods are callable through a template
reference or ViewChild. Native attributes apply to the documented template root or directive host;
they are not automatically forwarded through component hosts.
TagsInputComponent
Section titled “TagsInputComponent”Component selector: simurgh-tags-input. The template’s first native element is div.
| Input | Type | Default / requirement |
|---|---|---|
value | string[] | undefined |
name | string | undefined |
disabled | boolean | false |
readonly | boolean | false |
required | boolean | false |
maxTags | number | 20 |
placeholder | string | 'Add a tag' |
inputLabel | string | 'Add a tag' |
aria-label | string | 'Tags' |
| Output | Payload |
|---|---|
valueChange | string[] |
Content projection: none.
| Public method |
|---|
removeLabel(tag: string): string |
commit(value: string[]): void |
add(): void |
remove(index: number, event?: Event): void |
handleKeydown(event: KeyboardEvent): void |
Composition contract
Section titled “Composition contract”Follow the framework example as a structural contract. Root components own shared state; parts that consume that state must stay under the root (or be attached to projected descendants in Angular). Parts described as conditional are optional until their corresponding interaction or semantic region is used. Do not render a state-consuming part by itself.
| Framework | Required parent/child relationship | Conditional parts | Supporting types |
|---|---|---|---|
| React | TagsInput is standalone and required when using this component. | Content is optional unless the API requires a label or value. | TagsInputProps. |
| Vue | TagsInput is standalone and required when using this component. | Content is optional unless the API requires a label or value. | None. |
| Angular | TagsInputComponent is standalone and required when using this component. | Content is optional unless the API requires a label or value. | None. |
Accessible names, descriptions, and form labels remain required whenever the component’s purpose cannot otherwise be determined, even when the corresponding visual part is optional.
Framework parity and differences
Section titled “Framework parity and differences”The adapters target the same user-visible behavior and accessibility contract. Their public shapes follow each framework’s conventions and are not expected to be symbol-for-symbol identical.
| Concern | Contract |
|---|---|
| Public composition | React exports 2 parts, Vue 1, and Angular 1. These are intentional composition differences; use each framework’s example rather than translating symbol-for-symbol. |
| State and change events | React uses controlled/default props and callbacks for value; Vue uses v-model; Angular uses [(value)]. |
| Children and content | React uses children; Vue uses the slots listed above; Angular uses the documented content projection selectors. |
| Native attributes | React forwards the named native interface; Vue follows the stated fallthrough rule; Angular attributes apply to the component host unless an input, directive, or documented native root consumes them. |
| Imperative access | React forwards native refs; Vue exposes no methods; Angular exposes the listed class methods through a template reference or ViewChild. |
These differences are intentional adapter design. Behavioral or accessibility differences not stated on this page are parity defects rather than supported variations.
Form integration
Section titled “Form integration”Use name="tags" to serialize one same-name hidden value per tag. The examples initialize the field, keep its
value application-owned, forward disabled and required, render an accessible error, and read
the browser submission payload. This component has no public invalid prop; announce validation errors next to the labeled control and use native validity where available.
const initial = ['docs'];const [value, setValue] = useState(initial);const [errors, setErrors] = useState<Record<string, string>>({});
<form onSubmit={(event) => { event.preventDefault(); const data = new FormData(event.currentTarget); // Submit data.get('tags') or data.getAll('tags').}}> <TagsInput name="tags" value={value} onValueChange={setValue} required disabled={isDisabled} /> {errors.tags && <p role="alert">{errors.tags}</p>} <button type="submit">Submit</button></form><script setup lang="ts">import { reactive, ref } from 'vue';const initial = ['docs'];const value = ref(initial);const errors = reactive<Record<string, string>>({});function submit(event: Event) { const data = new FormData(event.currentTarget as HTMLFormElement); // Submit data.get('tags') or data.getAll('tags').}</script>
<form @submit.prevent="submit"> <TagsInput v-model="value" name="tags" required :disabled="isDisabled"></TagsInput> <p v-if="errors.tags" role="alert">{{ errors.tags }}</p> <button type="submit">Submit</button></form>Angular
Section titled “Angular”initial = ['docs'];value = this.initial;errors: Record<string, string> = {};submit(form: HTMLFormElement) { const data = new FormData(form); // Submit data.get('tags') or data.getAll('tags').}<form #form (submit)="submit(form); $event.preventDefault()"> <simurgh-tags-input [(value)]="value" name="tags" required [disabled]="isDisabled"></simurgh-tags-input> <p *ngIf="errors.tags" role="alert">{{ errors.tags }}</p> <button type="submit">Submit</button></form>For Angular reactive or template-driven forms, bridge the documented value/valueChange pair
to your form control. The component does not implement ControlValueAccessor; update disabled and
validation state from the Angular form explicitly.
Supported states
Section titled “Supported states”The table distinguishes component behavior from application-owned presentation. “Not supported” means there is no public state contract for that adapter; do not invent one with an undocumented attribute. Keep status and error messages accessible when they are rendered outside the component.
| State | React | Vue | Angular |
|---|---|---|---|
| Loading | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Empty | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Invalid | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
| Read-only | Supported with readOnly={true}; focus and value submission remain available while editing is blocked. | Supported with :readonly="true"; focus and value submission remain available while editing is blocked. | Supported with [readonly]="true"; focus and value submission remain available while editing is blocked. |
| Disabled | Supported with disabled={true} on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. | Supported with :disabled="true" on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. | Supported with [disabled]="true" on the documented control or interactive part; its interaction is blocked. Disabled form controls are omitted from submission. |
| Error | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. | Not supported by this component API; handle this state in surrounding application UI. |
Styling contract
Styling contract
Section titled “Styling contract”The selectors below are used by the published component recipe or emitted consistently by an adapter. Treat these as the supported styling surface. Element order, anonymous wrappers, and undocumented descendants are implementation details and should not be targeted.
| Surface | Stable hooks |
|---|---|
| Recipe classes | No component-specific recipe class; this stylesheet currently imports shared tokens only. |
| Stable DOM parts | [data-slot="tags-input"], [data-slot="tags-input-control"], [data-slot="tags-input-remove"], [data-slot="tags-input-tag"], [data-slot="tags-input-tag-text"] |
| Stable data attributes | [data-disabled], [data-readonly], [data-slot] |
| ARIA/state selectors used by the recipe | No ARIA state selector is used by this recipe. |
| CSS custom properties consumed | --simurgh-accent, --simurgh-background, --simurgh-border, --simurgh-foreground, --simurgh-ring |
Prefer a semantic token override for theme-wide changes. Use the listed class or part selectors for a component-scoped override. When omitting recipe CSS, preserve state attributes and ARIA semantics even if your replacement styles use different selectors.
Customization
Section titled “Customization”Load the optional component stylesheet for the default recipe, override semantic tokens for broad theme changes, or omit the recipe CSS for headless styling. See theming and styling hooks for import order, selectors, dark mode, RTL, and reduced-motion guidance.
Last verified on 2026-08-13 against Simurgh registry 0.1.1.
Related components
Section titled “Related components”- Review the shared accessibility and RTL guidance and theming and styling hooks.
- Use the component chooser and component overview to compare related primitives.
- Inspect the registry manifest and framework source for React, Vue, or Angular.