Compare wide — Comparison block
Freecomparison-compare-wide · for home, product, landing pages
Compare wide
The title and text above, the two pictures across the page: a detail worth seeing large
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/comparison-compare-wideUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import ComparisonCompareWide from '@/components/trame/blocks/comparison/comparison-compare-wide.vue'
const props = {
title: "Before and after plant dyeing",
text: "The same T-shirts, photographed in the same spot, before and after a bath of madder and weld. Drag the slider to see the difference.",
before: {
image: "https://images.unsplash.com/photo-1705250466297-90035b3a2b26?w=1600&q=80&sat=-100",
alt: "Rolled-up T-shirts in undyed cotton",
label: "Before"
},
after: {
image: "https://images.unsplash.com/photo-1705250466297-90035b3a2b26?w=1600&q=80",
alt: "The same T-shirts, dyed from green to blue",
label: "After"
},
options: {
eyebrow: "Our workshop"
}
}
</script>
<template>
<ComparisonCompareWide v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordswhat the visitor is invited to compare |
| before* | Before | the first picture: before, or the first option |
| after* | After | the second picture: after, or the second option |
| text | string | Wordswhat changed, and how the business knows |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Before before · 3 props
| Prop | Type | Description |
|---|---|---|
| image* | string | Picturea real picture of the subject, in the same frame as the other side |
| alt* | string | Wordswhat this picture shows |
| label | string | Wordsthe chip on its side, plainly ("New", "After 800 km") |
After after · 3 props
| Prop | Type | Description |
|---|---|---|
| image* | string | Picturea real picture of the subject, in the same frame as the other side |
| alt* | string | Wordswhat this picture shows |
| label | string | Wordsthe chip on its side, plainly ("New", "After 800 km") |
Options options · 3 props
| Prop | Type | Description |
|---|---|---|
| eyebrow | string | Wordsa few words above the title |
| initial | number | where the split starts, in % from the left (50 by default); side by side, how the width is shared and which side a phone shows first |
| 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 comparison section, for home, product, landing pages; it uses @lucide/vue, clsx, motion, tailwind-merge.
Built with
The components this block is made of; each one installs on its own too.
More comparison blocks
- Before after count contrast: two huge figures (9 steps, then 3) with their lists under: when one number tells the story.
- Before after pros cons: two panels, "for whom" tinted and "not for whom" quiet: an honest statement of fit.
- Before after two lists: the old way struck through on the left, the new way framed on the right, totals underneath: step-by-step savings.
- Cost bars: the merchant’s cost against another cost the merchant sourced, as two bars and a sentence: when a saving is real.
- Fit matrix: options as columns and situations as rows with a mark per cell: compatibility, "this bag goes with…".
- Head to head choice cards: 2 to 4 cards, each with its price, what it adds over the previous and its points: tiers, sizes and variants.
- Head to head dimension rows: each criterion a row with the answers side by side in sentences: 3 to 6 dimensions that need words, not marks.
- Head to head versus split: two panels, ours and the other, each a list of points grouped by theme: 4 to 8 points without a table feel.