Chip

A small label for a tag, a count or a status.

Usage

It never wraps or shrinks. Put the spacing on the container.

tsx
<div className="flex flex-wrap gap-2">
  <List array={tags} itemExtractor={({ row }) => <Chip key={row}>{row}</Chip>} />
</div>
typescript
tailwind
react

As a filter

active inverts the colours. For a filter, render it as a button.

tsx
const [selected, setSelected] = useState("all");

<div className="flex flex-wrap gap-2">
  <List
    array={tags}
    itemExtractor={({ row }) => (
      <Chip
        key={row}
        as="button"
        active={selected === row}
        aria-pressed={selected === row}
        onClick={() => setSelected(row)}
      >
        {row}
      </Chip>
    )}
  />
</div>

Reference

proptypedefault
as?ElementType"div"the element or component to render
active?booleanfalseinverted colours; visual only
className?string—added after the component's own class: what you set wins
…restprops of as—typed against the chosen element