Tag Input

The Tag Input component allows a user to select a list of tags. Options can be specified by the developer or, if allowed, created by the user (dropdown variant only).

The component consists of an input area consisting of a tag area and a search field and, depending on the variant, a dropdown list or a table underneath the input. The tag area displays all currently selected tags and allows the user to remove tags. The search field allows users to filter the displayed options and eventually to create new tags.

In the dropdown variant the dropdown displays help text and all selectable options. The table variant allows to display more data, for instance people's names, email and role.

Properties Examples Events Accessibility Notes

* Required property

label *
A description for the Tag Input. Required even if the label-position is set to none (for accessibility reasons).
Sets the info text displayed under the component.
top | left | none
Defaults to top. Set to none if no label should be displayed.
The maximum number of tags that can be selected.
Sets the placeholder text present in the search field. Defaults to the following possibilities depending on component configuration: Add a new tag, Search and select a tag, or Add or search for a tag
string: csv
A comma-separated string of all tags that will load as pre-selected. In the dropdown variant, this is the option text itself. In the table variant, list the id of each <wm-tag-input-table-row>
dropdown | table
Sets the variant of the component. Defaults to dropdown.

Dropdown variant

Determines the user's ability to add new tags. Defaults to true.
Sets the maximum character limit for the search field. Defaults to 50.
string: csv
A comma-separated list of all options that populate the dropdown.

Table variant

col-headers *
string: csv
A comma-separated list of the table headers. The number of items determines the number of columns.
string: csv
A comma-separated list of the widths of the columns. If a value is left blank, the column will fill the remaining space.
string: csv
A comma-separated list for the text wrapping rule for each column. Can be either "wrap" or "trunc" (truncate). Defaults to "wrap" (so if the property is absent all columns' text will wrap). If provided less values than there are columns, the last columns will wrap (so "trunc" is equivalent to "trunc, wrap, wrap, wrap" if 4 columns have been specified)

For wm-tag-input-table-row

id *
Unique id. Pass this reference to wm-tag-input's selected-tags to preselect rows.
col1 | col2 | col3 | col4
Values for each column.
Disables the table row (displays a lock icon on the tag and on the row).

Usage in HTML

Edit the code below to see changes reflected in the example above.

Usage in Elm

Code generated from HTML.

Emitted when the selected tags have changed. The event.detail is an object containing two keys: value is all the currently selected tags, and tagChanged is the tag which triggered the event. For the dropdown variant, tags are represented by their exact string. For the table variant, tags are represented a reference to the corresponding wm-tag-input-row.

Keyboard Support

Tag Area

Key Function
Left Arrow Right Arrow Navigate through the tag list.
Backspace Delete Remove the currently focused tag. If this tag was added by the user, removes the corresponding list item from the dropdown.

Search Field

Key Function
Down Arrow Up Arrow If the dropdown is closed, re-opens it. If the dropdown is open, begin navigating the dropdown. If the first list item is reached, Up will focus the search field.
Escape If the dropdown is open, closes it.
Key Function
Up Arrow Down Arrow Navigate through the list items.
Escape Stops navigating the dropdown and returns focus to the search field.


Key Function
Up Arrow Down Arrow Navigate through the table rows.
Left Arrow Right Arrow Navigate through the row's cells.
  • The component consists of two tab stops, the tag area and the search field. If no tags are selected only the search field will be present.
  • Duplicate tags cannot be added when using the dropdown variant.
  • The dropdown list items are sorted alphabetically.
  • If a user-added tag is removed, its corresponding list item will be removed as well.

In a compound component like Select or Action Menu, child components are rendered in the parent's slot element, part of its shadow DOM tree. Slots essentially serve as a placeholder for markup that you the developer define in the light DOM tree, like <wm-menuitem>, <wm-option>, text content, or other child elements.

The browser distributes the child elements defined in the light DOM into the shadow DOM of the parent. The result is a flattened DOM tree—a merger of the the light DOM and the shadow DOM. This flattened tree is what you see in DevTools and what is rendered on the page.

With the standard implementation of the component, dynamically updating the child items will throw an error. Elm's efficient diffing of the DOM will register that only the child items have changed and try to update them, but the component has already been composed.

Rendering the component in a Keyed node and giving it a dynamic id will cause the entire component, rather than just the child items, to render anew, avoiding the error.