1.0.2 • Published 8 months ago

react-custom-tags-input v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

React Custom Tags Input

A highly customizable and accessible React component for managing tags in your projects. Add, edit, and remove tags with ease while maintaining full control over styling and behavior.

npm License npm bundle size


Installation

To install the package, run:

npm install react-custom-tags-input

or with Yarn:

yarn add react-custom-tags-input

Usage

Import the component and use it in your project:

import React, { useState } from "react";
import { TagsInput } from "react-tags-input";

const App = () => {
  const [tags, setTags] = useState(["example", "tags"]);

  return (
    <div>
      <h1>React Tags Input</h1>
      <TagsInput
        tags={tags}
        setTags={setTags}
        placeholder="Add a tag..."
        tagStyle={{
          backgroundColor: "#4CAF50",
          color: "#fff",
        }}
        inputStyle={{
          border: "1px solid #ddd",
          padding: "8px",
        }}
      />
    </div>
  );
};

export default App;

Props

Prop NameTypeDefaultDescription
tagsstring[][]Array of tags to display.
setTags(tags: string[]) => void-Function to update the array of tags.
placeholderstring"Add a tag..."Placeholder text for the input field.
tagStyleReact.CSSProperties{}Inline styles for each tag.
inputStyleReact.CSSProperties{}Inline styles for the input field.
tagClassNamestring""CSS class name for each tag.
inputClassNamestring""CSS class name for the input field.
onTagAdd(tag: string) => voidundefinedCallback when a new tag is added.
onTagRemove(tag: string) => voidundefinedCallback when a tag is removed.
maxTagsnumberInfinityMaximum number of tags allowed.
allowDuplicatesbooleanfalseWhether to allow duplicate tags.

Features

  • Fully customizable styling with tagStyle and inputStyle.
  • Accessible and keyboard-friendly.
  • Supports dynamic callbacks for adding/removing tags.
  • Optional limit on the maximum number of tags.
  • Lightweight and easy to use.

Author

Developed by pr4th4meshh

License

MIT License

Links

NPM Package

1.0.2

8 months ago

1.0.0

8 months ago