npm.io
0.0.5 • Published 6 years ago

tags-input-react

Licence
MIT
Version
0.0.5
Deps
4
Size
80 kB
Vulns
0
Weekly
0
Stars
1

tags-input-react

Tags Input Component

How to Install

Make sure you have Node.js and NPM installed.

npm install tags-input-react

Demo

Check demo online here.

How to Use

import React, { Component } from 'react'
import TagsInput from 'tags-input-react'

class TagsInputDemo extends Component {
  constructor() {
    super()
    this.state = {
      tags: []
    }
    this.handleOnChange = this.handleOnChange.bind(this)
  }

  handleOnChange (tags, value) {
    this.setState({
      tags
    })
  }

  render() {
    return (
      <TagsInput
        placeholder='Type here...'
        onChange={this.handleOnChange}
      />
    )
  }
}

Available PropTypes

Prop Name Type Default Value Description
tags array [] Array of tags for Pre-populate in Input
preventDuplicates Boolean true Preventing duplicates in tags
placeholder string 'Type here' Placeholder in input
onChange Function null Callback function to get the tags created by user

Keywords