Tag Input
kumo-svelte
ava@cloudflare.com
Paste comma- or newline-separated email addresses.
<script lang="ts">
  import { TagInput } from 'kumo-svelte';
  let recipients = $state(['ava@cloudflare.com']);
</script>

<TagInput
  label="Recipients"
  description="Paste comma- or newline-separated email addresses."
  placeholder="name@example.com"
  bind:value={recipients}
  validateValue={(value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)}
/>

Installation

import { TagInput } from 'kumo-svelte';

Usage

Use bind:value for controlled tags or defaultValue for uncontrolled usage. Press Enter, comma, or Tab to create a tag. Blur also commits the current value, and pasted comma- or newline-separated text creates each value synchronously. Duplicate values are ignored.

<TagInput label="Labels" bind:value={tags} placeholder="Add a label" />

Maximum values

alpha
A maximum of three groups.
<script lang="ts">
  import { TagInput } from 'kumo-svelte';
</script>

<TagInput
  defaultValue={['alpha']}
  label="Access groups"
  maxValues={3}
  description="A maximum of three groups."
  placeholder="Type a group name"
/>

Localization

Use labels to translate the fallback input name, tag removal action, invalid-value feedback, and maximum-value feedback.

API Reference

PropTypeDefaultDescription
readOnly booleanfalsePrevents additions/removals while retaining focus and form submission. Also accepts the native readonly alias.
name string-Submits each accepted tag as a separate form value; the draft is unnamed.
form string-Associates the draft and accepted values with an external form ID.
required boolean-Requires an accepted tag. Native read-only validation rules apply.
value string[]-Controlled tag values.
defaultValue string[][]Initial uncontrolled tag values.
onValueChange (value: string[]) => void-Called whenever the tag list changes.
validateValue (value: string, acceptedValues: string[]) => boolean-Validates each candidate tag.
maxValues number-Maximum accepted tag count.
labels TagInputLabels-Localized generated labels and validation messages.
label string | Snippet-Visible label content.
description string | Snippet-Supporting description text.
error TagInputError-Validation error content.
disabled booleanfalseDisables entry and tag removal.

readOnly prevents tag edits/removal while keeping focus and form submission. name submits each accepted tag separately; the draft has no name. Use form for an external form. required requires an accepted tag, and is skipped for read-only inputs. Pasting separators merges text at the draft selection.