# @eidellev/react-tag-input

> React tag input component

Latest version **1.1.0** (published 2021-11-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install @eidellev/react-tag-input
pnpm add @eidellev/react-tag-input
yarn add @eidellev/react-tag-input
bun add @eidellev/react-tag-input
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-11-09 |
| First published | 2021-10-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 15.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | lev-eidelman |
| Keywords | react, component, tag input, colors, suggestions |

## Links

- npm: https://www.npmjs.com/package/@eidellev/react-tag-input
- Repository: https://github.com/eidellev/react-tag-input
- Homepage: https://github.com/eidellev/react-tag-input#readme
- Issues: https://github.com/eidellev/react-tag-input/issues
- npm.io page: https://npm.io/package/@eidellev/react-tag-input

## Dependencies (6)

- [react](https://npm.io/package/react.md) ^17.0.2
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [color-hash](https://npm.io/package/color-hash.md) ^2.0.1
- [@types/react](https://npm.io/package/@types/react.md) ^17.0.33
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^17.0.10
- [@types/color-hash](https://npm.io/package/@types/color-hash.md) ^1.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-11-09
- 1.0.2 — 2021-11-06
- 1.0.1 — 2021-10-26
- 1.0.0 — 2021-10-26

## README

# React Tag Input

![screenshot](./screenshot.png)

A lean, easily customizable, tag input React component.

## Installation

```shell
npm i @eidellev/react-tag-input

# or
yarn add @eidellev/react-tag-input
```

## Usage

### Import styles

```css
/* In your stylesheet */
@import '@eidellev/react-tag-input/dist/index.css';
```

### Import component

```jsx
import TagInput from '@eidellev/react-tag-input';
...

<TagInput value={tags} onChange={onChange} colorize placeholder="New Tag" options={suggestions} />
```

## Props

- `value`(string[]) - The current value
- `options`(string[]) - A list of suggestions
- `colorize`(boolean) - Should each tag be assigned a unique background color
- `placeholder`(string) - Placeholder text
- `completeKeys`(string[]) - A list of keys that trigger tag completion (the default are `Esc`, `Enter` and `,`)
- `onChange`(function) - A callback that will be called when a tag is added or removed

## Customizing Styles

If you would like to apply your own design, there is no need to import the default styles. Simply add your own styles to the built-in classes:

```css
.tag-input {
  /* ... */
}

.tag-input .tag {
  /* ... */
}

.tag-input .tag .remove-tag-button {
  /* ... */
}

.tag-input .new-tag {
  /* ... */
}
```

For example, this is how we can style the component with [TailwindCSS](https://tailwindcss.com/):

```css
.tag-input {
  @apply w-full bg-white rounded border border-gray-300  focus-within:border-purple-500 focus-within:ring-2 focus-within:ring-purple-200 text-base outline-none py-1 px-3 leading-8 transition-colors duration-200 ease-in-out text-white;
}

.tag-input .tag {
  @apply px-2 py-1 rounded-md mr-2;
}

.tag-input .tag .remove-tag-button {
  @apply ml-2;
}

.tag-input .new-tag {
  @apply focus:border-0 focus:outline-none text-gray-700;
}
```

![screenshow with tailwind](./tailwind.png)

---
_Source: https://npm.io/package/@eidellev/react-tag-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
