AdaptTable for Tailwind

Filtering in Tailwind

Declare what a column filters by and the table builds the control: text and number operators, date ranges with relative presets, and a checklist of the values actually present.

For the cases one row of inputs cannot express there is an AND/OR tree, and every active filter shows as a chip that removes itself.

The whole filter state lives in the URL, so a filtered view is a link someone can send — and the popover, drawer, inputs and chips are native elements, each one addressable by class so the filter form looks like the form you wrote.

The backdrop, panel, popover and every filter input carry the map's classes with an indigo focus ring, and a checked option fills its label in indigo; the checklist and the AND/OR builder are not in the map, so they read as browser defaults.

The code

import { DataTable } from "@adapttable/unstyled";

const columns = [
  { key: "name", filter: "text" },
  {
    key: "team",
    filter: { type: "select", options: "auto" },
  },
  { key: "budget", filter: "numberRange" },
  { key: "hiredAt", filter: "dateRange" },
];

export function People({ rows }) {
  return (
    <DataTable
      data={rows}
      columns={columns}
      rowKey={(row) => row.id}
      filtersMode="popover"
      urlKey="f"
    />
  );
}

Install

pnpm add @adapttable/unstyled @adapttable/core

The same feature in the other kits

More Tailwind features

Reference: filtering, filter-tree, url-state. More of this kit: AdaptTable for Tailwind, or the live demo.