Skip to content

Tag Composer

Editable tags collect inside a softly framed input with individual remove controls.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import TagComposer from "./TagComposer";
export default function Example() {
return (
<TagComposer
defaultValue={[
"Typography",
"Motion"
]}
label={"Project tags"}
placeholder={"Add a tag"}
maxTags={6}
color={"#a8bec7"}
disabled={false}
/>
);
}

Using Tag Composer

Press Enter or a comma to add a trimmed tag. Exact duplicates are ignored, and composition input is left alone until the composition is complete.

Backspace on an empty input removes the last tag and Escape clears the draft. Use value and onValueChange for controlled state; maxTags stops additions while keeping existing tags removable.

Props

NameTypeRequiredDefaultDescription
valuestring[]NoundefinedControlled list of tags.
defaultValuestring[]No[]Initial uncontrolled tags.
onValueChangefunctionNoundefinedReceives the complete next tag list.
labelstringNo"Tags"Visible input label.
placeholderstringNo"Add a tag"Placeholder while more tags can be added.
removeLabelfunctionNoundefinedReceives a tag and returns its remove-button label.
maxTagsnumberNo8Maximum tag count, with a minimum of one.
disabledbooleanNofalseDisable input and removal.
colorstringNo"#a8bec7"Accent and focus colour.
namestringNoundefinedOptional repeated hidden field name for form submission.
classNamestringNo""Additional classes on the root element.
styleCSSPropertiesNoundefinedInline styles for sizing, typography and appearance.

Related components

A recessed password field pairs a reveal control with an optional strength indicator.

A recessed search field expands into a polished capsule as you type.

Faceted stars lift into selection with a small marker beneath the chosen rating.

A bank of tactile keys holds independent selections with illuminated indicators.