Report Filter Builder - Bitblue

Compose column filters into SQL WHERE and JSON conditions for report queries

Build report conditions as a compact rule list. AND / OR joins appear between conditions on a connecting rail — each connection is independent. Use Add group when you need a nested AND/OR block. Filter rows and groups on the left collapse to one-line summaries (click to expand and edit). The preview panel emits SQL WHERE, a flat JSON list, and a structured tree, with SQL | JSON tabs when preview="both". The whole query panel can still collapse with « — use bind:previewCollapsed, or set previewCollapsible={false} to keep it always open.

Features

  • Collapsible filter rows: summary line when idle, editors when expanded (one at a time)
  • Collapsible groups: chevron header hides inner rules until expanded
  • Between-row AND / OR joins (each connection independent; stay visible when rows collapse)
  • Optional one-level groups for mixed boolean logic
  • Typed columns: string, number, date, boolean
  • Operators per type, including between for number and date
  • Live SQL and JSON preview tabs (jsonBuild + tree)
  • Collapsible query preview panel (bind:previewCollapsed, previewCollapsible)
  • Theme slots via filterBuilder / ThemeConfig
  • Responsive split: stacked on small screens, side-by-side from lg

Column config

PropertyTypeRequiredDescription
namestringYesColumn identifier used in the export
labelstringYesLabel shown in the UI
typestring | number | date | booleanYesDrives operators and value inputs

Operators

String — contains, equals, does not equal, starts with, ends with

Number / date — equals, comparisons, between, not equals

Boolean — is, is not

Basic usage

<script lang="ts">
	import {
		FilterBuilder,
		type FilterBuilderColumnConfig,
		type FilterBuilderExport
	} from '.';

	const columns: FilterBuilderColumnConfig[] = [
		{ name: 'name', label: 'Full Name', type: 'string' },
		{ name: 'age', label: 'Age', type: 'number' },
		{ name: 'created_at', label: 'Created Date', type: 'date' },
		{ name: 'is_active', label: 'Active Status', type: 'boolean' }
	];

	function handleQuery(val: FilterBuilderExport) {
		console.log(val);
	}
</script>

<FilterBuilder {columns} onRunQuery={handleQuery} class="max-h-[min(40rem,80vh)]" />

Filters

Build conditions against the available columns.

No filters yet.

Query

No conditions ready

No filters yet.

Bind filters

Keep conditions, match mode, and groups in your own state.

<script lang="ts">
	import {
		FilterBuilder,
		type FilterBuilderGroup,
		type FilterBuilderItem,
		type FilterMatchMode
	} from '.';

	let filters: FilterBuilderItem[] = [];
	let matchMode: FilterMatchMode = 'all';
	let groups: FilterBuilderGroup[] = [];
</script>

<FilterBuilder
	{columns}
	bind:filters
	bind:matchMode
	bind:groups
	preview="sql"
	onchange={(next) => console.log(next)}
/>

Theming

Override slots through classes or a ThemeConfig entry for filterBuilder.

<FilterBuilder
	{columns}
	classes={{
		base: 'rounded-sm',
		rule: 'gap-3',
		group: 'bg-primary-50/40'
	}}
/>

Props

PropTypeDefaultDescription
columnsFilterBuilderColumnConfig[][]Available columns
filtersFilterBuilderItem[][]Bindable root conditions
matchModeall | anyallDefault join for newly added filters/groups
groupsFilterBuilderGroup[][]Bindable one-level subgroups
previewsql | json | both | falsebothPreview panel mode
previewCollapsiblebooleantrueShow collapse control on the query panel
previewCollapsedbooleanfalseBindable collapsed state for the query panel
titlestringFiltersBuilder heading
descriptionstring—Builder subtext
previewTitlestringQueryPreview heading
runLabelstringRun queryPrimary action label
addLabelstringAdd filterAdd condition label
addGroupLabelstringAdd groupAdd group label
clearLabelstringClearClear button label
emptyMessagestringNo filters yet.Empty state copy
onRunQuery(val: FilterBuilderExport) => void—Fired by Run query
onchange(filters: FilterBuilderItem[]) => void—Fired after root filter edits
class / classestheme slots—Styling hooks

© 2026 Bitblue is a registered trademark. All Rights Reserved.