Skip to content

Inputs

TagsInput

Bit.BlazorUIChipsTokens

The TagsInput turns free text into a list of short values: the user types a tag, confirms it with Enter (or with a separator of your own), and it becomes a removable chip in front of the input. It binds to a collection of strings, offers known values through the browser's own suggestion list - or accepts nothing else - splits a pasted list into a tag each, and keeps the entries in shape on the way in: trimming, transforming, capping their length and their number, and rejecting the ones that repeat, that are too short, that fail a pattern or that a validator turns down, each rejection reported with the rule that caused it. The chips form a proper accessible list: one stop of the tab order that the arrow keys walk through, removable with Delete, correctable in place, movable by drag, by two taps on the handle a chip grows or with Alt and the arrows, with the ones a predicate pins in place carrying no dismiss button at all, and with every change announced to screen readers. It comes in three sizes, three variants and the whole accent palette, folds a long list away behind a chip, carries a label, a helper text, a prefix, a suffix, a counter, a clear button and a spinner for the suggestions it is still fetching, can be driven entirely from code, and takes part in an EditForm like any other input.

Overview

Adding and removing tags, the label and description, the field and tag variants, and separators that split typing and pasting.

Basic

Type a word and press Enter: it becomes a chip, and its dismiss button takes it back off. Placeholder is the hint shown while the list is still empty; once there is a tag it would only compete with the chips for the width of the field, so it is dropped unless a TagsPlaceholder keeps the invitation visible. ReadOnly keeps the tags visible and navigable while refusing every change, and Disabled dims the whole field along with them.

blazor
1 tags.
Tag 1
Tag 2
2 tags.
Tag 1
Tag 2
2 tags.

Label & description

Label renders the caption above the field and ties it to the input, so clicking it puts the caret in there. With the inherited Required it carries the asterisk that marks the field as mandatory. Description renders a hint under the field which the input references through aria-describedby, so it is announced along with the field rather than only drawn - which is where the rules of the field belong. LabelTemplate and DescriptionTemplate take markup instead of a string.

Press Enter after each skill. Up to 5 of them.
Separate the addresses with a comma or a semicolon.

Variants

Variant decides how much of a frame the field carries - Outline (the default), Fill or only an underline with Text - and NoBorder removes it altogether. TagVariant decides how much of the color the chips are painted with, exactly as a BitTag is. The two are independent, so they combine freely.

blazor
dotnet
2 tags.
blazor
dotnet
2 tags.
blazor
dotnet
2 tags.
blazor
dotnet
2 tags.

Separators & pasting

By default only Enter turns the typed text into a tag. Separators adds characters that do the same: typing one commits what stands before it, and the character itself never reaches the input. A separator is any string - a comma, a space, or something longer such as ", ". The same separators split a paste, so a comma separated list arrives as a whole row of tags, each piece going through the same validation. A paste spread over several lines is joined over the first separator on its way in, so a column copied out of a spreadsheet does not land as one run-on tag.

Try pasting: red,green;blue - or a column copied out of a spreadsheet.

Topics

Everything else about TagsInput, one page per topic.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.