Fit by size tabs — Storefront block
Prostorefront-fit-by-size-tabs · for product pages
Fit by size tabs
A size at a time: a row of size chips, and under it that size’s measurements and the models who wear it, to picture it before choosing
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-fit-by-size-tabsUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontFitBySizeTabs from '@/components/trame/blocks/storefront/storefront-fit-by-size-tabs.vue'
const props = {
title: "Find your size",
intro: "Our measurements are taken flat on the finished garment. Compare them with a piece you already wear.",
chart: {
columns: [
"Chest (cm)",
"Waist (cm)"
],
rows: [
{
size: "XS",
values: [
84,
70
]
},
{
size: "S",
values: [
90,
76
]
}
]
},
models: [
{
name: "Ivy",
size: "S",
image: "https://images.unsplash.com/photo-1538516089546-40b08c9c9866?w=1600&q=80",
alt: "Ivy in a navy rain jacket, size S",
height: "5′4″",
measurements: [
{
label: "Chest",
value: "86 cm"
},
{
label: "Waist",
value: "68 cm"
}
],
note: "Fitted cut, sleeves the right length."
},
{
name: "Hugo",
size: "L",
image: "https://images.unsplash.com/photo-1578100044626-110806c15b00?w=1600&q=80",
alt: "Hugo in a denim jacket, size L",
height: "5′11″",
measurements: [
{
label: "Chest",
value: "98 cm"
},
{
label: "Waist",
value: "82 cm"
}
],
note: "A little room in the shoulders, comfortable over a sweater."
}
]
}
</script>
<template>
<StorefrontFitBySizeTabs v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe block’s title ("Size guide") |
| intro | string | Wordshow to read it, or how to measure ("Measure yourself without thick clothing"), as the merchant wrote it |
| chart* | Chart | Datathe size table; numbers are centimetres and convert to inches, strings stay as written |
| models* | Model[] | the models who wear the piece, each with their size and measurements |
| unit | string | Designcm | in: the unit the chart opens in |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Chart chart · 2 props
| Prop | Type | Description |
|---|---|---|
| columns* | string[] | measurements, in the order of each row’s values ("Chest") |
| rows* | Row[] | the chart’s rows, in order |
Row chart.rows[] · 2 props
| Prop | Type | Description |
|---|---|---|
| size* | string | the size, e.g. "M" |
| values* | (number | string)[] | the measurements for this size, one per column |
Model models[] · 7 props
| Prop | Type | Description |
|---|---|---|
| name* | string | Wordsa first name or a label ("Model 1"), a real model of the merchant |
| image | string | Picturea picture: a root-relative path (/media/…) or an absolute URL |
| alt | string | Wordswhat the picture shows |
| height | string | Words("1.78 m") |
| measurements | Measurement[] | the model’s measurements, each a label and a value |
| size* | string | Wordsthe size worn ("M") |
| note | string | Wordshow it fits this person |
Measurement models[].measurements[] · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Wordswhat the value is about |
| value* | string | Wordsthe value, as the merchant states it |
Options options · 2 props
| Prop | Type | Description |
|---|---|---|
| unitToggle | boolean | offer the cm / in switch on the chart (on 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 |
| asset | a picture’s address as your app serves it |
| 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
- Subtle motion: one short reveal; still under reduced motion
- Real buttons and links, a visible focus
A storefront section, for product pages; it uses 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
- Featured selection flanked: the first product in the middle on a tinted stage with its two buttons, the others flanking it in two columns like pieces either side of a shop window: one product to crown, with three to six around it; the merchant’s own products and figures only.
- Featured selection grid: the first product double-sized with two buttons, then a grid: one product to push among others; the merchant’s own products and figures only.
- Finder intro card: A question prompt, step count and image strip invite the visitor to start the quiz, with micro motion only.
- Finder results cards: Recommended product cards with reasons, restart and see-all actions conclude a quiz; the merchant’s own rules only, with micro motion only.
- Fit models cards: clothes worn by real people: height, measurements and the size each one wears, to compare with oneself.
- Floating products staggered: two staggered columns of tall cards whose pictures drift at opposite paces as the page scrolls: an editorial run of 4 to 12 products; the merchant’s own products and figures only.
- Fulfilment choice cards: a product that can be delivered or picked up: a switch and the stores with their distance and stock.
- Fulfilment estimator card: a bordered card listing every shipping option with its delay and price: a cart or a product with several carriers.