Skip to content

useTableFiltering

@astryxdesign/core v0.7.1 · useTableFiltering

Parameters ​

useTableFiltering() takes one config object. Wrap it in a getter or a ref so the table reads the current filters: useTableFiltering(() => ({ ... })).

NameTypeDefaultDescription
filtersTableFilterState—Required. Current filter state: a map from field key to filter value.
onFilterChange(key: string, value: TableFilterValue | null) => void—Required. Called when the user changes a filter value. null clears the filter.
fieldsreadonly TableFilterField[]—Required. The fields a column may filter on. Each entry has key, label, type, and the options or limits that type needs.
variant'inline' | 'inline-compact' | 'popover''popover'Where the control sits. inline and inline-compact render it in the header cell under the label, inline-compact in a tighter frame; popover keeps it behind a funnel button that applies on confirm.

Returns ​

useTableFiltering() returns one TablePlugin<T>. Pass it to Table in plugins. The plugin fills two fields of the plugin contract:

NameTypeDescription
transformColumns(columns: TableColumn<T>[]) => TableColumn<T>[]Only set for the inline variants: a filtered column without a width gets proportional(1) so the control fits under the label.
filterFor(column: TableColumn<T>) => TableFilterContribution | nullBuilds the control for a column, or null when the column has no filter or names a field that is not in fields.

TableFilterContribution ​

NameTypeDescription
variant'inline' | 'inline-compact' | 'popover'The resolved variant, after the default is applied.
fieldTableFilterFieldThe field the column named, taken from fields.
valueTableFilterValue | nullThe current value from filters, or null when the field has no filter.
onChange(value: TableFilterValue | null) => voidReports a new value through your onFilterChange, already keyed by the field.

TableFilterField ​

NameTypeDefaultDescription
keystring—Field key. A column's filter holds this string, and the field reads row[key].
labelstring—Label and placeholder of the control. It also names the control for screen readers.
type'string' | 'enum' | 'multi-select' | 'number' | 'date'—How the filter matches. string matches a substring, enum one option, multi-select any of the picked options, number the same number, and date a cell date later than the picked day.
optionsreadonly { value: string, label: string }[]—Choices for an enum or multi-select field. Without options the control renders an empty list.
minnumber—Smallest value a number field accepts.
maxnumber—Largest value a number field accepts.
stepnumber1 when isIntegerOnly, otherwise noneStep of a number field.
isIntegerOnlybooleanfalseA number field that only accepts whole numbers.

TableFilterValue ​

NameTypeDescription
valuestring | number | string[]A number field stores a number, multi-select stores an array of option values, and the rest store a string. A date field stores an ISO calendar day such as 2026-03-21.