Navigation links for filtering a dataset by a category, status, owner, or other attribute.
This component only renders the filter navigation. Your SQL query is responsible for filtering the data based on the URL parameter selected by the user.
Use it alongside a table, list, or card. The links use GET parameters, so the selected filter can be bookmarked and shared.
Set compact to display the facets in a dropdown, which is useful for a moderate number of choices or on narrow screens. Use selected_facet to show the active facet in the closed dropdown. all_link and all_title add a link that clears the filter.
The following portable pattern filters a table by category. sqlpage.link preserves the current page path while safely generating the URL.
select 'table' as component;
select title, category
from my_table
where $category is null or category = $category;
select 'facet' as component,
'Category' as description,
sqlpage.link(sqlpage.path(), json_object('category', null)) as all_link,
$category is null as all_active;
select category as title,
sqlpage.link(sqlpage.path(), json_object('category', category)) as link,
category = $category as active
from my_table
group by category
order by category;