TagInput

Input that splits typed text into removable tag pills. Enter / comma to commit (custom separators supported), Backspace on empty input peels the last tag, optional validator rejects bad entries.

designmotiontokens

Press Enter or comma to commit · Backspace on empty input to peel the last tag · Up to 6 tags allowed in this demo.

Usage

import { TagInput } from '@bwo-ui/react';

const [tags, setTags] = useState<string[]>([]);

<TagInput
  value={tags}
  onValueChange={setTags}
  placeholder="Add a tag…"
  max={10}
  validate={(t) => t.length >= 2 || 'Tag too short'}
/>

Props

PropTypeDefaultDescription
valuestring[]Controlled tag list.
defaultValuestring[][]Uncontrolled default.
onValueChange(tags: string[]) => voidFires whenever the list changes.
placeholderstring'Add a tag…'Input placeholder.
separatorsstring[]['Enter', ',']Keys that finalise a tag.
maxnumberMaximum number of tags.
validate(tag: string) => string | trueCustom validator. Return string to reject with that reason.
renderTag(tag, remove) => ReactNodeOverride the pill render.