1.1.1 • Published 3 years ago

react-simple-tags v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-simple-tags

A simple tags input component written in React.

NPM JavaScript Style Guide

Features

  • 🚀 Simple and lightweight (< 700 bytes when gzipped!)
  • ✅ Easy to use
  • 🎨 Customizable styles

Install

npm install --save react-simple-tags

Usage

import React from 'react'

import TagsInput from 'react-simple-tags'
import 'react-simple-tags/dist/index.css'

const App = () => {
  const [tagsList, setTagsList] = React.useState<string[]>([])

  const handleTagAddition = (tag: string) => {
    const newTagsList = tagsList.concat(tag)
    setTagsList(newTagsList)
  }

  const handleTagRemoval = (tagToBeRemoved: string) => {
    const newTagsList = tagsList.filter((tag) => tag !== tagToBeRemoved)
    setTagsList(newTagsList)
  }

  return (
    <TagsInput
      className='my-custom-tags'
      onTagAddition={handleTagAddition}
      onTagRemoval={handleTagRemoval}
    />
  )
}

export default App

Props

PropTypeRequired?Default value
maxTagLengthnumberno3
uniqueTagsbooleannotrue
classNamestringnoempty string
onTagAdditionfuncyesN/A
onTagRemovalfuncyesN/A

License

MIT © akkisagiraju

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago