Data

Filter builder.

Compose text, choice, numeric and date conditions with deliberate motion.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/filter-builder.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Draft, validate and explicitly apply

Incomplete rules remain editable; applying a query is a host decision.

Loads this example when you need it.

Keyboard

  • Tab reaches each condition and removal action.
  • Removing a rule returns focus to a neighbouring control.

States covered

  • No conditions
  • Draft rule
  • Validation feedback
  • Applied query

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-filter-builder.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {useState} from 'react';
import {Button,FilterBuilder,UIProvider,emptyFilterQuery,validateFilterQuery,type FilterField,type FilterQuery} from '@bld8/ui';
import '@bld8/ui/styles.css';
const fields:FilterField[]=[{id:'title',label:'Example title',kind:'text'},{id:'effort',label:'Example effort',kind:'number'}];
export default function FilterExample(){const [draft,setDraft]=useState<FilterQuery>(emptyFilterQuery()),[errors,setErrors]=useState<Record<string,string>>({}),[applied,setApplied]=useState('No query applied.');return <UIProvider><FilterBuilder label="Example conditions" fields={fields} value={draft} onValueChange={setDraft} errors={errors}/><Button onClick={()=>{const next=validateFilterQuery(draft,fields);setErrors(next);if(!Object.keys(next).length)setApplied(JSON.stringify(draft));}}>Apply example conditions</Button><p role="status">{applied}</p></UIProvider>;}

Quick reference

React / TypeScript
<FilterBuilder fields={fields} value={draft}
  onValueChange={setDraft} errors={errors} />
// Validate drafts before applying them.
const errors = validateFilterQuery(draft, fields);

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

The default mode keeps the version 1 flat query API. Set allowGroups to compose bounded version 2 nested all/any groups and group negation. Existing saved links remain valid; use migrateFilterQuery for an explicit upgrade and parseFilterQuery with allowNested:true at the host boundary. See /blocks/issue-table and /agent/guides/nested-filters.md. FilterField supports text, select, number and date. Multi-value choices, inclusive ranges and empty/not-empty tests use typed operators. Up to 20 rules are supported; maxRules defaults to 12. Incomplete drafts remain editable and validation is explicit. Motion uses eased row entry/exit and reduced-motion preferences; focus moves to a neighbouring field or Add filter after removal. Use the pure filter-query subpath on servers; the query model is not authorisation or SQL.

Try grouped filters in the Issue workspace · Query and migration guide

FilterBuilder

FilterBuilder public properties
PropTypeDefault
fieldsRequiredreadonly FilterField[]—
onValueChangeRequired((query: FilterQuery) => void) | ((query: AnyFilterQuery) => void)—
valueRequiredAnyFilterQuery—
allowGroupsboolean | undefined

Opt into bounded groups and accept both legacy and nested query envelopes.

—
disabledboolean | undefined—
errorsRecord<string, string> | undefined—
labelstring | undefined—
maxRulesnumber | undefined—

FilterField

FilterField public properties
PropTypeDefault
idRequiredstring—
kindRequiredFilterKind—
labelRequiredstring—
optionsreadonly { value: string; label: string; }[] | undefined—

FilterQuery

FilterQuery public properties
PropTypeDefault
matchRequired"all" | "any"—
rulesRequiredFilterRule[]—
versionRequired1—

FilterRule

FilterRule public properties
PropTypeDefault
fieldRequiredstring—
idRequiredstring—
operatorRequiredFilterOperator—
valuesRequiredstring[]—

NestedFilterBuilderProps

NestedFilterBuilderProps public properties
PropTypeDefault
allowGroupsRequiredtrue

Opt into bounded groups and accept both legacy and nested query envelopes.

—
fieldsRequiredreadonly FilterField[]—
onValueChangeRequired(query: AnyFilterQuery) => void—
valueRequiredAnyFilterQuery—
disabledboolean | undefined—
errorsRecord<string, string> | undefined—
labelstring | undefined—
maxRulesnumber | undefined—

AnyFilterQuery

FilterQuery | NestedFilterQuery

AnyFilterQuery public properties
PropTypeDefault
versionRequired1 | 2—

NestedFilterQuery

NestedFilterQuery public properties
PropTypeDefault
rootRequiredFilterGroup—
versionRequired2—

FilterGroup

FilterGroup public properties
PropTypeDefault
childrenRequiredFilterNode[]—
idRequiredstring—
matchRequired"all" | "any"—
notboolean | undefined—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.