TagInput

Enter or comma adds a tag. Tags pop in and out and the rest reflow. Inputs.

Open playground
MotionReact

About

TagInput is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { TagInput } from "@ashutoshswamy/smoui" and set label, value, onChange among its 4 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { TagInput } from "@ashutoshswamy/smoui";

<TagInput label="Skills" defaultValue={["Motion"]} onChange={(tags) => save(tags)} />

Props 4

label

Accessible name.

string
value / defaultValue

Controlled or initial tags.

string[]
onChange

Called on add or remove. Backspace removes the last.

(tags: string[]) => void
placeholder

Shown while empty.

stringdefault "Add a tag"