Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Data Table examples · Standard

Data Table with Filters for React

A table of users with two inputs that filter the rows by name and by email.

Framework
UI library

Five users and two Inputs above the table, one for names and one for emails. Each keystroke narrows the rows, and both filters apply together. TanStack Table's column filtering does the matching. Use it for directories and lists where people look for a row by a field they know.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How do the inputs filter the table?

Each input belongs to a column, name or email. Its onChange calls column.setFilterValue and its value reads column.getFilterValue(). The table has columnFilteringFeature, createFilteredRowModel() and the includesString filter.

Can both inputs filter at once?

Yes. Each writes its own column's filter, and a row shows only when it matches both. Role and Status have no filter here.

How do I clear a filter?

Empty the input; an empty value removes that column's filter. The inputs are type="search", so browsers that support it show a clear button inside.

What appears when nothing matches?

The body renders one cell spanning every column with No results.

Which filter function runs?

includesString on both columns: it matches any part of the value and ignores case, so jo finds John Doe and Bob Johnson. Pick another of TanStack Table's filter functions, or write one, for exact or numeric matching.

Are the filters labeled?

Yes. Each input has an aria-label, Filter by name and Filter by email, and the same words as its placeholder. Tab moves between them and the table.