Skip to content
v0.2.10

TagInput

Free-form text tokens with keyboard entry, removal and named form values.

Preview
DesignReact
Design, React

Use TagInput

TagInput is a named export of @flood-md/react. Connect the package once, then import what you use.

First time here? Connect Flood
Example import style
tag-input.tsxTSX
"use client";

import { FloodRoot, TagInput } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <TagInput label="Topics" defaultValue={["Design", "React"]} name="topics" placeholder="Add a topic…" />
    </FloodRoot>
  );
}

Design notes

  • Use TagInput for values the user may create. Use MultiSelect for a fixed option collection.
  • Enter and configured delimiters commit trimmed, unique tags. Pasting separated text adds multiple tags. IME composition is preserved.
  • Each committed tag submits one entry under name. required applies to committed tags; a draft is not a submitted token. Form reset preserves controlled ownership.
  • Backspace on an empty draft removes the last token. Read only preserves copying and form values; disabled omits submission and removal. Introduced in 0.2.7.

API reference

PropValuesDefault
status"error" | "warning" | "success" | "info"—
invalidboolean—
controlSize"sm" | "md" | "lg" | "xl""md"
labelstringRequired
hideLabelbooleanfalse
valuereadonly string[]—
defaultValuereadonly string[]—
onValueChange(value: string[]) => void—
delimitersreadonly string[]—
removeLabelstring"Remove"
requiredMessagestring"Add at least one tag."
Native HTML propsOmit<InputHTMLAttributes<HTMLInputElement>, "type" | "value" | "defaultValue" | "onChange" | "children" | "size">Forwarded
View TypeScript source