Skip to content

Tag group

A set of chips: labels, services, filters in force. Arrow keys move between tags; with onRemove each tag has a remove button (and Backspace removes the focused one); with selectionMode tags can be chosen.

Language
Appearance

Removable

Contact labels
VIP
New patient
Prefers WhatsApp
import { useState } from 'react';
import { Tag, TagGroup } from '@arbol-ai/ui';

const RemovableExample = () => {
  const [labels, setLabels] = useState([
    { id: 'vip', name: 'VIP' },
    { id: 'new', name: 'New patient' },
    { id: 'whatsapp', name: 'Prefers WhatsApp' },
  ]);
  return (
    <TagGroup
      emptyLabel="No labels"
      items={labels}
      label="Contact labels"
      onRemove={(keys) => {
        setLabels((current) => current.filter((label) => !keys.has(label.id)));
      }}
    >
      {(label) => <Tag>{label.name}</Tag>}
    </TagGroup>
  );
};

<RemovableExample />

Selectable

Services
Annual checkup
Vaccination
Lab results
import { Tag, TagGroup } from '@arbol-ai/ui';

<TagGroup defaultSelectedKeys={['checkup']} label="Services" selectionMode="multiple">
  <Tag id="checkup">Annual checkup</Tag>
  <Tag id="vaccine">Vaccination</Tag>
  <Tag id="lab">Lab results</Tag>
</TagGroup>

Source

The examples above are src/components/tag-group/tag-group.examples.tsx, which the library’s tests render too.

Type to search…

↑↓ navigate↵ selectEsc close