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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mantine-tag-input

v1.0.2

Published

A react tag input built on mantine component library and it adapts well with the theme of the library.

Downloads

22

Readme

mantine-tag-input

A react tag input built on mantine component library and it adapts well with the theme of the library.

Publish package on NPM

Mantine Tag Input

Installation

To start using mantine Tag Input in your React project, follow these simple steps:

  1. Install the package via npm or yarn:

bash

npm install mantine-tag-input

or

bash

yarn add mantine-tag-input

or

bash

pnpm add mantine-tag-input
  1. Import the component in your desired file:

javascript

import { TagsInput } from 'mantine-tag-input';

Props

name (optional)

  • Type: string
  • Default: undefined

The name prop allows you to specify the name attribute for the input field. This can be useful for form submission or accessing the input value via JavaScript.

placeHolder (optional)

  • Type: string
  • Default: undefined

The placeHolder prop defines the placeholder text that appears in the input field when no tags are present.

value (optional)

  • Type: string[]
  • Default: []

The value prop accepts an array of strings representing the initial tags to be displayed in the input field.

onChange (optional)

  • Type: (tags: string[]) => void
  • Default: undefined

The onChange prop is a callback function that is triggered whenever there is a change in the tags. It receives an array of strings representing the updated tags as a parameter.

onBlur (optional)

  • Type: any
  • Default: undefined

The onBlur prop allows you to define a function that is called when the input field loses focus.

separators (optional)

  • Type: string[]
  • Default: undefined

The separators prop allows you to specify an array of strings that will act as separators for creating multiple tags. By default, the tags are separated by commas.

disableBackspaceRemove (optional)

  • Type: boolean
  • Default: false

The disableBackspaceRemove prop, when set to true, prevents the removal of tags by pressing the Backspace key.

onExisting (optional)

  • Type: (tag: string) => void
  • Default: undefined

The onExisting prop is a callback function that is triggered when an existing tag is added. It receives the added tag as a parameter.

onRemoved (optional)

  • Type: (tag: string) => void
  • Default: undefined

The onRemoved prop is a callback function that is triggered when a tag is removed. It receives the removed tag as a parameter.

disabled (optional)

  • Type: boolean
  • Default: false

The disabled prop, when set to true, disables the input field and prevents any further interaction with the component.

isEditOnRemove (optional)

  • Type: boolean
  • Default: false

The isEditOnRemove prop, when set to true, allows users to edit tags after they have been added.

beforeAddValidate (optional)

  • Type: (tag: string, existingTags: string[]) => boolean
  • Default: undefined

The beforeAddValidate prop allows you to define a validation function that is called before a tag is added. The function receives the tag to be added and the existing tags as parameters, and should return a boolean value (true to allow the addition and false to prevent it).

onKeyUp (optional)

  • Type: (e: React.KeyboardEvent<HTMLInputElement>) => void
  • Default: undefined

The onKeyUp prop is a callback function that is triggered when a key is released within the input field.

size (optional)

  • Type: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
  • Default: undefined

The size prop allows you to specify the size of the input field. It accepts one of the following values: 'xs', 'sm', 'md', 'lg', or 'xl'.

error (optional)

  • Type: React.ReactNode
  • Default: undefined

The error prop allows you to display an error message below the input field. It accepts a React node as a value.

badgeProps (optional)

  • Type: BadgeProps
  • Default: undefined

The badgeProps prop allows you to pass mantine badge props to the badge component.

closeButtonProps (optional)

  • Type: CloseButtonProps
  • Default: undefined

The closeButtonProps prop allows you to pass mantine close button props to the close button component.

Example Usage

import { MantineTagsInput } from 'mantine-tag-input';

const MyComponent = () => {
  const handleTagChange = (tags) => {
    // Handle tag change logic here
  };

  const handleTagRemove = (tag) => {
    // Handle tag removal logic here
  };

  return (
    <MantineTagsInput
      name="tags"
      placeHolder="Enter tags..."
      value={['tag1', 'tag2', 'tag3']}
      onChange={handleTagChange}
      onRemoved={handleTagRemove}
      separators={[' ', ',']}
      disableBackspaceRemove={true}
      isEditOnRemove={true}
    />
  );
};