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
betweenfor 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
| Property | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Column identifier used in the export |
label | string | Yes | Label shown in the UI |
type | string | number | date | boolean | Yes | Drives 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
| Prop | Type | Default | Description |
|---|---|---|---|
columns | FilterBuilderColumnConfig[] | [] | Available columns |
filters | FilterBuilderItem[] | [] | Bindable root conditions |
matchMode | all | any | all | Default join for newly added filters/groups |
groups | FilterBuilderGroup[] | [] | Bindable one-level subgroups |
preview | sql | json | both | false | both | Preview panel mode |
previewCollapsible | boolean | true | Show collapse control on the query panel |
previewCollapsed | boolean | false | Bindable collapsed state for the query panel |
title | string | Filters | Builder heading |
description | string | — | Builder subtext |
previewTitle | string | Query | Preview heading |
runLabel | string | Run query | Primary action label |
addLabel | string | Add filter | Add condition label |
addGroupLabel | string | Add group | Add group label |
clearLabel | string | Clear | Clear button label |
emptyMessage | string | No filters yet. | Empty state copy |
onRunQuery | (val: FilterBuilderExport) => void | — | Fired by Run query |
onchange | (filters: FilterBuilderItem[]) => void | — | Fired after root filter edits |
class / classes | theme slots | — | Styling hooks |