Tag Input

A multi-tag input built on Combobox with chips, free entry, CSV paste, and predefined options.

Overview

TagInput lets users add, remove, and select multiple tags. It supports predefined options, free-typed tags via Enter/comma, CSV/TSV/newline pasting, and backspace-to-remove on an empty input.

Usage

import { TagInput } from "@tilt-legal/cubitt-components/primitives";

const options = [
  { id: "react", label: "React" },
  { id: "ts", label: "TypeScript" },
  { id: "ui", label: "UI/UX" },
];

export default function Component() {
  return <TagInput options={options} placeholder="e.g. TypeScript" />;
}

Examples

Default (predefined options)

Free entry + remove last on backspace

Paste CSV/TSV/newlines

Expanded field

Increase the field height when tags are likely to wrap across several rows or when you want a larger area to click and start typing.

URL State

API Reference

TagInput

PropTypeDefaultDescription
tags{ id: string; label: string }[]Controlled tags.
defaultTags{ id: string; label: string }[]Uncontrolled initial tags.
onTagsChange(next: Tag[]) => voidChange handler for controlled usage.
options{ id: string; label: string }[]Predefined selectable options.
variant"sm" | "md" | "lg""md"Size variant.
placeholderstringPlaceholder for the input.
classNamestringAdditional className for the wrapper.
inputPropsInputHTMLAttributes<HTMLInputElement>Forward id/name/aria/blur to the inner input.
allowDuplicatesbooleanfalseAllow duplicate tag labels.
enableExcelPastebooleantrueSplit pasted CSV/TSV/newlines into tags.
enableCommaDelimiterbooleantrueComma key creates a tag.
pasteDelimitersstring[][",", "\n", "\r\n", "\t"]Delimiters used when splitting pasted text.

URL State Props

When paramName is provided, TagInput syncs its tags to a string[] URL parameter via TanStack Router search params.

PropTypeDefaultDescription
paramNamestringURL parameter name to sync. Enables URL state management.
onUrlValueChange(value: string[]|null) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when value equals default.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

On this page