A Pure JavaScript Solution to create Tags Input Element.

Overview

JavaScript Tags Input Library

Native JavaScript library to make Tags Input Element in DOM. There isn't any dependency for this library, add it straight in your project and you'r ready to go.

Install via npm

npm install vanilla-tags-input

Require in Node

let TagsInput = require('vanilla-tags-input')

Import Styles

@import '~vanilla-tags-input/tags-input.css'

##3 Alternatively, you can use a CDN or even download

<!-- Tags-input CSS -->
<link rel="stylesheet" href="https://unpkg.com/vanilla-tags-input/tags-input.css">

<!-- Tags-input JavaScript -->
<script src="https://unpkg.com/vanilla-tags-input"></script>

Usage

Selector is the only compulsory option to making this plugin work, and it accepts ID of input field you want to convert to tag input.

var tagInput1 = new TagsInput({
    selector: 'tag-input1',
});

However there are few other options too like

  • Duplicate - Set it to yes if you want to allow duplicate tags
  • Max - Limit the maximum number of tags to be added in plugin
var tagInput1 = new TagsInput({
    selector: 'tag-input1',
    duplicate : false,
    max : 10
});

Options

Add multiple tags programatically

tagInput1.addData(['PHP' , 'JavaScript' , 'CSS'])
// or add single one
tagInput1.addTag('React');

Check if there are any erros to add a tag

tagInpu1.anyErrors('another tag');

Destroy the instance and release the cached memory

tagInput1.destroy();

Reinitialize the plugin if previously destroyed

tagInput1.init()

// you can reinitialize options
tagInput1.init({
    selector: 'other-tag-input',
    duplicate : false,
    max : 10
})

Method chaning available too

tagsInput1.init().addTag().addData().destroy().init()

License

MIT Copyright (c) 2018-present, Qamar Ali

For Learning Purposes

Here is a Demo on codepen

Find Tutorial on how i build this javascript library.

You might also like...

Hackathon for Social Good 2022 and use your superpowers to create a solution for the social good.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Jun 27, 2022

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time.

A tiny JavaScript library to easily toggle the state of any HTML element in any contexts, and create UI components in no time. Dropdown, navigation bu

Nov 25, 2022

A package to toggle properties of your HTML tags.

A package to toggle properties of your HTML tags.

Toggler A package(atleast the code) to toggle properties of tags. I mostly use toggle classes while making a switch theme method, button interaction e

Jan 9, 2022

Bootstrap5-tags - Replace select[multiple] with nices badges

Bootstrap5-tags - Replace select[multiple] with nices badges

Tags for Bootstrap 4/5 How to use An ES6 native replacement for select using standards Bootstrap 5 (and 4) styles. No additional CSS needed! Supports

Jan 9, 2023

Wrap selected text in custom tags with shortcuts.

Wrap selected text in custom tags with shortcuts.

Obsidian Wrap With Shortcuts Wrap the selected text in customized tags with shortcuts. Underline is provided with Ctrl-u(Cmd-u) as default wrappers. P

Dec 28, 2022

A Zotero add-on that scans your Markdown reading notes, tags the associated Zotero items, and lets you open notes for the Zotero items in Obsidian.

A Zotero add-on that scans your Markdown reading notes, tags the associated Zotero items, and lets you open notes for the Zotero items in Obsidian.

Zotero Obsidian Citations Adds colored tags to Zotero items that have associated Markdown notes stored in an external folder. Open an associated Markd

Jan 4, 2023

Obsidian plugin that adds autocomplete and auto-formatting to frontmatter tags.

Obsidian plugin that adds autocomplete and auto-formatting to frontmatter tags.

Obsidian Front Matter Tag Wizard Tired of having to type # to get tag autocompletion in your Obsidian note front matter? I feel your pain. This plugin

Nov 5, 2022

Disallow form tags without explicit method="post"

Disallow form tags without explicit method=

eslint-plugin-require-form-method-post Disallow form tags without explicit method="post" Prevents sensitive data appearing on URLs Allow form tags wit

Apr 24, 2022

A ideia do projeto era desenvolver um jogo onde o usuário pode tentar "descobrir" ou melhor dizendo, lembrar a maior quantidade de HTML Tags em um determinado tempo.

A ideia do projeto era desenvolver um jogo onde o usuário pode tentar

HTML Tag Memory Test 🚀 Tecnologias Esse projeto foi desenvolvido com as seguintes tecnologias: ViteJS ReactJS Typescript Tailwind Zustand Immer Axios

May 17, 2022
Comments
  • Tag not created on blur

    Tag not created on blur

    Steps to reproduce:

    • enter some tag text "asdf"
    • click outside the field : expected behavior : the tag is created actual behavior : the text remains in the field and the tag is not created

    Additional note : when the form is submitted the new text (asdf) is not submitted as the tag was never created.

    It would be good if there were an onblur handler that ran to create the tag if the input is not empty.

    Thanks for your work on a small, simple library!

    opened by samortiz 0
Owner
Qamar ALi
Full stack web developer & designer
Qamar ALi
This is a JQuery plugin for input tags with auto complete suggestion.

Jquery Suggestags This is a JQuery plugin for input tags with auto complete suggestion. $('input').amsifySuggestags(); npm installation npm i suggesta

Amsify42 60 Nov 16, 2022
🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue

Tagify - tags input component Transforms an input field or a textarea into a Tags component, in an easy, customizable way, with great performance and

Yair Even Or 2.8k Jan 2, 2023
A Bootstrap plugin to create input spinner elements for number input

bootstrap-input-spinner A Bootstrap / jQuery plugin to create input spinner elements for number input. Demo page with examples Examples with floating-

Stefan Haack 220 Nov 7, 2022
👌A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for drop an annoying pop-ups confirming the submission of form in your web apps.

Throw out pop-ups confirming the submission of form! A useful zero-dependencies, less than 434 Bytes (gzipped), pure JavaScript & CSS solution for dro

Vic Shóstak 35 Aug 24, 2022
JavaScript micro-library: pass in an element and a callback and this will trigger when you click anywhere other than the element

Add a click listener to fire a callback for everywhere on the window except your chosen element. Installation run npm install @lukeboyle/when-clicked-

Boyleing Point 5 May 13, 2021
A phone input component that uses intl-tel-input for Laravel Filament

Filament Phone Input This package provides a phone input component for Laravel Filament. It uses International Telephone Input to provide a dropdown o

Yusuf Kaya 24 Nov 29, 2022
An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon class in an input element.

Font Awesome Browser An easy-to-use jQuery plugin that allows the user to pick an icon from a responsive icon browser and shows the corresponding icon

Gianluca Chiarani 1 May 1, 2021
A pure CSS toggle switch for form input checkboxes

Toggle Switchy A pure CSS toggle switch for form input checkboxes Preview Installation CSS <link rel="stylesheet" href="toggle-switchy.css"> HTML <lab

Adam Culpepper 34 Dec 8, 2022
Linkify is a JavaScript plugin for finding links in plain-text and converting them to HTML tags.

Linkify Linkify is a JavaScript plugin. Use Linkify to find links in plain-text and convert them to HTML <a> tags. It automatically highlights URLs, #

Hypercontext 1.5k Dec 27, 2022
In this project, I built a to-do list app, which is inspired by the minimalist website. Build withHTML/CSS & JavaScript best practices: Correct use of tags, elements, properties and syntax.

Webpack Exercise In this project, I built a to-do list app, which is inspired by the minimalist website. Built With HTML/CSS & JavaScript best practic

Vanessa Oliveros 3 Oct 11, 2022