Product configurator side by side — Storefront block

Pro

storefront-product-configurator-side-by-side · for product pages

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

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-configurator-side-by-side

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontProductConfiguratorSideBySide from '@/components/trame/blocks/storefront/storefront-product-configurator-side-by-side.vue'

const props = {
title: "Make it your own",
product: {
id: "gourde-75",
name: "Insulated bottle 25 oz",
price: 3900,
image: "https://images.unsplash.com/photo-1605714312496-01e90cb509cc?w=1600&q=80",
alt: "A white steel water bottle"
},
steps: [
{
id: "couleur",
label: "Color",
kind: "swatch",
help: "Powder-coated, matte",
choices: [
{
id: "acier",
label: "Brushed steel",
color: "oklch(0.86 0.01 250)",
image: "https://images.unsplash.com/photo-1664714628878-9d2aa898b9e3?w=1600&q=80",
alt: "A brushed aluminum bottle with a black cap, on a gray background"
},
{
id: "sapin",
label: "Fir green",
color: "oklch(0.42 0.07 160)",
price: 500,
image: "https://images.unsplash.com/photo-1602143407151-7111542de6e8?w=1600&q=80",
alt: "A plain green insulated bottle"
}
]
},
{
id: "contenance",
label: "Capacity",
kind: "choice",
choices: [
{
id: "50",
label: "17 oz"
},
{
id: "75",
label: "25 oz"
}
]
}
],
addAction: "cart.add",
addLabel: "Add my bottle to the cart",
note: "Made to order in five business days. An engraved bottle cannot be returned.",
options: {
eyebrow: "Custom",
summaryLabel: "Your selection",
baseLabel: "Bottle 25 oz"
}
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe heading ("Make it your own")
product*ProductDatathe product being personalised; its price is the base price, in cents
steps*Step[]Datathe product’s options, in the order the visitor makes them
addAction*stringActionthe page action that receives the chosen options (posted as a form: product, then one field per step)
addLabelstringWordswhat the button says ("Add my bottle to the cart")
notestringWordswhat the merchant says about personalised items ("Made to order, not returnable")
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Product product · 5 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
price*numberan amount in cents
imagestring | nullPicturethe main picture; null or absent: the product has none yet
altstringWordswhat the main picture shows
Step steps[] · 11 props
PropTypeDescription
id*stringthe option’s key, posted as the field name
label*stringWordsthe step’s name ("Colour", "Engraving")
kind*'swatch' | 'choice' | 'text' | 'toggle'swatch: colours; choice: sizes or finishes as buttons; text: a free text shown on the picture; toggle: a yes/no extra (gift wrap)
helpstringWordsone line under the step’s name ("Up to 18 characters, capitals")
choicesChoice[]the choices offered, for kind swatch or choice
pricenumberfor text and toggle: what the option adds, in cents
placeholderstringWordsfor text: the field’s example ("Your initials")
valuestringWordsfor text: the words the field starts with; absent for an empty field
maxLengthnumberfor text: the number of characters
requiredbooleantrue: the visitor must answer this step before adding to the cart
preview'center' | 'top' | 'bottom'for text: where the words sit on the picture
Choice steps[].choices[] · 8 props
PropTypeDescription
id*stringthe choice’s key, posted as the field’s value
label*stringWordsthe choice’s name, e.g. "Forest green"
pricenumberwhat this choice adds to the price, in cents; absent when it is free
colorstringDesignthe swatch’s CSS colour, for kind swatch
imagestringPicturethe product picture for this choice (a colour’s picture), if the merchant has one
altstringWordswhat the choice’s picture shows
notestringWordsa short note ("Back in March")
unavailablebooleantrue: the choice is shown but cannot be picked
Options options · 4 props
PropTypeDescription
eyebrowstringWordsa small line above the heading
summaryLabelstringWordsthe heading of the recap ("Your selection")
baseLabelstringWordsthe line of the base price ("75 cl bottle")
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
moneyformats a price, given in cents
asseta picture’s address as your app serves it
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
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: addAction
  • Reads products from your app

A storefront section, for product 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 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 compare cards above: product cards over a grouped table whose header stays in view: a large range with many attributes.
  • Product compare swipe: phone-first: columns scroll sideways and snap, the attribute names pinned; chosen automatically beyond four products.
  • 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.
  • 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.
  • Product features alternating: the usual story of a product: a picture and a selling point per row, sides swapping each time.

All 409 storefront blocks