Skip to content

Repository files navigation

ReactFieldTag

React library for tag inputs

NPMJavaScript Style Guide

Install

npm install --save react-field-tag

Usage

importReactfrom'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

Demo

Demo

Table of contents

StyleClasses

Type declaration

NameTypeDescription
root?stringstyle class for the whole input and tag container
input?stringstyle class for input
tags?stringstyle class for tags container
tag?stringstyle class for tag(s)

ReactFieldTagProps

Type declaration

NameTypeDescriptionDefault
tagsArray of stringan array of tags-
delimiter?stringdetermines a point at which the string separates into tags,
classes?StyleClassesstyle classes for styling-
closeIcon?ReactElementelement to be used as close iconx (close icon from icons8)
onAddfunctiona callback function called when a new tag is to be added-
onDeletefunctiona callback function called on deleting a tag-

License

MIT © iamdipanshusingh

Releases

Packages

Used by

Contributors

Languages