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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-autocomplete-tagbox

v1.0.1

Published

React Autocomplete Tagbox is a modern, customizable React component for tag input with optional autocomplete. Effortlessly add, remove, and select tags with keyboard or mouse. Supports both free-form and restricted tag entry, smart suggestions, and a clea

Readme

React Autocomplete Tagbox is a modern, flexible, and fully customizable React component for tag input with optional autocomplete. Effortlessly add, remove, and select tags with keyboard or mouse. Supports both free-form and restricted tag entry, smart suggestions, and a clean, accessible UI. Perfect for forms, search bars, and dynamic filters. Easy to integrate and fully styleable to match your project.


🎬 Without Autocomplete

Without Autocomplete

🎬 With Autocomplete

With Autocomplete


✨ Features

  • Autocomplete Suggestions: Show relevant tag options as users type.
  • Free-form or Restricted Tags: Allow any input or restrict to a predefined list.
  • Custom Tag Validation (filterData): Accept only tags that match your custom logic (e.g., only URLs, emails, etc.).
  • Keyboard & Mouse Friendly: Full keyboard navigation and intuitive mouse interactions.
  • Customizable UI: Easily style to match your design system.
  • Tag Removal: Remove tags with a click or keyboard.
  • Tag Limit: Optionally limit the number of tags.
  • Paste Multiple Tags: Paste a list of tags separated by space/comma/newline.
  • Accessible: Built with accessibility in mind (ARIA roles, keyboard support).
  • TypeScript Support: Fully typed for a great developer experience.
  • Lightweight: Small bundle size, no heavy dependencies.
  • Easy Integration: Plug-and-play with minimal setup.

🚀 Installation

npm install react-autocomplete-tagbox
# or
yarn add react-autocomplete-tagbox

🛠️ Usage

import React, { useState } from "react";
import ReactAutocompleteTagbox from "react-autocomplete-tagbox";

const options = [
  "React",
  "JavaScript",
  "TypeScript",
  "GraphQL",
  "Redux",
  "Bootstrap",
];

// Example filter: only allow options that are at least 5 characters
const filterData = (str: string) => str.length >= 5;
const filteredOptions = options.filter(filterData);

export default function App() {
  const [tags, setTags] = useState<string[]>([]);

  return (
    <ReactAutocompleteTagbox
      tags={tags}
      onChange={setTags}
      options={filteredOptions} // Filtered options
      filterData={filterData}
      limit={5}
      placeholder="Add technologies..."
    />
  );
}

Note:
If you use both options and filterData, only options that pass filterData will be selectable or added as tags.
It's recommended to filter your options with filterData before passing them to the component.


⚙️ Props

| Prop | Type | Default | Description | | ---------------- | --------------------------- | --------------------------------------- | ------------------------------------------------------------------- | | tags | string[] | [] | The current list of tags. | | onChange | (tags: string[]) => void | | Callback when tags change. | | options | string[] | undefined | Optional. Restricts tags to these options and enables autocomplete. | | limit | number | undefined | Optional. Maximum number of tags allowed. | | placeholder | string | "Type and press ENTER to add tags..." | Placeholder text for the input. | | containerStyle | React.CSSProperties | undefined | Optional. Inline styles for the container. | | className | string | undefined | Optional. Additional class for the container. | | filterData | (data: string) => boolean | undefined | Optional. Custom validation/filter function for tags. |


🧠 Filtering Options

If you use both options and filterData, make sure your options match your filter. For example, to only allow URLs:

const filterData = (str: string) => {
  try {
    const url = new URL(str.trim());
    return url.protocol === "http:" || url.protocol === "https:";
  } catch {
    return false;
  }
};
const filteredOptions = options.filter(filterData);

<ReactAutocompleteTagbox
  tags={tags}
  onChange={setTags}
  options={filteredOptions}
  filterData={filterData}
/>;

🎨 Customization

  • Styling: The component uses CSS Modules. You can override styles by importing your own CSS or using the className prop.
  • Accessibility: Keyboard navigation and ARIA attributes are included for a11y. You can further enhance accessibility by providing descriptive labels and ensuring color contrast in your custom styles.

🧑‍💻 Development

Clone the repo and run:

npm install
npm run dev

📝 License

MIT © Amrit Utsav


💡 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to check issues page.


React Autocomplete Tagbox — The smart, beautiful way to manage tags in your React apps!