Skip to content

FilterDialog

A button that opens the filter editor in a dialog. Edits are staged: only Apply emits.

Terminal window
pnpm dlx shadcn@latest add https://sg-widgets.vercel.app/r/react/filter-dialog.json
Terminal window
pnpm dlx shadcn-svelte@latest add https://sg-widgets.vercel.app/r/svelte/filter-dialog.json
FilterDialog: empty, two filters applied, a Note read-state row, and sizes

React

Loading the React demo…

Svelte

Loading the Svelte demo…

With no filters it is one Add filters button. With filters applied it becomes Edit filters, carries the count of conditions that would be sent, and gains a control that clears them without opening anything.

proptypedefaultmeaning
entityTypestringrequiredType the editor reads its fields on.
contextSgContextrequiredThe widget context. Every read goes through it, so widgets on a page share one cache.
valueFilterGrouprequiredThe applied tree. Two-way in Svelte through bind:value.
hidePathsstring[][]Passed through to the editor.
labelstring—Replaces both button labels.
titlestring'Filters'Dialog title.
disabledbooleanfalseBlocks both buttons.
openbooleanfalseWhether the dialog is showing. Two-way in Svelte.
size'sm' | 'md' | 'lg''md'Launcher heights 7, 8 and 9. Passed to the editor inside.
class / classNamestring—Merged after the widget's own classes.

Every other attribute is spread onto the root: id, aria-*, data-*, key handlers and a ref to the root element.

eventpayloadwhen
onValueChangeFilterGroupThe tree was applied, by Apply, Clear all or the clear control, never while editing. Svelte also binds it with bind:value.
onOpenChangebooleanThe dialog opened or closed. Svelte also binds it with bind:open.

The three the editor takes, forwarded unchanged.

slotreceivesdraws
fieldChooserentityType, the current path, hidePaths, filterableOnly, disabled, onSelect(path)The field chooser, in place of FieldPicker.
valueEditorfield, dataType, operator, value, arity, disabled, onChange(value)Every value control in the editor.
entityEditorthe same arguments as the value editorThe two entity pickers alone.
keydoes
Enter, SpaceOpens the dialog from the launcher.
TabCycles inside the dialog while it is open.
EscapeCloses the dialog and drops the staged edits.

Apply sends the tree through the same serialiser the editor shows: a tree whose rows are all blank applies as no filter, because a group with no conditions matches every row (030_complex_filters).