FilterBar
Composable filter layout with HTMX integration and optional apply mode.
Quick Start
Live Preview
Auto vs Apply Mode
mode="auto"triggers HTMX on change and keyupmode="apply"renders an Apply button
Reset Button
HTMX Integration
FilterBar(
*filters,
endpoint="/reports",
method="get",
hx_target="#results",
hx_swap="outerHTML",
push_url=True,
)
Layout Control
Use filters_cls and actions_cls to adjust spacing or alignment.
Security Notes
Validate filters server-side. If you use method="post", enable CSRF protection.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
*filters |
Any |
Filter controls to render. | |
endpoint |
str \| None |
None |
Form action and optional HTMX endpoint. |
method |
"get" \| "post" |
"get" |
Submit method. |
mode |
"auto" \| "apply" |
"auto" |
Auto-submit on change or render Apply button. |
apply_label |
str |
"Apply" |
Apply button text in apply mode. |
apply_variant |
Bootstrap variant | "primary" |
Apply button variant. |
reset_label |
str \| None |
None |
Reset link label. |
reset_href |
str \| None |
None |
Reset link target. |
debounce |
int |
300 |
HTMX debounce in milliseconds for auto mode. |
hx_target |
str \| None |
None |
HTMX target selector. |
hx_swap |
str \| None |
"outerHTML" |
HTMX swap style. |
push_url |
bool |
False |
Push URL for HTMX GET flows. |
filters_cls / actions_cls / form_cls |
str \| None |
None |
Styling hooks. |
**kwargs |
Any |
Extra form attributes. |
API Reference
faststrap.components.forms.filter_bar.FilterBar(*filters, endpoint=None, method='get', mode='auto', apply_label='Apply', apply_variant='primary', reset_label=None, reset_href=None, debounce=300, hx_target=None, hx_swap='outerHTML', push_url=False, filters_cls=None, actions_cls=None, form_cls=None, **kwargs)
Composable filter bar with optional HTMX integration.