Catalog filters drawer — Storefront block

Free

storefront-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-drawer

Usage

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.

PropTypeDescription
facets*Facet[]Datathe facets of the current result, with their counts and what is selected
action*stringActionthe page the filters apply to: the form is a GET to its address, and "Clear all" leads back to it
total*numberDatathe number of products the current filters give
sortSortthe sort menu: the orders offered and the one chosen
keepRecord<string, string>Dataparameters of the address the form must keep (a search query, a view), sent as hidden fields
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Facet facets[] · 6 props
PropTypeDescription
key*stringDatathe parameter of the address ("colour", "size")
label*stringWordsthe 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
valuesValue[]the values (not for a range)
rangeRangethe bounds, for kind range
openbooleanthe group starts open in the column and the drawer; true by default
Value facets[].values[] · 5 props
PropTypeDescription
value*stringDatathe value sent in the address ("black", "42")
label*stringWordswhat the visitor reads ("Black", "42")
countnumberhow many products the value gives, from the tool: never computed here. 0 disables the value
selectedbooleanthe value is in the address now
colorstringDesigna CSS colour for a swatch ("navy", "oklch(…)"); with `kind` swatch
Range facets[].range · 5 props
PropTypeDescription
min*numberthe lowest value in the catalogue
max*numberthe highest value in the catalogue
fromnumberthe minimum now in the address
tonumberthe maximum now in the address
unitstringWordsthe unit written after the numbers ("€")
Sort sort · 2 props
PropTypeDescription
options*Option[]the orders offered; the first is the default
valuestringDatathe order now in the address
Option sort.options[] · 2 props
PropTypeDescription
value*stringDesigna sort key the backend knows
label*stringWords("Price, low to high")
Options options · 4 props
PropTypeDescription
titlestringWordsthe drawer’s title ("Filters")
unitstringWordswhat the count counts ("products")
collapsenumbervalues shown before "See more", 6 by default
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa 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).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour 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:

KeyEnglishFrench
filters.activeActive filtersFiltres actifs
filters.applyApplyAppliquer
filters.clearClear allTout effacer
filters.removeRemove filter {label}Retirer le filtre {label}
filters.sortSort byTrier par
filters.titleFiltersFiltres
filters.viewView {total} resultsVoir les {total} résultats
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo 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 facets from 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.

All 409 storefront blocks