Product compare table — Storefront block
Freestorefront-product-compare-table · for product, catalog pages
Product compare table
Two to four models side by side in a plain grid, the current one tinted: the usual comparison of a small range
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-product-compare-tableUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontProductCompareTable from '@/components/trame/blocks/storefront/storefront-product-compare-table.vue'
const props = {
title: "Which bag should you choose?",
products: [
{
id: "p1",
name: "Line 20 bag",
price: 8900,
summary: "The everyday companion.",
image: "https://images.unsplash.com/photo-1680039211156-66c721b87625?w=1600&q=80",
alt: "A black flap backpack on a yellow background",
specs: {
weight: "1.4 lb",
capacity: "20 L",
material: "Recycled canvas",
warranty: "2 years",
origin: "Portugal"
}
},
{
id: "p2",
name: "Line 28 bag",
price: 10900,
summary: "For the whole day.",
image: "https://images.unsplash.com/photo-1641934725990-1326a660c184?w=1600&q=80",
alt: "A midnight blue mesh backpack with a cognac leather flap",
specs: {
weight: "1.7 lb",
capacity: "28 L",
material: "Recycled canvas",
warranty: "2 years",
origin: "Portugal"
}
}
],
rows: [
{
key: "weight",
label: "Weight",
group: "The product"
},
{
key: "capacity",
label: "Capacity",
group: "The product"
}
],
currentId: "p2",
action: {
label: "See this model",
action: "product"
}
}
</script>
<template>
<StorefrontProductCompareTable v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordswhat is compared ("Which model to choose?") |
| products* | Product[] | Data2 to 4 products of the same family (more switch to the swipe layout) |
| rows* | Row[] | the attributes compared, in order |
| currentId | string | number | Datathe id of the product the visitor is looking at, marked in the grid |
| action | Action | the call to action: its words and the page action it runs |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Product products[] · 20 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| price* | number | an amount in cents |
| compareAt | number | the price before the merchant’s reduction |
| currency | string | DesignISO 4217, EUR by default |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| images | string[] | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the main picture shows |
| brand | string | Wordsthe brand or maker |
| category | string | Wordsthe product’s category, e.g. "Knitwear" |
| summary | string | Wordsone short line on the product |
| badge | string | Wordsa short tag the merchant set ("New", "Handmade") |
| rating | number | the average of the shop’s own stored reviews |
| reviewCount | number | how many stored reviews the rating averages |
| available | boolean | false: sold out; true or absent: can be bought |
| stock | number | the real stock, when the merchant shows it |
| maxQuantity | number | the most one order may hold of it, as the merchant set it (one per customer, a limited run) |
| options | Option[] | the product’s options and their values, e.g. sizes |
| highlights | Highlight[] | a few key facts the merchant set, shown on the product’s card |
| specs | Record<string, string> | the product’s attributes by row key, as the catalogue holds them |
Option products[].options[] · 2 props
| Prop | Type | Description |
|---|---|---|
| name* | string | Wordsthe option’s name, e.g. "Size" |
| values* | string[] | Wordsits values, e.g. "S", "M", "L" |
Highlight products[].highlights[] · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe property ("Material", "Capacity") |
| value* | string | Wordsits value, as the merchant states it ("Washed linen", "50 cl") |
Row rows[] · 3 props
| Prop | Type | Description |
|---|---|---|
| key* | string | Designthe key of the attribute in each product’s specs |
| label* | string | Wordsthe attribute ("Battery life") |
| group | string | Wordsthe group it belongs to ("Comfort"), when rows are grouped |
Action action · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordsthe button on each column ("See this model") |
| action* | string | Actiona named action of the page |
Options options · 2 props
| Prop | Type | Description |
|---|---|---|
| caption | string | Wordsa sentence under the title, as the merchant writes it |
| 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 |
| money | formats a price, given in cents |
| asset | a picture’s address as your app serves it |
| Link | your router’s link component |
| 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 |
|---|---|---|
| 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
- No motion; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
action - Reads
productsfrom your app
A storefront section, for product, catalog pages; it uses @lucide/vue, @vueuse/core, 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
- Product close ups film: tall close-ups in a row that scrolls sideways, each name over its foot, the piece leading the row as its first card: a product page band that shows the making quality without a long read.
- Product close ups index: a numbered list of the details beside one large close-up that changes as a detail is chosen, the piece’s card under the list: a few details with real explanations, read one at a time.
- Product close ups loupes: each detail in a round close-up like a magnifying glass, set in staggered balanced rows with its name and note under it, the piece itself in a card at the head: three to twelve details of a crafted piece (leather, knitwear, ceramics).
- Product configurator compact: a product page’s buy box with one or two options: a thumbnail, the choices in a row, the total and the button, no second column.
- Product configurator side by side: a made-to-order page of its own: the picture stays in view on one side while every option runs down the other, the recap at the end.
- Product dimensions diagram: A dimension drawing with exact measurements, enlarged in a dialog with an all-media tab; the merchant’s own only.
- Product facets radial: one product with 3 to 6 named facets around its picture: a single object seen from several sides.
- Product features accordion picture: a few features that each deserve a sentence: a picture beside an accordion, the picture following the open panel.