inputshwcz-input-tag

Tag Input

Token input that turns typed text into removable, editable tags, with validation, slugify, and duplicate control.

Attributes

AttributeTypeDefaultDescription
maxlengthnumber20Maximum characters per tag (default 20).
minlengthnumber1Minimum characters per tag (default 1).
slugifybooleanfalseSlugifies tag values (lowercase, hyphenated) before committing.
slugify-optionsstring''JSON options passed to the slugify helper (e.g. replacement characters).
delimitersstring','Characters that commit the current text as a tag (default ,).
allow-duplicatesbooleanfalseAllows the same tag more than once.
max-tagsnumber0Maximum number of tags (0 = unlimited).
add-on-blurbooleantrueCommits the pending text as a tag when the input loses focus (default true).
Inherited from InputMixin
AttributeTypeDefaultDescription
disabledbooleanfalseDisables the control so it cannot be interacted with.
formstring''Associates the hidden form input with a form by id, even when the component sits outside that form.
namestring''Field name for the hidden form input; array values submit as name[].
placeholderstring''Placeholder text for the control's empty state.
requiredbooleanfalseMarks the control as required.
valuestring''Initial value of the control, synchronized with the hidden form input.
Inherited from Hwc
AttributeTypeDefaultDescription
i18nstring''Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults.
floatingstring''Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs.
force-prevent-rerenderbooleanfalseSkips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM.
templatestring''Selector or id of an external element or <template> whose inner content is cloned in place of an inline template[data-fn="template"] child.
Inherited from Base
AttributeTypeDefaultDescription
clsstring''Adds classes to named parts as key: classes pairs; a plain string targets the default part.
stlstring''Adds inline styles to named parts as key: styles pairs; a plain string targets the default part.

Custom Styling (cls / stl)

Default cls target:wrapper · defaultstl target:wrapper

KeyDefault classclsstlDescription
errorsr-onlyyesyesValidation message region (default sr-only).
host-inner—yesyesRendered root wrapper.
input—yesyesThe text input for new tags.
tagz-tag z-tag-secondaryyesnoOne tag chip (default z-tag z-tag-secondary).
tag-listz-input-tag-listyesyesList of committed tags (default z-input-tag-list).
tag-remove—yesnoTag remove button.
tag-text—yesnoTag label, click to edit (button role).
wrapperz-input-tagyesyesThe tag field wrapper (default z-input-tag); the default cls/stl target.

CSS Variables

VariableDefaultScopeDescription
--z-input-tag-border-colorvar(--z-input).z-input-tagBorder base color, mixed with transparency using --z-input-tag-border-color-o.
--z-input-tag-border-color-ovar(--z-input-o).z-input-tagBorder opacity percentage used in the border color mix.
--z-input-tag-border-width1px.z-input-tagBorder width of the tag field.
--z-input-tag-focus-ring-colorvar(--z-focus).z-input-tagFocus ring base color, mixed with transparency using --z-input-tag-focus-ring-color-o.
--z-input-tag-focus-ring-color-o100%.z-input-tagFocus ring opacity percentage used in the mix.
--z-input-tag-gap0.25rem.z-input-tagGap between the tag list and the input.
--z-input-tag-input-colorvar(--z-bg-f).z-input-tag inputText base color of the inner input, mixed with transparency using --z-input-tag-input-color-o.
--z-input-tag-input-color-o100%.z-input-tag inputText opacity percentage used in the input color mix.
--z-input-tag-input-min-height1.75rem.z-input-tag inputMinimum height of the inner text input.
--z-input-tag-input-padding0 0.25rem.z-input-tag inputPadding of the inner text input.
--z-input-tag-list-gap · hook0.25rem.z-input-tag-listGap between tag chips.
--z-input-tag-min-height2.5rem.z-input-tagMinimum height of the tag field.
--z-input-tag-padding0.5rem.z-input-tagInner padding of the tag field.
--z-input-tag-radiusvar(--z-form-input-radius).z-input-tagCorner radius of the tag field.
--z-input-tag-shadowvar(--z-form-input-shadow).z-input-tagBox shadow of the tag field.

i18n Keys

KeyDefaultPlaceholdersDescription
duplicate-errorTag already exists—Error shown for a duplicate tag.
edit-labelEdit tag—Prefix of the edit-tag button label. Used in: tag-text.
input-labelTag input—Accessible label of the tag input. Used in: input.
max-length-errorTag cannot exceed {max} charactersmaxError template with {max} for too-long tags.
max-tags-errorMaximum {max} tags allowedmaxError template with {max} when the tag limit is reached.
min-length-errorTag must be at least {min} charactersminError template with {min} for too-short tags.
placeholderAdd a tag...—Placeholder of the tag input. Used in: input.
remove-labelRemove tag—Prefix of the remove-tag button label. Used in: tag-remove.
tag-list-labelTags—Accessible label of the tag list. Used in: tag-list.

Events

EventDetailFlagsDescription
z-input-tag:input · from InputMixin{ value: string | string[] }bubblesFires when the tag list changes; detail.value carries the tags as a string array.

Data Hooks

AttributeValuesApplies toRoleDescription
data-disabled—descendantmarkerSet on the wrapper while the control is disabled.
data-has-error—descendantmarkerSet on the wrapper while a validation error is shown.
data-host-inner · from Hwc—descendantconfigMarks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering.
data-reactive · from Hwc—descendantconfigOpts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates.
data-tag-index—descendantmarkerSet by the component on each tag to its index.

Child Content

script[data-fn="config"][type="application/json"]

JSON configuration script parsed by the base class (i18n, cls, stl, floating).

AttributeRequiredTypeDescription
data-fnyesconfigMarks the script as configuration (value: config).
data-reactivenobooleanRe-parses the configuration when the script mutates.

select[data-fn="data-source"]

Hidden select parsed into grouped option data by the base class.

AttributeRequiredTypeDescription
data-fnyesdata-sourceMarks the select as the data source (value: data-source).
data-reactivenobooleanRe-parses the options when the select mutates.

optgroup · repeatable

Groups options under a label.

AttributeRequiredTypeDescription
labelyesstringGroup header text; also the default group key.
disablednobooleanDisables every option in the group.
data-keynostringOverrides the group key used in the parsed data.
data-keywordsnocomma-separated stringComma-separated keywords stored with the group's data.

option · repeatable

One option entry within the group.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated; searched alongside the label and value.

option · repeatable

One ungrouped option entry.

AttributeRequiredTypeDescription
valuenostringValue carried by this option in the parsed data.
disablednobooleanMakes the option non-selectable.
selectednobooleanMarks the option as initially selected.
data-keywordsnocomma-separated stringExtra search terms, comma-separated.

template[data-fn="icons"]

Instance-level icon repository.

AttributeRequiredTypeDescription
data-fnyesiconsMarks the template as an icon source (value: icons).
data-reactivenobooleanRe-parses the icons when the template mutates.

* · repeatable

One icon element.

AttributeRequiredTypeDescription
data-keyyesstringIcon key referenced by $icons.

template[data-fn="template"]

Deferred content template mounted by the base class.

AttributeRequiredTypeDescription
data-fnyestemplateMarks the template for deferred mounting (value: template).
data-reactivenobooleanRe-parses the template when it mutates.

CSS Classes

ClassRoleApplies toDescription
.z-input-tagrootz-input-tagRoot class of the tag field.
.z-input-tag-liststate.z-input-tagThe flex list of tag chips.

Keyboard

KeysActionWhen
EnterCommits the pending text as a tag.—
BackspaceRemoves the last tag when the input is empty.The input is empty.

Accessibility

PartARIADescription
erroraria-live="polite" role="alert"Validation message: role="alert" with aria-live="polite".
host-inner—Root wrapper; no ARIA attributes.
inputaria-describedby="${this.$error ? 'tag-error' : ''}" aria-invalid="${!!this.$error}" aria-label="${inputLabel}" role="textbox"Text input: role="textbox" labeled by input-label, aria-invalid and aria-describedby point at the error while invalid.
tagrole="listitem"Tag chip: role="listitem".
tag-listaria-label="${tagListLabel}" role="list"Tag list: role="list" labeled by tag-list-label.
tag-removearia-label="${removeLabel}: ${tag}"Remove button labeled remove-label: <tag>.
tag-textaria-label="${editLabel}: ${tag}" role="button"Tag label: role="button" labeled edit-label: <tag>.
wrapper—Tag field wrapper; no ARIA attributes.
  • Validation errors are announced through the alert region and linked to the input with aria-describedby.
  • The value submits through hidden inputs named name[].