NSW Design System

Enable js flag on filter to activate "Apply" button only when filters selected. This parameter is also required when you pass collapsible into facet_section. Collapsible facets are initially collapsed and have an icon next to title, when at least one facet from the section is active.

Note, filters component needs a form to apply filters. By default GET form for the current page is added around the filters. To use existing form, set form_id parameter of the filters component to its ID. You'll need to do the same with facets if using external form. As for normal input fields, they require attrs={"form": form_id} parameter.

{%- call ui.util.call(show_example) -%} {%- raw %} {% set id = ui.util.id() -%}
{%- call ui.util.call(ui.filters, form_id=id, js=true, instant=true) -%} {%- call ui.util.call(ui.facet_section, title="Cool facet", collapsible=true) -%} {{ ui.facet("First value", key="cool", form_id=id) }} {{ ui.facet("Second value", key="cool", form_id=id) }} {%- endcall %} {%- call ui.util.call(ui.facet_section, title="Non-collapsible") -%} {{ ui.facet("First value", key="not-cool", form_id=id) }} {{ ui.facet("Second value", key="not-cool", form_id=id) }} {%- endcall %} {%- endcall %} {%- endraw %} {%- endcall %}

When js is enabled on filters, you can specify collapse behavior on small screens for the whole filter panel. Set collapse_direction parameter to down or right, and filters panel will be collapsed initially, expanding according to the specified direction upon click. Note, this will apply only for mobile devices. On desktop filters will remain visible.

{%- call ui.util.call(show_example) -%} {%- raw %} {% call ui.util.call(ui.filters, collapse_direction="down", js=true) -%} {%- call ui.util.call(ui.facet_section, title="Cool facet") -%} {{ ui.facet("First value", key="cool", form_id=id) }} {{ ui.facet("Second value", key="cool", form_id=id) }} {%- endcall %} {%- endcall %} {%- call ui.util.call(ui.filters, collapse_direction="right", js=true) -%} {%- call ui.util.call(ui.facet_section, title="Cool facet") -%} {{ ui.facet("First value", key="cool", form_id=id) }} {{ ui.facet("Second value", key="cool", form_id=id) }} {%- endcall %} {%- endcall %} {%- endraw %} {%- endcall %}

You can use arbitrary inputs inside facet section. Put them directly into facet_section. If facet section contains a single field leave the label empty because facet section already has title that identifies the field.

{%- call ui.util.call(show_example) -%} {%- raw %} {% call ui.util.call(ui.filters, collapse_direction="down", js=true) -%} {%- call ui.util.call(ui.facet_section, title="Cool facet") -%} {{ ui.select(name='select-filter', options=[{"value": ""}, {'value': "A"},{'value': "B"}]) }} {%- endcall %} {%- endcall %} {%- call ui.util.call(ui.filters, collapse_direction="right", js=true) -%} {%- call ui.util.call(ui.facet_section, title="Multi-input facet", collapsible=true) -%} {{ ui.input(name='select-input', label="Input") }} {{ ui.nds_date_input_group(name='date-input', label="Date") }} {%- endcall %} {%- endcall %} {%- endraw %} {%- endcall %}