← All Components
<mth-tag-input>
Form-associated inline tag chip editor supporting delimiter splitting, paste parsing, Backspace deletion, duplicate guards, and max-tags limits.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-tag-input>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/tag-input"></script>
<mth-tag-input max-tags="0" delimiter=","></mth-tag-input>import '@methane-ui/ui/tag-input';
import '@methane-ui/react';
export function Example() {
return <mth-tag-input max-tags="0" delimiter=","></mth-tag-input>;
}<script setup lang="ts">
import '@methane-ui/ui/tag-input';
</script>
<template>
<mth-tag-input max-tags="0" delimiter=","></mth-tag-input>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/tag-input';
import { MthTagInputDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthTagInputDirective],
template: `<mth-tag-input max-tags="0" delimiter=","></mth-tag-input>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/tag-input';
import MthTagInput from '@methane-ui/svelte/MthTagInput.svelte';
</script>
<MthTagInput max-tags="0" delimiter=","></MthTagInput>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
name | name | string | "" | Form field name. |
value | value | string | "" | Comma-separated string of entered tags. |
defaultValue | default-value | string | "" | Initial comma-separated tag value for form reset. |
maxTags | max-tags | number | 0 | Maximum number of tags allowed (0 for unlimited). |
allowDuplicates | allow-duplicates | boolean | false | Allows duplicate tag values. |
delimiter | delimiter | string | "," | delimiter property. |
label | label | string | "" | Accessible field label. |
placeholder | placeholder | string | "" | Input placeholder text. |
hint | hint | string | "" | Helper message. |
error | error | string | "" | Validation error message. |
disabled | disabled | boolean | false | Disables editing and removal. |
readonly | readonly | boolean | false | Prevents adding or removing tags. |
required | required | boolean | false | Requires at least one tag for validity. |
Events
| Event | Detail Type | Description |
|---|---|---|
mth-change | { value: string; values: ReadonlyArray<string> } | Fired when the tag list changes. |
mth-tag-add | { tag: string; values: ReadonlyArray<string> } | Fired when a tag is added. |
mth-tag-remove | { tag: string; index: number; values: ReadonlyArray<string> } | Fired when a tag is removed. |
APG Keyboard Matrix
| Key | Direction | When | Expected Behavior |
|---|---|---|---|
| Enter | both | input has text | commits new tag chip and clears input |
| Backspace | both | input empty and tags present | removes last tag chip |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | delegatesFocus: true with zero host internals.role (ADR-014). | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| keyboard | Implements all 2 APG keyboard transitions across LTR/RTL. | mth-tag-input.spec.test.ts |
| states | Exposes ElementInternals CustomStateSet flags: :state(dirty), :state(touched), :state(user-invalid), :state(disabled), :state(required). | Conformance suite |
| i18n | Routes 4 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |