Listening figures bars — Stats block

Pro

stats-listening-figures-bars · for home, landing pages

Listening figures bars

Published figures and ranked shares with a required measurement period; the merchant’s own only.

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/stats-listening-figures-bars

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StatsListeningFiguresBars from '@/components/trame/blocks/stats/stats-listening-figures-bars.vue'

const props = {
title: "The notebook’s words",
statistics: {
period: "Measured when this demonstration was written",
source: "Length of the titles in demo.ts, spaces included",
items: [
{
label: "The open window",
value: "15 characters"
},
{
label: "Covered passage",
value: "15 characters"
}
]
}
}
</script>

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

Props

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

PropTypeDescription
title*stringWordsthe section’s heading
introstringWordsa sentence or two under the heading
statistics*Statisticsthe listening figures: their period, source and items
ctaCtathe call to action: its words and the page action it runs
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Statistics statistics · 3 props
PropTypeDescription
period*stringWordsthe period the figures cover, e.g. "January to March"
source*stringWordswhere the figures come from, e.g. the hosting platform
items*Item[]the statistic’s items, in order
Item statistics.items[] · 3 props
PropTypeDescription
label*stringWordswhat the value is about
value*stringWordsthe value, as the merchant states it
sharenumberDataits share, 0 to 100
Cta cta · 2 props
PropTypeDescription
label*stringWordsthe words on the button or link
action*stringActiona named action of the page
Options options · 1 props
PropTypeDescription
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
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: cta

A stats section, for home, landing pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.

More stats blocks

  • Impact ledger breakdown bar: one stacked bar of shares with a legend and an explanation per share: what happens to returns, where the money goes.
  • Impact ledger commitments timeline: dated promises with the merchant’s own status on each: commitments kept, ongoing or late.
  • Impact ledger rules grid: numbered cards saying how the figures are counted: gives credibility to the numbers above it.
  • Impact ledger: rows of label and value grouped by topic with a method footnote: carbon, repair, donations, sourcing figures.
  • Metric cards spotlight: one figure that matters more than the others, set very large on a tinted panel, the rest as ruled rows beside it and the series as labelled bars under them: when the first figure carries the story; the merchant’s own only.
  • Metric cards: each figure on its own card with its precision, its change and a small line of its series; the merchant’s own only.
  • Progress figures columns: the same measures at two dates in two columns: what improved, and what went backwards; the merchant’s own only.
  • Proof figures tiles: up to three compact boxes (rating, count, one more figure) under an action: when numbers carry the page; the merchant’s own only.

All 20 stats blocks