DocsComponentsTemplatesThemesGitHub

TagInput

Multi-value input: type and press Enter or comma to add tags, Backspace to remove; optional suggestions, max and allowCustom.

Code

import * as React from 'react';
import { TagInput } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        maxWidth: 420,
        minHeight: 260,
      }}
    >
      <TagInput
        label="Skills"
        defaultValue={['React', 'Figma']}
        defaultQuery="Ty"
        defaultOpen
        suggestions={['TypeScript', 'Typography', 'Testing', 'Swift', 'Python']}
        max={8}
      />
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { TagInput } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/tag-input.json

Guidelines

  • Use for keywords, emails, skills. With suggestions, matching options appear as you type.
  • allowCustom={false} restricts to suggestions; max caps the count.

Props

PropTypeRequired
defaultQuerystringNo
valuestring[]No
defaultValuestring[]No
onChange(tags: string[]) => voidNo
suggestionsArray<string | SelectOption>No
allowCustombooleanNo
maxnumberNo
limitnumberNo
labelstringNo
hintReact.ReactNodeNo
errorReact.ReactNodeNo
requiredbooleanNo
placeholderstringNo
iconstringNo
size'sm' | 'md'No
defaultOpenbooleanNo
classNamestringNo
styleReact.CSSPropertiesNo

Edit this example on GitHub