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-tagit

v1.0.4

Published

Simple input tag component for react

Downloads

38

Readme

react-tagit

npm version license bundle size types

A simple and customizable Input Tag Component for React.

Demo

Demo

Table of Contents

Installation

Install the package using your preferred package manager:

NPM

npm install react-tagit

Yarn

yarn add react-tagit

PNPM

pnpm add react-tagit

Peer Dependencies

Ensure you have the following peer dependencies installed:

"peerDependencies": {
  "react": "^19.0.0",
  "react-dom": "^19.0.0"
}

Usage

Here’s an example of how to use the <InputTag> component:

import { InputTag } from 'react-tagit';
import { useState } from 'react';

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

  return (
    <form>
      <InputTag
        separator="Space"
        theme="theme-1"
        maxTags={5}
        maxTagsValue={25}
        value={tags}
        onChange={setTags}
      />
      <button type="submit">Submit Tags</button>
    </form>
  );
}

And that's it! You now have a fully functional input tag component.

Props

Here’s a list of props you can pass to the <InputTag> component:

| Prop | Type | Default | Description | | ----------------------------- | ------------------------------------- | ----------- | --------------------------------------------------------------------- | | autoFocus | boolean | false | Autofocus the tag input element when the component mounts. | | customClass | object | {} | Custom classes for the elements of the InputTag component. | | disabled | boolean | false | Disable the InputTag component. Hides the remove button for each tag. | | inputTagContainerStyleProps | object | {} | Style props for the container element. | | labelStyleProps | object | {} | Style props for the label element. | | inputStyleProps | object | {} | Style props for the input element. | | tagsContainerStyleProps | object | {} | Style props for the tags list container. | | tagsStyleProps | object | {} | Style props for individual tag elements. | | removeTagBtnStyleProps | object | {} | Style props for the remove button on each tag. | | hideLabel | boolean | false | Whether to hide the label. | | label | string | 'Tags' | Label for the input. | | maxTags | number | infinite | Maximum number of tags allowed. | | maxTagsValue | number | infinite | Maximum number of characters per tag. | | name | string | 'tags' | Name attribute for the input element. | | separator | 'Enter' \| 'Space' | 'Enter' | The key that triggers tag creation. | | theme | 'theme-1' \| 'theme-2' \| 'theme-3' | undefined | Available themes for styling the component. | | value | Array<string> | [] | Current tag values. | | onChange | (tags: Array<string>) => void | undefined | Function to update the tag values. | | onFocus | (event: FocusEvent) => void | () => {} | Callback when the input gains focus. | | onBlur | (event: FocusEvent) => void | () => {} | Callback when the input loses focus. |

Styling & Theming

react-tagit comes with built-in themes and allows you to customize styles using class names or inline styles.

Built-in Themes

You can use one of the predefined themes:

  • Theme 1

    <InputTag theme="theme-1" />

    Theme 1 Demo

  • Theme 2

    <InputTag theme="theme-2" />

    Theme 2 Demo

  • Theme 3

    <InputTag theme="theme-3" />

    Theme 3 Demo

Custom Classes

You can override the default classes by passing a customClass object:

<InputTag
  customClass={{
    inputTagContainerElement: 'custom-container',
    inputTagLabelElement: 'custom-label',
    inputTagListContainerElement: 'custom-list',
    inputTagTagItemElement: 'custom-tag-item',
    inputTagTagRemoveBtnElement: 'custom-remove-btn',
    inputTagTagContentElement: 'custom-tag-content',
    inputTagInputElement: 'custom-input',
  }}
/>

Default Classes

Here are the default class names you can target for styling:

  • input-tag-container-element
  • input-tag-label-element
  • input-tag-list-container-element
  • input-tag-tag-item-element
  • input-tag-tag-remove-btn-element
  • input-tag-tag-content-element
  • input-tag-input-element

Development

Testing

This project uses Jest and Testing Library for testing. To run the tests:

npm run test

Storybook

The project uses Storybook for component documentation and previews. To start Storybook:

npm run storybook

This will start a local server and provide a preview URL.

Building

The project uses Rollup as the bundler. To build the project:

npm run build

The compiled code will be available in the dist folder.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

License

This project is licensed under the MIT License.