Git Product home page Git Product logo

tag-input's Introduction

build

Tag Input

Demo

How to use

This library provides UMD build, so you can use it in webpack or just as is in HTML

<script src="tag-input.umd.js" charset="UTF-8"></script>
<script>
  var tagInput = taginput(document.querySelector('#some-input'), options)
</script>

Following options can be provided:

  1. placeholder - placeholder text for input

  2. validate - validation function (Empty by default)

  3. tags - initial tags (Defaults to [])

  4. type - input type. text or email (Defaults to text)

  5. style - custom CSS classes for styling

API

Add Item

tagInput.addItem('tag1')

Get current tags both valid and invalid

tagInput.tags

Replace current items with new

tagInput.replaceItems(['tag1','tag2'])

Clear all items

tagInput.replaceItems()

Events

Events are triggered on the element that was used to create TagInput

var node = document.querySelector('#some-input')
var tagInput = taginput(node)

// Added tag event
node.addEventListener('tagadded', function (e) {
  console.log('tag added:', e.detail.tag)
})

// Deleted tag event
node.addEventListener('tagdeleted', function (e) {
  console.log('tag deleted:', e.detail.tag)
})

What's missing

Mobile adaption

It should work fine on any mobile browser but some additional adaptations can be made

a11y

It does not exist yet, but definitely should be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.