nessra uinessra ui

Tag Input

An input for entering multiple tags with keyboard support.

Loading...
import { TagInput } from "@/components/ui/tag-input"

const frameworks = [

Installation

pnpmnpmyarnbun
pnpm dlx shadcn@latest add https://nessra-ui.vercel.app/r/tag-input.json

Usage

import { TagInput } from "@/components/ui/tag-input"
<TagInput defaultValue={["React", "TypeScript"]} />

Examples

Controlled

Control tags with value and onChange.

Loading...
"use client"

import * as React from "react"

Max Tags

Limit the number of tags with maxTags.

Loading...
import { TagInput } from "@/components/ui/tag-input"

export function TagInputMax() {

Disabled

Loading...
import { TagInput } from "@/components/ui/tag-input"

export function TagInputDisabled() {

API Reference

TagInput

PropTypeDefaultDescription
valuestring[]-Controlled value
defaultValuestring[][]Default value (uncontrolled)
onChange(value: string[]) => void-Called when tags change
suggestionsstring[][]List of autocomplete suggestions
placeholderstring"Add tag..."Placeholder text
disabledbooleanfalseDisable the input
maxTagsnumber-Maximum number of tags
allowDuplicatesbooleanfalseAllow duplicate tags
allowCustombooleantrueAllow custom tags not in suggestions
delimiterstring | RegExp/[,\n]/Delimiter to split input

Keyboard Navigation

KeyAction
EnterAdd highlighted suggestion or input
ArrowDownHighlight next suggestion
ArrowUpHighlight previous suggestion
EscapeClose suggestions dropdown
,Add current input as tag
BackspaceRemove last tag (when input empty)