1.0.0 • Published 5 years ago
react-tags-awesome v1.0.0
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
| Property | Description | Required | Type | Default |
|---|---|---|---|---|
| tags | Render list | true | Array | [] |
| className | Tags class name | false | String | - |
| onBeforeClose | Determine whether current tag can be closed by return value. | false | Function | return true |
| onClose | Triggered after tag closed. | false | Function | - |
| clearAll | Determine whether show clear all link. | false | Boolean | true |
| closable | Determine whether show close icon in each tag component. | false | Boolean | true |
tags Item ( each item is object )
| Params | Description | Required | Type | Default |
|---|---|---|---|---|
| name | Tag name. | true | String | - |
| className | Tag class name | false | String | - |
| closable | Determine whether current tag has close icon. | false | Boolean | true |
| visible | Determine current tag visible. | false | Boolean | true |
| restProps | Current tag style. | false | object | {} |
Tag Component
| Params | Description | Required | Type | Default |
|---|---|---|---|---|
| name | Tag name. | true | String | - |
| className | Tag class name | false | String | - |
| closable | Determine whether current tag has close icon. | false | Boolean | true |
| visible | Determine current tag visible. | false | Boolean | true |
| restProps | Current tag style. | false | object | {} |
1.0.0
5 years ago