All Projects → erizocosmico → React Categorized Tag Input

erizocosmico / React Categorized Tag Input

Licence: mit
React.js component for making tag autocompletion inputs with categorized results.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Categorized Tag Input

React Selectrix
A beautiful, materialized and flexible React Select control
Stars: ✭ 166 (+112.82%)
Mutual labels:  input, dropdown, tags
tagselector
Dependency-free JS library that turns select fields in customizable tag clouds
Stars: ✭ 19 (-75.64%)
Mutual labels:  tags, dropdown
Svelte Tags Input
Svelte tags input is a component to use with Svelte and easily enter tags and customize some options
Stars: ✭ 123 (+57.69%)
Mutual labels:  input, tags
insect
🛠 Highly customisable, minimalistic input x select field for React.
Stars: ✭ 33 (-57.69%)
Mutual labels:  input, dropdown
Core Components
Accessible and lightweight Javascript components
Stars: ✭ 85 (+8.97%)
Mutual labels:  input, dropdown
Tagify
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
Stars: ✭ 2,305 (+2855.13%)
Mutual labels:  input, tags
React Input Enhancements
Set of enhancements for input control
Stars: ✭ 1,375 (+1662.82%)
Mutual labels:  input, dropdown
Vue Input Tag
🔖 Vue.js 2.0 Input Tag Component
Stars: ✭ 507 (+550%)
Mutual labels:  input, tags
react-native-element-textinput
A react-native TextInput, TagsInput and AutoComplete component easy to customize for both iOS and Android.
Stars: ✭ 28 (-64.1%)
Mutual labels:  tags, input
bootstrap5-tags
Replace select[multiple] with nices badges for Bootstrap 5
Stars: ✭ 58 (-25.64%)
Mutual labels:  tags, input
React Tagsinput
Highly customizable React component for inputing tags.
Stars: ✭ 1,241 (+1491.03%)
Mutual labels:  input, tags
React Input Tags
React component for tagging inputs.
Stars: ✭ 10 (-87.18%)
Mutual labels:  input, tags
vue-tags-component
Vue.js 2+ tags component
Stars: ✭ 27 (-65.38%)
Mutual labels:  tags, dropdown
tag-picker
Better tags input interaction with JavaScript.
Stars: ✭ 27 (-65.38%)
Mutual labels:  tags, input
Form Js
Easily create web forms. Supports Meteor, AngularJS, React, Polymer and any CSS library, e.g. Bootstrap.
Stars: ✭ 9 (-88.46%)
Mutual labels:  input, dropdown
Nb Choices
Angular wrapper for choices.js, vanilla, lightweight, configurable select box/text input plugin
Stars: ✭ 32 (-58.97%)
Mutual labels:  dropdown, tags
Django Taggit Labels
Clickable label widget for django-taggit
Stars: ✭ 62 (-20.51%)
Mutual labels:  tags
Redoflacs
Parallel BASH commandline FLAC compressor, verifier, organizer, analyzer, and retagger
Stars: ✭ 71 (-8.97%)
Mutual labels:  tags
Countrycity
🌎 Geodata API - Get countries, and cities to plug in a select drop-down.
Stars: ✭ 62 (-20.51%)
Mutual labels:  dropdown
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (-21.79%)
Mutual labels:  input

react-categorized-tag-input Build Status

React.js component for making tag autocompletion inputs with categorized results with no dependencies and 10KB minified.

Note: v1.x versions only work with react 0.14.0 or higher. For compatibility with previous versions use the v0.x versions.

Install

npm install react-categorized-tag-input

Include

With webpack, browserify, etc (recommended way):

import TagInput from 'react-categorized-tag-input';

or (if you are not yet using ES2015, which you should)

var TagInput = require('react-categorized-tag-input');

With other tools: Just include the categorized-tag-input.js file in your HTML and your good to go. It is already minified.

If you want to use the default style you have to include the categorized-tag-input.css file. It is plain CSS, no LESS, no SASS, no dependencies.

As a personal suggestion, I recommend webpack. You would just need to require('node_modules/react-categorized-tag-input/categorized-tag-input.css');.

Usage

To use this component we will assume the imported variable name is TagInput. The props are very straightforward.

Name Type Description default
addNew boolean If true, allows the user to create new tags that are not set in the dataset true
categories Array of objects Dataset with categories and items Required
transformTag function A function that will receive the tag object (which has at least keys title and category) and must return a string. This string will be displayed to the user. Useful if you need to apply a transformation to the tags. (tag) => tag.title
value Array of tags. Tags are objects with (at least) keys title and category, where category is the id of a category in the array passed in for the categories prop Array with the initial tags []
onBlur function Callback for when the input loses focus noop
onChange function Callback for when the input changes. It does not get an event as parameter, it gets the array of tags after the change. noop
placeholder string A placeholder will be given in the input box. Add a tag
getTagStyle function A function from the tag text (string) to an object with any or all of the following keys: base, content and delete. The values are React style objects. This example renders 1-letter long tags in red: text => text.length === 1 ? {base: {color: "red"}} : {} () => ({})
getCreateNewText function A function that returns the text to display when the user types an unrecognized tag, given a title and text. (title, text) => Create new ${title} "${text}"
getTagStyle function A function from the tag (object with at least the keys title and category) to an object with any or all of the following keys: base, content and delete. The values are React style objects. This example renders 1-letter long tags in red: text => text.length === 1 ? {base: {color: "red"}} : {} () => ({})

The tag object

Tag objects look like this:

{
  title: 'String to used to identify the tag',
  category: 'id of the category for the tag'

}

The category object

The category object for the dataset looks like this:

{
  id: 'string or number identifying the category',
  type: 'word to describe the category. Will be used on the create new tag button. E.g: "Create new animal foo"',
  title: 'Title displayed on the category row',
  items: ['Array', 'With', 'Tags'],
  single: optional boolean. If is true the row will be treated as one-valued row. It does not have the option of adding new items to the category
}

Create the object

<TagInput categories={myCategories} addNew={true}
    transformTag={tagTransformer}
    onBlur={onBlur}
    onChange={onChange} />

Get the value

You can either use the onChange callback or use the value() method of the component. It will return the existing tags as an array of strings.

How to use the rendered component

When you click on the input you will be able to write on it. Right away, a panel with the categories with matches will be shown. You can navigate through categories and options using the arrow keys to change the selected tag. Backspace when there is nothing written erases the last tag. Enter and , add the currently selected tag to the input.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].