DOCS
v0.4

Components / Tag Input

Tag Input

Chip-based multi-value input. Type + Enter (or comma) to add tags · Backspace on empty input removes the last tag. Pill chips with subtle border + soft hover · screen-reader live announcements · error/success states.

formsv0.7.0

Playground

Examples

Pre-filled chips
<cg-tag-input label="Skills" placeholder="Type a skill, press Enter…" helper="Hover a chip to see the soft bg shift · click × to remove" style="max-width:480px;"></cg-tag-input>
Empty — start typing
<cg-tag-input label="Tags" placeholder="Type and press Enter or comma" helper="Backspace on empty input removes the last tag" style="max-width:480px;"></cg-tag-input>
Max 3 (try adding a 4th)
<cg-tag-input label="Top tags" placeholder="Max 3 tags…" max="3" helper="Live region announces the limit" style="max-width:480px;"></cg-tag-input>
Error state
<cg-tag-input label="Tags (required)" placeholder="Add a tag…" error helper="At least one tag is required" style="max-width:480px;"></cg-tag-input>
Success state
<cg-tag-input label="Tags" placeholder="Add a tag…" success helper="Looks good!" style="max-width:480px;"></cg-tag-input>
Sizes (md / lg)
<div style="display:flex;flex-direction:column;gap:16px;max-width:480px;"><cg-tag-input label="Medium (default)" placeholder="Add a tag…" size="md"></cg-tag-input><cg-tag-input label="Large" placeholder="Add a tag…" size="lg"></cg-tag-input></div>
Email recipients
<cg-tag-input label="To" placeholder="Enter email addresses…" helper="Press Enter or comma after each email" size="lg" style="max-width:480px;"></cg-tag-input>
GitHub-style topics
<cg-tag-input label="Repository topics" placeholder="Add a topic…" max="6" helper="Up to 6 topics" style="max-width:480px;"></cg-tag-input>
Disabled
<cg-tag-input label="Locked tags" disabled style="max-width:480px;"></cg-tag-input>

Import

import { CgTagInput } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-tag-input';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
valuestring[][]Current tags
labelstring""Label text
placeholderstring""Input placeholder
helperstring""Helper text below the field
delimiterstring","Delimiter to split tags
maxnumber0Maximum tags (0 = unlimited)
allow-duplicatesbooleanfalseAllow duplicate tags
errorbooleanfalseError state
successbooleanfalseSuccess state
disabledbooleanfalseDisabled state
size"md" | "lg""md"Field size

Events

EventDetailDescription
cg-tag-add{value: string[], tag: string}Tag added
cg-tag-remove{value: string[], tag: string}Tag removed
cg-tag-change{value: string[]}Tags changed