Skip to main content
A facet summarizes the values of one column over the rows that match the filter. The grid requests facets with every query and keeps them in its state. Each column type declares its facet kind. A type with facet none has no facet. See Column types.

Where they show

  • The filter bar suggests values from terms facets.
  • A chip’s popover lists value counts for enums and draws a histogram for numbers and dates.
  • The column menu shows the number of unique values.

Which columns

The grid asks for a facet on every column that is filterable and whose type has a facet kind. facetColumns(schema) returns that list. Set filterable: false to leave a column out.

Reading facets

Facets are in the grid state. Select them with useGridState so the component only renders when they change.
plan-counts.tsx

Without a grid

computeFacets(rows, columns, schema, context, options?) computes facets over an array.
facets.ts
Terms of an enum follow option order. Other terms are ordered by count, highest first. Empty values are not counted. The same options exist on createArraySource as facetOptions, and as bins and maxTerms on the SQL adapters.

Where they run

The grid sends the facet columns to the source when it has the facets capability. Otherwise it computes them over the rows it loaded.
Facets computed in the grid only count loaded rows. The Supabase adapter computes facets this way, from the loaded page.