Catalog sidebar — Storefront block

Pro

storefront-catalog-sidebar · for catalog 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

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-sidebar

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontCatalogSidebar from '@/components/trame/blocks/storefront/storefront-catalog-sidebar.vue'

const props = {
title: "Low Light, fall–winter",
intro: "Coats and knitwear cut in our studio, in wool that lasts. We repair everything we sell.",
results: {
items: [
{
id: "p1",
name: "Long wool coat, charcoal",
price: 42000,
image: "https://images.unsplash.com/photo-1782694308249-917d2599b46f?w=1600&q=80",
images: [
"https://images.unsplash.com/photo-1782694308249-917d2599b46f?w=1600&q=80",
"https://images.unsplash.com/photo-1790802195673-357071dfa500?w=1600&q=80"
],
alt: "A woman in a long dark coat by stone columns, in black and white",
brand: "Ostra",
badge: "New",
options: [
{
name: "Size",
values: [
"XS",
"S"
]
}
],
summary: "Double-faced virgin wool, hand-finished seams, falls below the knee.",
rating: 4.6,
reviewCount: 38
},
{
id: "p2",
name: "Black cotton trench",
price: 32000,
compareAt: 38000,
image: "https://images.unsplash.com/photo-1790802195673-357071dfa500?w=1600&q=80",
images: [
"https://images.unsplash.com/photo-1790802195673-357071dfa500?w=1600&q=80",
"https://images.unsplash.com/photo-1782694308249-917d2599b46f?w=1600&q=80"
],
alt: "A woman in a black trench coat and a gray slip dress on a city sidewalk",
brand: "Ostra",
options: [
{
name: "Color",
values: [
"Charcoal",
"Ecru"
]
}
],
summary: "Dense cotton gabardine, storm flap, belt with a horn buckle.",
rating: 4.8,
reviewCount: 112
}
],
total: 64,
facets: [
{
key: "categorie",
label: "Category",
values: [
{
value: "coats",
label: "Coats",
count: 18
},
{
value: "knitwear",
label: "Knitwear",
count: 14
}
]
},
{
key: "couleur",
label: "Color",
kind: "swatch",
values: [
{
value: "noir",
label: "Black",
count: 16,
color: "black"
},
{
value: "sable",
label: "Camel",
count: 12,
color: "tan"
}
]
}
],
sort: "pertinence"
},
action: "catalog",
open: "product",
add: "cart.add",
pagination: {
total: 64,
page: 1,
pageSize: 9,
mode: "more",
action: "catalog",
unit: "pieces"
},
options: {
sorts: [
{
value: "pertinence",
label: "Relevance"
},
{
value: "nouveautes",
label: "Newest"
}
],
unit: "pieces",
showRating: true
}
}
</script>

<template>
<StorefrontCatalogSidebar v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
titlestringWordsthe page’s title, an h2 here (the page’s h1 is CollectionHeader’s): "All our products"
introstringWordsone sentence under the title, in the merchant’s words
results*ResultsDatathe filtered catalogue: what a tool answers for the page’s address
action*stringActionthe page the filters apply to: the form is a GET to its address, and "Clear all" leads back to it
openstringActionthe page action a product opens; it receives the product
addstringActionthe page action that puts a product in the cart (a POST); it receives the product. Products with options open instead
paginationPaginationhow the list is paged: the total, the page shown and the page action
keepRecord<string, string>Dataparameters of the address the form must keep (a search query), sent as hidden fields
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Results results · 4 props
PropTypeDescription
items*Item[]the products of this page of the result
total*numberthe real number of products the filters give, all pages together
facets*Facet[]the facets of the current result, with their counts and what is selected
sortstringDatathe order now in the address
Item results.items[] · 19 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
price*numberan amount in cents
compareAtnumberthe price before the merchant’s reduction
currencystringDesignISO 4217, EUR by default
imagestring | nullPicturethe main picture; null or absent: the product has none yet
imagesstring[]Picturea picture: a root-relative path (/media/…) or an absolute URL
altstringWordswhat the main picture shows
brandstringWordsthe brand or maker
categorystringWordsthe product’s category, e.g. "Knitwear"
summarystringWordsone short line on the product
badgestringWordsa short tag the merchant set ("New", "Handmade")
ratingnumberthe average of the shop’s own stored reviews
reviewCountnumberhow many stored reviews the rating averages
availablebooleanfalse: sold out; true or absent: can be bought
stocknumberthe real stock, when the merchant shows it
maxQuantitynumberthe most one order may hold of it, as the merchant set it (one per customer, a limited run)
optionsOption[]the product’s options and their values, e.g. sizes
highlightsHighlight[]a few key facts the merchant set, shown on the product’s card
Option results.items[].options[] · 2 props
PropTypeDescription
name*stringWordsthe option’s name, e.g. "Size"
values*string[]Wordsits values, e.g. "S", "M", "L"
Highlight results.items[].highlights[] · 2 props
PropTypeDescription
label*stringWordsthe property ("Material", "Capacity")
value*stringWordsits value, as the merchant states it ("Washed linen", "50 cl")
Facet results.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 results.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 results.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 ("€")
Pagination pagination · 6 props
PropTypeDescription
total*numberthe real number of products matching, all pages together
page*numberthe page shown, from 1
pageSize*numberhow many products a page holds
mode*'more' | 'pages'"more": a link to the next page and a progress line; "pages": numbered links
action*stringActionthe page action that leads to a page of the list; it receives { page }
unitstringWordswhat is counted ("products")
Options options · 8 props
PropTypeDescription
sortsSort[]the orders offered; the first is the default
unitstringWordswhat the count counts ("products")
collapsenumberfacet values shown before "See more", 6 by default
showRatingbooleanshow the shop’s own rating line under the price (only when the product has one)
names'display'the products’ names: "display" sets them in the theme’s display face, a step larger (a brand whose names carry its voice, a serif shop); the text face by default
emptyTextstringWordswhat the list says when the filters give nothing
layout'grid' | 'editorial' | 'rows'the list’s arrangement, a grid by default
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
Sort options.sorts[] · 2 props
PropTypeDescription
value*stringDesigna sort key the backend knows
label*stringWords("Price, low to high")
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
moneyformats a price, given in cents
asseta picture’s address as your app serves it
Linkyour router’s link component
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
cart.addedAdded to the cartAjouté au panier
catalog.clearClear allTout effacer
catalog.noMatchNo product matches these filters.Aucun produit ne correspond à ces filtres.
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
grid.chooseChoose optionsChoisir les options
grid.emptyNo product matches.Aucun produit ne correspond.
grid.pagePage {n}Page {n}
grid.paginationPaginationPagination
grid.range{from}–{to} of {total} {unit}{from}–{to} sur {total} {unit}
grid.ratingAverage rating {rating} out of 5Note moyenne {rating} sur 5
grid.saleSale pricePrix réduit
grid.shown{shown} of {total} {unit}{shown} sur {total} {unit}
grid.soldOutSold outÉpuisé
grid.wasPrice before reductionPrix avant réduction
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, open, cart.add, pagination
  • Reads products, facets from your app

A storefront section, for catalog pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.

Built with

The components this block is made of; each one installs on its own too.

More storefront blocks

  • 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 filters bar: a slim bar of facet menus over a grid that sits in its own section, sort on the right: for catalogues with two to five facets.
  • 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.
  • 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.
  • Category index alphabet: a long or picture-poor catalogue: every category as a link under its letter, from 3 to 60 of them.
  • Category index inline: a short catalogue of 3 to 20 categories set large in one flowing paragraph, each count raised after its name: a confident, type-led way in for a shop with few or no pictures.

All 409 storefront blocks