@igloo-ui/tag-picker
TypeScript icon, indicating that this package has built-in type declarations

0.15.0 • Public • Published

TagPicker

A multiselect of items displayed as tags.

Installation

To install @igloo-ui/tag-picker in your project, you will need to run the following command using npm:

npm install @igloo-ui/tag-picker

If you prefer Yarn, use the following command instead:

yarn add @igloo-ui/tag-picker

Usage

Then to use the component in your code just import it!

import TagPicker from '@igloo-ui/tag-picker';
import { mockData } from './data';

const [selected, setSelected] = React.useState([]);
const [results, setResults] = React.useState([]);

const onInput = (value) => {
  setResults(
    mockData.filter(
      (d) =>
        d.text.toLowerCase().includes(value.toLowerCase()) &&
        !selected.includes(d)
    )
  );
};

const select = (id) => {
  const selectedItem = mockData.find((d) => d.id === id);
  if (selectedItem) {
    setSelected([...selected, selectedItem]);
  } else {
    setSelected([...selected]);
  }
};

const remove = (id) => {
  setSelected(selected.filter((s) => s.id !== id));
};

<TagPicker
  {...args}
  results={results}
  selectedResults={selected}
  onInput={onInput}
  onSelection={select}
  onTagRemove={remove}
  noResultsText="No results"
  placeholder="Enter Team or Bob"
/>;

/@igloo-ui/tag-picker/

    Package Sidebar

    Install

    npm i @igloo-ui/tag-picker

    Weekly Downloads

    52

    Version

    0.15.0

    License

    Apache-2.0

    Unpacked Size

    2.86 MB

    Total Files

    9

    Last publish

    Collaborators

    • infra.admin