inputshwc
z-input-tagTag Input
Token input that turns typed text into removable, editable tags, with validation, slugify, and duplicate control.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
maxlength | number | 20 | Maximum characters per tag (default 20). |
minlength | number | 1 | Minimum characters per tag (default 1). |
slugify | boolean | false | Slugifies tag values (lowercase, hyphenated) before committing. |
slugify-options | string | '' | JSON options passed to the slugify helper (e.g. replacement characters). |
delimiters | string | ',' | Characters that commit the current text as a tag (default ,). |
allow-duplicates | boolean | false | Allows the same tag more than once. |
max-tags | number | 0 | Maximum number of tags (0 = unlimited). |
add-on-blur | boolean | true | Commits the pending text as a tag when the input loses focus (default true). |
Inherited from InputMixin
| Attribute | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | Disables the control so it cannot be interacted with. |
form | string | '' | Associates the hidden form input with a form by id, even when the component sits outside that form. |
name | string | '' | Field name for the hidden form input; array values submit as name[]. |
placeholder | string | '' | Placeholder text for the control's empty state. |
required | boolean | false | Marks the control as required. |
value | string | '' | Initial value of the control, synchronized with the hidden form input. |
Inherited from Hwc
| Attribute | Type | Default | Description |
|---|---|---|---|
i18n | string | '' | Per-instance text overrides as key: text pairs, merged over the global z-i18n script and the built-in defaults. |
floating | string | '' | Floating UI placement options (for example offset and shiftPadding) parsed as key: value pairs. |
force-prevent-rerender | boolean | false | Skips re-rendering after the first render; an existing data-host-inner child is adopted as the rendered DOM. |
template | string | '' | 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
| Attribute | Type | Default | Description |
|---|---|---|---|
cls | string | '' | Adds classes to named parts as key: classes pairs; a plain string targets the default part. |
stl | string | '' | 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
| Key | Default class | cls | stl | Description |
|---|---|---|---|---|
error | sr-only | yes | yes | Validation message region (default sr-only). |
host-inner | — | yes | yes | Rendered root wrapper. |
input | — | yes | yes | The text input for new tags. |
tag | z-tag z-tag-secondary | yes | no | One tag chip (default z-tag z-tag-secondary). |
tag-list | z-input-tag-list | yes | yes | List of committed tags (default z-input-tag-list). |
tag-remove | — | yes | no | Tag remove button. |
tag-text | — | yes | no | Tag label, click to edit (button role). |
wrapper | z-input-tag | yes | yes | The tag field wrapper (default z-input-tag); the default cls/stl target. |
CSS Variables
| Variable | Default | Scope | Description |
|---|---|---|---|
--z-input-tag-border-color | var(--z-input) | .z-input-tag | Border base color, mixed with transparency using --z-input-tag-border-color-o. |
--z-input-tag-border-color-o | var(--z-input-o) | .z-input-tag | Border opacity percentage used in the border color mix. |
--z-input-tag-border-width | 1px | .z-input-tag | Border width of the tag field. |
--z-input-tag-focus-ring-color | var(--z-focus) | .z-input-tag | Focus ring base color, mixed with transparency using --z-input-tag-focus-ring-color-o. |
--z-input-tag-focus-ring-color-o | 100% | .z-input-tag | Focus ring opacity percentage used in the mix. |
--z-input-tag-gap | 0.25rem | .z-input-tag | Gap between the tag list and the input. |
--z-input-tag-input-color | var(--z-bg-f) | .z-input-tag input | Text base color of the inner input, mixed with transparency using --z-input-tag-input-color-o. |
--z-input-tag-input-color-o | 100% | .z-input-tag input | Text opacity percentage used in the input color mix. |
--z-input-tag-input-min-height | 1.75rem | .z-input-tag input | Minimum height of the inner text input. |
--z-input-tag-input-padding | 0 0.25rem | .z-input-tag input | Padding of the inner text input. |
--z-input-tag-list-gap · hook | 0.25rem | .z-input-tag-list | Gap between tag chips. |
--z-input-tag-min-height | 2.5rem | .z-input-tag | Minimum height of the tag field. |
--z-input-tag-padding | 0.5rem | .z-input-tag | Inner padding of the tag field. |
--z-input-tag-radius | var(--z-form-input-radius) | .z-input-tag | Corner radius of the tag field. |
--z-input-tag-shadow | var(--z-form-input-shadow) | .z-input-tag | Box shadow of the tag field. |
i18n Keys
| Key | Default | Placeholders | Description |
|---|---|---|---|
duplicate-error | Tag already exists | — | Error shown for a duplicate tag. |
edit-label | Edit tag | — | Prefix of the edit-tag button label. Used in: tag-text. |
input-label | Tag input | — | Accessible label of the tag input. Used in: input. |
max-length-error | Tag cannot exceed {max} characters | max | Error template with {max} for too-long tags. |
max-tags-error | Maximum {max} tags allowed | max | Error template with {max} when the tag limit is reached. |
min-length-error | Tag must be at least {min} characters | min | Error template with {min} for too-short tags. |
placeholder | Add a tag... | — | Placeholder of the tag input. Used in: input. |
remove-label | Remove tag | — | Prefix of the remove-tag button label. Used in: tag-remove. |
tag-list-label | Tags | — | Accessible label of the tag list. Used in: tag-list. |
Events
| Event | Detail | Flags | Description |
|---|---|---|---|
z-input-tag:input · from InputMixin | { value: string | string[] } | bubbles | Fires when the tag list changes; detail.value carries the tags as a string array. |
Data Hooks
| Attribute | Values | Applies to | Role | Description |
|---|---|---|---|---|
data-disabled | — | descendant | marker | Set on the wrapper while the control is disabled. |
data-has-error | — | descendant | marker | Set on the wrapper while a validation error is shown. |
data-host-inner · from Hwc | — | descendant | config | Marks the rendered inner wrapper so force-prevent-rerender can adopt server-rendered DOM without re-rendering. |
data-reactive · from Hwc | — | descendant | config | Opts the marked child (config script, data source, icons, or template) into live re-parsing when its DOM mutates. |
data-tag-index | — | descendant | marker | Set 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).
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | config | Marks the script as configuration (value: config). |
data-reactive | no | boolean | Re-parses the configuration when the script mutates. |
select[data-fn="data-source"]
Hidden select parsed into grouped option data by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | data-source | Marks the select as the data source (value: data-source). |
data-reactive | no | boolean | Re-parses the options when the select mutates. |
optgroup · repeatable
Groups options under a label.
| Attribute | Required | Type | Description |
|---|---|---|---|
label | yes | string | Group header text; also the default group key. |
disabled | no | boolean | Disables every option in the group. |
data-key | no | string | Overrides the group key used in the parsed data. |
data-keywords | no | comma-separated string | Comma-separated keywords stored with the group's data. |
option · repeatable
One option entry within the group.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated; searched alongside the label and value. |
option · repeatable
One ungrouped option entry.
| Attribute | Required | Type | Description |
|---|---|---|---|
value | no | string | Value carried by this option in the parsed data. |
disabled | no | boolean | Makes the option non-selectable. |
selected | no | boolean | Marks the option as initially selected. |
data-keywords | no | comma-separated string | Extra search terms, comma-separated. |
template[data-fn="icons"]
Instance-level icon repository.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | icons | Marks the template as an icon source (value: icons). |
data-reactive | no | boolean | Re-parses the icons when the template mutates. |
* · repeatable
One icon element.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-key | yes | string | Icon key referenced by $icons. |
template[data-fn="template"]
Deferred content template mounted by the base class.
| Attribute | Required | Type | Description |
|---|---|---|---|
data-fn | yes | template | Marks the template for deferred mounting (value: template). |
data-reactive | no | boolean | Re-parses the template when it mutates. |
CSS Classes
| Class | Role | Applies to | Description |
|---|---|---|---|
.z-input-tag | root | z-input-tag | Root class of the tag field. |
.z-input-tag-list | state | .z-input-tag | The flex list of tag chips. |
Keyboard
| Keys | Action | When |
|---|---|---|
| Enter | Commits the pending text as a tag. | — |
| Backspace | Removes the last tag when the input is empty. | The input is empty. |
Accessibility
| Part | ARIA | Description |
|---|---|---|
error | aria-live="polite" role="alert" | Validation message: role="alert" with aria-live="polite". |
host-inner | — | Root wrapper; no ARIA attributes. |
input | aria-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. |
tag | role="listitem" | Tag chip: role="listitem". |
tag-list | aria-label="${tagListLabel}" role="list" | Tag list: role="list" labeled by tag-list-label. |
tag-remove | aria-label="${removeLabel}: ${tag}" | Remove button labeled remove-label: <tag>. |
tag-text | aria-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[].