Catalog filters drawer — Storefront block
Freestorefront-catalog-filters-drawer · for catalog, search pages
Catalog filters drawer
Only a "Filters (n)" button that opens the drawer of facets and sort: for small catalogues and pages where the filters should stay out of the way
Documentation
Installation
One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).
pnpm dlx shadcn-vue@latest add @trame/storefront-catalog-filters-drawerUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontCatalogFiltersDrawer from '@/components/trame/blocks/storefront/storefront-catalog-filters-drawer.vue'
const props = {
action: "catalog",
total: 128,
sort: {
options: [
{
value: "pertinence",
label: "Relevance"
},
{
value: "nouveautes",
label: "Newest"
}
],
value: "pertinence"
},
options: {
title: "Filters",
unit: "products"
},
facets: [
{
key: "categorie",
label: "Category",
values: [
{
value: "chaussures",
label: "Shoes",
count: 42
},
{
value: "sacs",
label: "Bags and luggage",
count: 31
}
]
},
{
key: "couleur",
label: "Color",
kind: "swatch",
values: [
{
value: "noir",
label: "Black",
count: 38,
color: "black"
},
{
value: "sable",
label: "Sand",
count: 24,
color: "tan"
}
]
}
]
}
</script>
<template>
<StorefrontCatalogFiltersDrawer v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| facets* | Facet[] | Datathe facets of the current result, with their counts and what is selected |
| action* | string | Actionthe page the filters apply to: the form is a GET to its address, and "Clear all" leads back to it |
| total* | number | Datathe number of products the current filters give |
| sort | Sort | the sort menu: the orders offered and the one chosen |
| keep | Record<string, string> | Dataparameters of the address the form must keep (a search query, a view), sent as hidden fields |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Facet facets[] · 6 props
| Prop | Type | Description |
|---|---|---|
| key* | string | Datathe parameter of the address ("colour", "size") |
| label* | string | Wordsthe group’s title ("Colour") |
| kind | 'list' | 'swatch' | 'chips' | 'range' | list: checkboxes with counts; swatch: colour dots; chips: short values in a grid (sizes); range: a minimum and a maximum |
| values | Value[] | the values (not for a range) |
| range | Range | the bounds, for kind range |
| open | boolean | the group starts open in the column and the drawer; true by default |
Value facets[].values[] · 5 props
| Prop | Type | Description |
|---|---|---|
| value* | string | Datathe value sent in the address ("black", "42") |
| label* | string | Wordswhat the visitor reads ("Black", "42") |
| count | number | how many products the value gives, from the tool: never computed here. 0 disables the value |
| selected | boolean | the value is in the address now |
| color | string | Designa CSS colour for a swatch ("navy", "oklch(…)"); with `kind` swatch |
Range facets[].range · 5 props
| Prop | Type | Description |
|---|---|---|
| min* | number | the lowest value in the catalogue |
| max* | number | the highest value in the catalogue |
| from | number | the minimum now in the address |
| to | number | the maximum now in the address |
| unit | string | Wordsthe unit written after the numbers ("€") |
Sort sort · 2 props
| Prop | Type | Description |
|---|---|---|
| options* | Option[] | the orders offered; the first is the default |
| value | string | Datathe order now in the address |
Option sort.options[] · 2 props
| Prop | Type | Description |
|---|---|---|
| value* | string | Designa sort key the backend knows |
| label* | string | Words("Price, low to high") |
Options options · 4 props
| Prop | Type | Description |
|---|---|---|
| title | string | Wordsthe drawer’s title ("Filters") |
| unit | string | Wordswhat the count counts ("products") |
| collapse | number | values shown before "See more", 6 by default |
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
What it asks your app for
The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your word for an interface key, or undefined to keep the block’s own |
The words it says itself, in English and French; label(key) replaces any of them:
| Key | English | French |
|---|---|---|
| filters.active | Active filters | Filtres actifs |
| filters.apply | Apply | Appliquer |
| filters.clear | Clear all | Tout effacer |
| filters.remove | Remove filter {label} | Retirer le filtre {label} |
| filters.sort | Sort by | Trier par |
| filters.title | Filters | Filtres |
| filters.view | View {total} results | Voir les {total} résultats |
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
Features
- Every word in the server HTML
- Same markup in Vue and React
- Theme tokens only: every theme, light and dark
- Shows what you give it, invents nothing
- Subtle motion: one short reveal; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
action - Reads
facetsfrom your app
A storefront section, for catalog, search pages; it uses @lucide/vue, clsx, tailwind-merge.
More storefront blocks
- Cart with suggestions folded rail: a classic narrow drawer whose suggestions fold under the lines, one large card at a time: a shop where the cart comes first and suggestions stay discreet.
- Cart with suggestions side column: a wide drawer after an addition: a column of suggestion cards against the cart, for a shop with several good companions to its products.
- Catalog browse search tiles: a wide field, then the categories as picture tiles and the popular searches in a band: a shop where visitors browse as much as they type.
- Catalog drawer: a single "Filters (n)" button above a full-width grid, the facets in a drawer: for small catalogues and calm pages.
- Catalog sidebar: the facets in a column beside the grid on a wide screen, in a drawer on a phone: the standard catalogue page, for shops with several facets.
- Catalog top bar: a bar of facet menus above a full-width grid: for catalogues with two to five facets, where the pictures should have all the room.
- Category campaign banner in grid: four or five tiles and the merchant’s own announcement tile in the last cell: a campaign among categories.
- Category comparison compare table: three or four categories against the same specifications: a technical catalogue where the choice is a comparison.