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.jsonGuidelines
- Use for keywords, emails, skills. With
suggestions, matching options appear as you type. allowCustom={false}restricts to suggestions;maxcaps the count.
Props
| Prop | Type | Required |
|---|---|---|
defaultQuery | string | No |
value | string[] | No |
defaultValue | string[] | No |
onChange | (tags: string[]) => void | No |
suggestions | Array<string | SelectOption> | No |
allowCustom | boolean | No |
max | number | No |
limit | number | No |
label | string | No |
hint | React.ReactNode | No |
error | React.ReactNode | No |
required | boolean | No |
placeholder | string | No |
icon | string | No |
size | 'sm' | 'md' | No |
defaultOpen | boolean | No |
className | string | No |
style | React.CSSProperties | No |