Skip to content
nexubDesign System
v11.9.0

Components · Form Controls

Filter Builder

BetaAdded v5.5.0

Build AND/OR filter queries with nested groups. The output is plain JSON your app runs.

import { FilterBuilder } from '@nexub/react';
View as Markdown

Examples

Deals filter

{
  "id": "root",
  "combinator": "and",
  "rules": [
    {
      "id": "r1",
      "field": "stage",
      "operator": "equals",
      "value": "proposal"
    },
    {
      "id": "r2",
      "field": "amount",
      "operator": "greaterThan",
      "value": "10000"
    }
  ]
}

Props

Props
PropTypeDefaultDescription
fieldsrequiredFilterField[]—What can be filtered. The type picks the operators and the value input.
valueFilterGroup—{ id, combinator: "and" | "or", rules: (FilterRule | FilterGroup)[] }; a rule is { id, field, operator, value: string }.
defaultValueFilterGroup—{ id, combinator: "and" | "or", rules: (FilterRule | FilterGroup)[] }; a rule is { id, field, operator, value: string }.
onValueChange((value: FilterGroup) => void)—Called with the whole query on every change.
maxDepthnumber1Levels of nested groups "Add group" may create; 0 hides it.
classNamestring—

Accessibility

ARIA roles

Each group is a `group` named "Filters, match all/any".

Screen reader

  • Field, condition and value controls are labelled; remove buttons say what they remove.

Notes

  • Helpers: `emptyFilter()`, `countFilters(group)`, `isFilterGroup(rule)`, `filterOperators`.