1.0.0 • Published 4 years ago

react-tags-awesome v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

react-tags-awesome

Install

npm install react-tags-awesome

Introduce

Actually, There are two react components Tags and Tag, you can get the difference by it name obviously. you may custom these component style and we provide more configuration for you!

Example

import Tags, { Tag } from 'react-tags-awesome';
// const tags=['a','b','c'];  //It also support simple array
const tags=[
       {
        name:'test1',
        closable:false,
        visible:false,
        style:{
            background:'red',
            fontSize:'20px'
           }
       }
     ];

export default class App extends  React.Component{
    handleClose(closedItem,leftItems){

    }
    render() {
        return (
          <Fragment> 
            <Tags
               tags={tags}
                clearAll={false}
                closable={false}
                onClose={(closedItem,leftItems)=>this.handleClose(closedItem,leftItems)}
                onBeforeClose={(closedItem)=>{return false}}
            />
            <Tag  
                {...tags[0]}
                onClose={(closedItem,leftItems)=>this.handleClose(closedItem,leftItems)}
               />
          </Fragment>
        )
    }

};

Props

Tags Component

PropertyDescriptionRequiredTypeDefault
tagsRender listtrueArray[]
classNameTags class namefalseString-
onBeforeCloseDetermine whether current tag can be closed by return value.falseFunctionreturn true
onCloseTriggered after tag closed.falseFunction-
clearAllDetermine whether show clear all link.falseBooleantrue
closableDetermine whether show close icon in each tag component.falseBooleantrue
tags Item ( each item is object )
ParamsDescriptionRequiredTypeDefault
nameTag name.trueString-
classNameTag class namefalseString-
closableDetermine whether current tag has close icon.falseBooleantrue
visibleDetermine current tag visible.falseBooleantrue
restPropsCurrent tag style.falseobject{}

Tag Component

ParamsDescriptionRequiredTypeDefault
nameTag name.trueString-
classNameTag class namefalseString-
closableDetermine whether current tag has close icon.falseBooleantrue
visibleDetermine current tag visible.falseBooleantrue
restPropsCurrent tag style.falseobject{}