npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

js-input-tags

v2.0.1

Published

Simple, but powerful vanilla javascript input-tags creator, with autocomplete.

Readme

js-input-tags

Version 2.01

Check the CodePen.io basic example; autocomplete example.

Project objective: simple but powerful vanilla ES6 javascript (code: 350 lines) input tag generator for any input fields; with auto-completion lists.

Based off the inspiration work of github.com/rk4bir/simple-tags-input; using his idea and CSS but then rewritten for ES6 and more features. Can record special keys (Meta, Alt, Tab, MouseLeft, VolumeUp, etc) as key presses.

This project is mobile-friendly: but you may want to prevent scrolling of screen depending on your needs.

Demo

(Go to my github repo to see the demos, this readme does't show them on other locations) demonstration

special-keys

Options

Only required tags are inputId

  • allowDelete: allow the [x] deleting of tags (default true)
  • allowDuplicates: allow duplicate tags (default false)
  • allowSpaces: allow spaces in tags (default false)
  • allowCustomKeys: enables special character handling (default false)
  • autocomplete: array of auto-complete options
  • initialTags: array of initial tags to display
  • targetEl: target list element (if UL) or parent for the created list element
  • onAdd: a function called before adding the tag text (returns text or modified version)
  • onDelete: a function called before deleting a tag (returns true if allowed, false otherwise)
  • onInput: a function called after new user input received
  • onChange: a function called after change to tags (new tag added, re-arranged, deleted tag)

Methods

With a valid InputTags() instance you have these methods:

  • getTags(): get the list of tags created
  • setTags([]): set the list of tags
  • addTag(tag): add a new tag to input tags instance
  • deleteTag(index): remove a tag, the index of it's placement
  • showAutocomplete(query): showes autoComplete with matches for the query
  • hideAutocomplete()
  • destroy(): remove the instance

Usage

There are 3 steps to using it

  1. Include the CSS & JS files (importing it into a script type=module)
  2. Have an empty list (UL) and an input box (INPUT)
  3. Run the function: const inputTags = new InputTags({ inputId: "tagsInput", listId: "tagsList" });

That's it!

BASIC Example

Check the CodePen.io example.

Step 1 - Include Files (change path to match where they are)

    <head>
        <link rel="stylesheet" href="https://unpkg.com/js-input-tags@latest/style.css">
    </head>

    <script type="module">
    import InputTags from "https://unpkg.com/js-input-tags@latest"
    </script>

Step 2 - Insert needed HTML into your code

<div>
    <ul id="tagsList"></ul>
    
    <input type="text" id="tagsInput" spellcheck="false" placeholder="Enter a tag" />
</div>

Step 3 - Run Javascript (to initialize INPUT field)

    const inputTags = new InputTags({ inputId: "tagsInput", listId: "tagsList" });

Quick example html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap 5 not used by Input Tags -->
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    
    <!-- Only CSS used by InputTags -->
    <link rel="stylesheet" href="https://unpkg.com/js-input-tags@latest/style.css">
</head>

<body>
    <div class="container mt-5">
        <h1 class="text-center mb-4">Tags Input</h1>
            
        <div class="mb-3">
            <p class="mb-2">Tag List:</p>
            <!-- specify the ul LIST element to show the tags -->
            <ul id="myTagList"><li><strong>List:</strong></li></ul>
            <!-- include the input box to input the tags -->
             <p><i>Type something and press Enter</i></p>
            <input type="text" id="tagsInput" class="form-control mt-2" spellcheck="false" placeholder="Enter a tag" />
        </div>
            
        <div class="mb-3">
            <p class="mb-2">List results: <strong><span id="tagsData"></span></strong></p>
            <div class="mt-5 d-grid gap-2 d-md-flex justify-content-md-start">
                <button class="btn btn-secondary ms-md-2" onClick="btnAddTag('hello')">Add Tag 'hello'</button>
            </div>
        </div>
    </div>

     <!--Simple tags input implementation-->
     <script type="module">
        import InputTags from "https://unpkg.com/js-input-tags@latest"

        const inputEl = document.getElementById('tagsInput');
        const inputTags = new InputTags(inputEl, {
            autocomplete: ['apple', 'banana', 'cherry'],
            // initialTags: ['one','two','three'], // pre-populate (1)
            targetEl: document.getElementById('myTagList'), // pre-populate (2)
            onChange: (tags) => document.getElementById('tagsData').innerHTML = tags?.join(',') || ''
        });

        // show initial tags by adding something
        setTimeout( ()=>inputTags.addTag('Auto-Add'), 100)

        // export module functions for DOM
        window.btnAddTag = (tag) => inputTags.addTag(tag);
     </script>
</body>
</html>        

AutoComplete Example

Check the CodePen.io example.

Step 1 - Include Files (change path to match where they are)

    <head>
        <link rel="stylesheet" href="https://unpkg.com/js-input-tags@latest/style.css">
    </head>

    <script type="module">
    import InputTags from "https://unpkg.com/js-input-tags@latest"
    </script>

Step 2 - Insert needed HTML into your code

Really just having an input box to enter tags is all that is needed. The package can use an existing list (UL) otherwise it will create one and pre-pend above the INPUT box.

<div>
    <input type="text" id="tagsInput" spellcheck="false" placeholder="Enter a tag" />

    <button onClick="btnAddTag('hello')">Add Tag 'hello'</button>
</div>

Step 3 - Run Javascript (to initialize INPUT field)

    const inputEl = document.getElementById('tagsInput');
    const inputTags = new InputTags(inputEl, {
        autocomplete: ['apple', 'banana', 'cherry'],
        initialTags: ['one','two','three'], // pre-populate (1)
        // targetEl: document.getElementById('myTagList'), // pre-populate (2)
        // onChange: (tags) => document.getElementById('tagsData').innerHTML = tags?.join(',') || ''
    });

    // export module functions for DOM access if needed
    window.inputTags = inputTags;

Advanced Ideas

You can use the 4 hooks to limit characters allow in inputs, prevent certain tags from being created, or others from being deleted (with these hooks: onInput, onAdd, onDelete)

    const inputEl = document.getElementById('tagsInput');
    const inputTags = new InputTags(inputEl, {
        targetEl: document.getElementById('myList'),
        autocomplete: ['apple', 'banana', 'cherry', 'pear', 'pineapple'],
        // allowCustomKeys: true,
        // onInput: (value,e) => customKeyHandling(value,e),
        onInput,
        onAdd,
        onDelete,
        onChange: (tags) => document.getElementById('tagsOutput').value = tags?.join(',') || '',
        });
  • AutoComplete: Triggering display of autocomplete: see example/advanced.html "Show AutoComplete" button.
    <button onClick="showList('apple')">Show AutoComplete List</button>
    window.showList = (search) => inputTags.showAutocomplete(search);

If you modify the javascript in src/index.js, you can build it with npm run build for distribution.

Before forking and spreading another version, please contact the author with a PR if you have improvements you would like. I'd be happy to integrate improvements.