React library for tag inputs
npm install --save react-field-tagimportReactfrom'react'importReactFieldTagfrom'react-field-tag'/// add below line to use default stylingimport'react-field-tag/dist/index.css'constApp=()=>{const[tags,setTags]=React.useState<Array<string>>([]);constonAdd=(tag: string)=>{setTags([...tags,tag]);}constonDelete=(index: number)=>{setTags(tags.filter((_,i)=>i!==index));}return<ReactFieldTagtags={tags}onAdd={onAdd}onDelete={onDelete}/>}exportdefaultApp| Name | Type | Description |
|---|---|---|
root? | string | style class for the whole input and tag container |
input? | string | style class for input |
tags? | string | style class for tags container |
tag? | string | style class for tag(s) |
| Name | Type | Description | Default |
|---|---|---|---|
tags | Array of string | an array of tags | - |
delimiter? | string | determines a point at which the string separates into tags | , |
classes? | StyleClasses | style classes for styling | - |
closeIcon? | ReactElement | element to be used as close icon | x (close icon from icons8) |
onAdd | function | a callback function called when a new tag is to be added | - |
onDelete | function | a callback function called on deleting a tag | - |
MIT © iamdipanshusingh
