Review form card — Storefront block

Pro

storefront-review-form-card · for product, account, review pages

Review form card

One form card with the product named on top: under the reviews of a product page, or on a page of its own

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-review-form-card

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontReviewFormCard from '@/components/trame/blocks/storefront/storefront-review-form-card.vue'

const props = {
product: {
id: "p1",
name: "Trail Path running shoe",
brand: "Ridgeline",
variant: "Midnight blue · 9",
image: "https://images.unsplash.com/photo-1575987116913-e96e7d490b8a?w=1600&q=80",
alt: "Tan leather hiking boots on a rock"
},
action: "review.submit",
title: "Review your purchase",
intro: "A few honest lines help the next hiker choose the right pair.",
criteria: [
{
key: "fit",
label: "Fit",
low: "Runs small",
high: "Runs large"
},
{
key: "comfort",
label: "Comfort"
}
],
policy: "Every review is read by our team before it appears. We publish good and bad reviews alike, and never edit your words.",
terms: {
label: "Review guidelines",
action: "page.reviewTerms"
},
options: {
photos: 4,
recommend: true
}
}
</script>

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

Props

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

PropTypeDescription
product*ProductDatathe product being reviewed: the one the customer bought
action*stringActionthe mutation that receives the review; the form is hidden when the page lacks it
titlestringWordsthe heading ("Review your purchase")
introstringWordsone line under the heading, e.g. "Your words help the next customer choose"
criteriaCriteria[]aspects rated apart, each 1 to 5 stars, each optional to answer
reviewerstringWordsthe name the review is signed with when the customer is known (signed in, or from the post-purchase email); absent: the form asks a first name and an email
policystringWordshow the shop checks reviews before they appear, in its own words, e.g. "Every review is read before it is published"
termsTermsthe full review terms
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Product product · 6 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
imagestring | nullPicturethe main picture; null or absent: the product has none yet
altstringWordswhat the main picture shows
brandstringWordsthe brand or maker
variantstringWordsthe options the customer bought, written out ("Navy · 42")
Criteria criteria[] · 4 props
PropTypeDescription
key*stringDesignthe criterion’s key, posted with its stars, e.g. "fit"
label*stringWordswhat is rated, e.g. "Fit"
lowstringWordswhat one star means, e.g. "Runs small"
highstringWordswhat five stars mean, e.g. "Runs large"
Terms terms · 4 props
PropTypeDescription
label*stringWordsthe link’s words, e.g. "See the collection"
actionstringActiona named action of the page
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
urlstringDesignan address outside the app
Options options · 3 props
PropTypeDescription
photosnumberlet the customer attach up to this many photos; absent: no photo field
recommendbooleantrue: ask whether they would recommend it, with no answer chosen in advance
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
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
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: review.submit, terms
  • Reads products from your app

A storefront section, for product, account, review 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

  • Restock notify card: a sold-out product on its own: its picture, its state, one field and the shop’s promise about the address.
  • Restock notify inline row: a product page or a sold-out list: one compact row per sold-out variant with its own field and bell button.
  • Retired products rows: products no longer made with their years, quantity and reason: an honest page about what was stopped.
  • Return request stepped: the request on one page in three numbered steps (items, reason, way back), a summary beside it.
  • Returning order review bag first: a signed-in customer: the bag first, saved address and card as rows, and who is signed in at the top.
  • Review list photo first: reviews with customer photos shown as a grid first, then the rest: photo-heavy products where the pictures matter.
  • Review list two column: the summary sticky on the left, reviews scrolling on the right: a wide screen where the summary stays visible.
  • Review list: a single-column list of reviews with a summary header: the standard review page.

All 409 storefront blocks