Stat cards trend — Charts block

Pro

charts-stat-cards-trend · for app, billing, analytics pages

Stat cards trend

Figures that come with their last points, to see the shape and not only the number

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/charts-stat-cards-trend

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import ChartsStatCardsTrend from '@/components/trame/blocks/charts/charts-stat-cards-trend.vue'

const props = {
title: "This week at the workshop",
items: [
{
label: "Paid orders",
value: 184,
delta: 12.4,
deltaTone: "success",
deltaLabel: "vs last month",
series: [
9,
12
],
icon: "orders",
open: "orders"
},
{
label: "Revenue",
value: 1248000,
format: "money",
delta: 8.1,
deltaTone: "success",
deltaLabel: "vs last month",
series: [
30,
34
],
icon: "revenue",
open: "orders"
}
]
}
</script>

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

Props

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

PropTypeDescription
titlestringWordswhat the figures describe ("This week at the workshop")
items*Item[]the items shown, in order
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Item items[] · 14 props
PropTypeDescription
label*stringWordswhat the figure counts ("Paid orders")
value*number | nullDatathe figure, counted by the server: cents for money, seconds for a duration, null when unknown
format'number' | 'money' | 'percent' | 'duration'how the figure reads: a number, money (cents), a percent or a duration (seconds)
unitstringWordsthe unit written after the figure ("GB", "orders")
deltanumberDatathe change the server gives, in percent and signed (+12.4, -3): never computed by the block
deltaTone'neutral' | 'info' | 'success' | 'warning' | 'danger'how the server reads that change: a rise in returns is not good news
deltaLabelstringWordswhat the change compares to ("vs last month")
seriesnumber[]Datathe last points of the figure, oldest first, 30 at most
usednumberDataa metered resource: what is used
limitnumberDataa metered resource: what the plan allows
tone'neutral' | 'info' | 'success' | 'warning' | 'danger'the state the host reads in the figure; it colours the meter and the status
statusstringWordsa short state or count ("6/6 goals", "Almost full")
iconstringDesignstorage, users, api, mail, database, orders, revenue, stock, goal
openstringActionwhere the figure leads: the list behind it
Options options · 3 props
PropTypeDescription
columns'2' | '3' | '4' | 'auto'how many columns on wide screens; auto by default
currencystringDesignISO 4217 for money figures, the app’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
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: items[].open
  • Reads figures from your app

A charts section, for app, billing, analytics 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 charts blocks

  • Heatmap matrix: a labelled grid with each value written in its shaded cell: cohorts and retention, hours by weekday, when the exact numbers are read.
  • Heatmap ranked rows: the rows sorted by their total, each one a thin strip of its cells, when which row leads matters more than the columns.
  • Key metrics featured: The merchant’s own primary metric takes the lead beside a quiet list of supporting measures.
  • Key metrics tiles: Centered figures on generous tiles for the merchant’s own headline measures, with context beneath.
  • Metric grid ruled grid: an analytics page of the host’s own measures over a chosen period: one ruled grid of chart tiles sharing their borders, the first metric leading at two thirds, each with its value, this period against the previous and an area chart.
  • Spend trend stacked bars: a plan with variable spend: three figures and a stacked bar chart of what each period cost.
  • Summary distribution: how values spread (latency, order value), with the percentiles called out.
  • Summary stacked bars: a total that splits into parts (base, seats, usage) period by period.

All 20 charts blocks