Cost bars — Comparison block

Pro

comparison-cost-bars · for landing, app, product pages

Cost bars

The merchant’s cost against another cost the merchant sourced, as two bars and a sentence: when a saving is real

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-cost-bars

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import ComparisonCostBars from '@/components/trame/blocks/comparison/comparison-cost-bars.vue'

const props = {
eyebrow: "Estimator",
title: "Estimate your price in seconds",
lead: "Set your volumes: the math uses our exact rate card, with no hidden extras.",
inputs: [
{
key: "seats",
label: "Users",
kind: "stepper",
min: 1,
max: 50,
step: 1,
default: 5,
unit: "users",
hint: "Two are included in the plan.",
quoteFrom: 50
},
{
key: "orders",
label: "Orders per month",
kind: "slider",
min: 0,
max: 5000,
step: 100,
default: 1200,
unit: "orders"
}
],
model: {
base: 1900,
lines: [
{
input: "seats",
label: "Additional users",
rate: 800,
includedUnits: 2
},
{
input: "orders",
label: "Orders",
bands: [
{
upTo: 500,
rate: 0,
label: "Starter"
},
{
upTo: 2000,
rate: 4,
label: "Growth"
}
]
}
]
},
resultLabel: "Your estimated price",
resultUnit: "/ month",
assumption: "Prices before tax for a monthly plan, calculated with our current rate card. Your bill may vary if your volumes change.",
benchmark: {
label: "Your current solution",
source: "The vendor’s public rate card, taken from its website in March.",
model: {
base: 4900,
lines: [
{
input: "seats",
label: "Users",
rate: 1200,
includedUnits: 1
},
{
input: "orders",
label: "Orders",
rate: 3
}
]
}
},
action: {
label: "Start with this plan",
action: "signup",
record: {
id: "custom"
}
}
}
</script>

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

Props

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

PropTypeDescription
eyebrowstringWordswhat this is ("Simulator")
title*stringWordsthe section’s title ("Estimate your price")
leadstringWordsone or two sentences under the title
inputs*Input[]what the visitor sets, one to five inputs
model*Modelthe merchant’s rates the total is computed from
resultLabel*stringWordswhat the total is ("Your estimated price")
resultUnitstringWordswhat the total is per ("/ month")
assumption*stringWordsthe assumption behind the figure, as the merchant states it ("Prices excl. tax, no discount, monthly commitment")
quoteLabelstringWordswhat is shown instead of a total when a value reaches its quote threshold ("On quote")
benchmark*Benchmarkthe cost to compare with, e.g. "Your current solution"
actionActionthe call to action: its words and the page action it runs
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Input inputs[] · 11 props
PropTypeDescription
key*stringDesignthe input’s key, the one the model’s lines refer to
label*stringWordswhat the visitor sets ("Users")
kind*'slider' | 'stepper' | 'switch' | 'choice'slider: a range; stepper: a count; switch: on or off; choice: one of the options
minnumberDatathe lowest value
maxnumberDatathe highest value
stepnumberDatathe step between values
default*numberDatathe value shown first, and used by the server render
unitstringWordswhat the value counts ("orders / month")
hintstringWordsone line helping to answer
quoteFromnumberDatafrom this value the merchant quotes by hand: no total is shown
optionsOption[]the choices, for kind choice
Option inputs[].options[] · 2 props
PropTypeDescription
label*stringWordsthe choice’s words ("500")
value*numberDatathe units this choice stands for
Model model · 2 props
PropTypeDescription
basenumberDataa fixed amount in cents, whatever the inputs (the subscription, the minimum)
lines*Line[]what the price is made of: one line per input that counts
Line model.lines[] · 5 props
PropTypeDescription
input*stringDesignthe key of the input that gives the units of this line
label*stringWordswhat the line charges for ("Additional users")
ratenumberDatacents per unit beyond the included units; a switch counts as one unit when on
includedUnitsnumberDataunits included before the rate applies
bandsBand[]graduated bands instead of a single rate, in order
Band model.lines[].bands[] · 3 props
PropTypeDescription
upTo*number | nullDatathe last unit of the band; null for the open last band
rate*numberDatacents per unit inside the band
labelstringWordsthe merchant’s name for the band ("Growth")
Benchmark benchmark · 3 props
PropTypeDescription
label*stringWordswhat the other cost is ("Your current solution")
source*stringWordswhere the merchant took these rates, mandatory ("Public prices checked in March")
model*Modelthe other cost’s rates, computed the same way
Model benchmark.model · 2 props
PropTypeDescription
basenumberDataa fixed amount in cents, whatever the inputs (the subscription, the minimum)
lines*Line[]what the price is made of: one line per input that counts
Line benchmark.model.lines[] · 5 props
PropTypeDescription
input*stringDesignthe key of the input that gives the units of this line
label*stringWordswhat the line charges for ("Additional users")
ratenumberDatacents per unit beyond the included units; a switch counts as one unit when on
includedUnitsnumberDataunits included before the rate applies
bandsBand[]graduated bands instead of a single rate, in order
Band benchmark.model.lines[].bands[] · 3 props
PropTypeDescription
upTo*number | nullDatathe last unit of the band; null for the open last band
rate*numberDatacents per unit inside the band
labelstringWordsthe merchant’s name for the band ("Growth")
Action action · 3 props
PropTypeDescription
label*stringWordswhat happens ("Start with this plan")
action*stringActiona named action of the page
recordRecord<string, unknown>Datathe record the action opens, if any; the chosen values are added to it
Options options · 2 props
PropTypeDescription
currencystringDesignISO 4217, the shop’s by default
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
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: action

A comparison section, for landing, app, 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 comparison blocks

  • 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.
  • Compare side by side: the two pictures whole, next to each other with "or" on the seam: two options or states to choose between, where a slider would hide half of each.
  • Compare split: the title and text beside the pictures, the legend under the words: the words explain what changed.
  • Compare wide: the title and text above, the two pictures across the page: a detail worth seeing large.
  • 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.

All 15 comparison blocks