InputTags
A field that turns typed values into removable tags; each tag posts as its own entry.
On this page
Examples
Tags
Press Enter or comma to add, Backspace to remove. Three at most.
Tags: blazor | tailwind
Razor
<div class="flex w-full max-w-sm flex-col gap-3">
<KlyFormField Label="Topics" Help="Press Enter or comma to add, Backspace to remove. Three at most.">
<KlyInputTags @bind-Value="_tags" Max="3" Placeholder="Add a topic" />
</KlyFormField>
<p class="text-sm text-(--klyroo-text-muted)" data-testid="tags-state">Tags: @(_tags.Count > 0 ? string.Join(" | ", _tags) : "none")</p>
</div>
@code {
private IReadOnlyList<string> _tags = ["blazor", "tailwind"];
}Not bound
Without a binding the browser keeps the tags.
Razor
<div class="flex w-full max-w-sm flex-col gap-3">
<KlyFormField Label="Skills">
<KlyInputTags Value="@(["svelte"])" Name="skills" Placeholder="Add a skill" />
</KlyFormField>
</div>API
KlyInputTags
Input that turns each entered text into a removable tag and binds to the list of tags.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Color |
KlyColor |
"primary" |
Semantic color of the control: a built-in KlyColor or the name of a color you defined. When not set, Color applies, else primary. Values: primary, secondary, success, info, warning, error, neutral. |
Disabled |
bool |
false |
Disables the control: it cannot be focused or changed and is not submitted. |
Id |
string |
The id of the native control. Defaults to the one of the enclosing KlyFormField , else a generated one. | |
Max |
int |
0 |
Most tags allowed. Past it, typed text is ignored. Zero means no limit. |
Name |
string |
Form field name outside an EditForm . Inside one, the name comes from the bound expression. | |
Placeholder |
string |
Hint shown while no text is being typed. | |
Required |
bool |
false |
Marks the control as required, for the browser and for assistive technology. |
Size |
KlySize? |
Defaults to the size of the enclosing KlyFormField , or medium. Values: Xs, Sm, Md, Lg, Xl. |
|
Ui |
InputTagsUi |
Per-instance class overrides of the slots of the input tags, see InputTagsUi . They are merged after the theme and the Class parameter wins on the root slot. | |
Value (@bind-Value) |
IReadOnlyList |
The value of the control. Bind it with @bind-Value . | |
ValueExpression |
Expression |
The expression of the bound field. The compiler sets it with @bind-Value , and validation uses it to find the field. | |
Variant |
FieldVariant |
FieldVariant. |
Look of the field: Outline , Soft , Subtle , Ghost or None . Values: Outline, Soft, Subtle, Ghost, None. |
Ui slots
Ui takes a InputTagsUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Root |
Classes merged into the root slot of KlyInputTags , after the theme and the app configuration. |
Tags |
Classes merged into the tags slot of KlyInputTags , after the theme and the app configuration. |
Tag |
Classes merged into the tag slot of KlyInputTags , after the theme and the app configuration. |
Remove |
Classes merged into the remove slot of KlyInputTags , after the theme and the app configuration. |
Input |
Classes merged into the input slot of KlyInputTags , after the theme and the app configuration. |