Skip to content

FilterChip

One filter that is on: what is filtered, by what, and a button that takes it away.

import { FilterChip } from '@sypnia/ui/react'

On this page
  1. Filters that are on
  2. When to use it
  3. For everyone
  4. Props

Filters that are on

Press an x. The last chip has no x: it cannot be removed.

StatusPaidCountryColombiaTotalover US$ 100Placedthis month
Code
import { useState } from 'react';
import { Button, FilterChip } from '@sypnia/ui/react';

const start = [{ id: 'status', label: 'Status', value: 'Paid' }, { id: 'country', label: 'Country', value: 'Colombia' }, { id: 'total', label: 'Total', value: 'over US$ 100' }];

// One filter that is on: its name, its value, and an x that takes it away.
export default function Basic() {
  const [chips, setChips] = useState(start);
  return (
    <div className="sy-row">
      {chips.map((c) => <FilterChip key={c.id} label={c.label} value={c.value} onRemove={() => setChips((all) => all.filter((x) => x.id !== c.id))} />)}
      {chips.length === 0 ? <Button size="sm" onClick={() => setChips(start)}>Put them back</Button> : <FilterChip label="Placed" value="this month" />}
    </div>
  );
}

When to use it

Use it when

  • Above a list, to say which filters are on, so nobody wonders why rows are missing.
  • Without onRemove it only says the filter is there: for a filter the person cannot take away.

Do not use it when

  • It is a choice the person has not made yet: Chip or a select.
  • It is a tag on a thing: Tag or Badge.

For everyone

  • The x is a real button named after the filter: «Remove Status».
  • Its target is at least 24 px, and 44 px on touch screens.

Props

FilterChipTypeDefault
labelrequired

What is filtered: the column's name.

string
valuerequired

The value it is filtered by.

ReactNode
onRemove (() => void)
  1. Filters that are on
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms