Skip to content
Klarhimmel UI

Stats, cards

Stats, cards previewStats, cards preview

Install

npx shadcn add @klarhimmel/stats-cards
DetailsAbout, usage, props and more

Two to four stat cards, each with a large value, a label, a line of context and an optional change badge.

Import

Import

import Block from '@/components/klarhimmel/blocks/stats-cards';
Also called
  • stats/cards
Category
A few numbers that prove the point. New project? Set it up once: /get-started/installation.

Notes

When to use it

Two to four stat cards, each with a large value, a label, a line of context and an optional change badge. Pick it for dashboard-like facts; stats-row is lighter when there is no context line.

Writing for it

- The value holds only 16 characters, so '1,2 M' fits and '1,2 million users' does not. Put the unit in the label (40 characters). - The delta field (32 characters) turns into a small accent badge such as '+12%' or 'up 3 pts'. Leave it empty on cards where nothing changed, and no badge is drawn. - The description line has 160 characters, a good place for the comparison period so nobody has to guess what the badge is relative to.

Watch out for

There is no eyebrow in this block, only title and description. Count the cards before you design around it, since two cards sit in two columns and three or four spread across a row only on wider containers.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import StatsCards from '@/components/klarhimmel/blocks/stats-cards';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <StatsCards props={{
          "title": "Say what changed over the period",
          "description": "Say what changed for the reader after a period of using it.",
          "items": [
            {
              "value": "00%",
              "label": "Name the first result",
              "description": "Say how the first result is measured.",
              "delta": "+00 pts"
            },
            {
              "value": "0.0 h",
              "label": "Name the second result",
              "description": "Say how the second result is measured.",
              "delta": "−00%"
            },
            {
              "value": "00%",
              "label": "Name the third result",
              "description": "Say how the third result is measured.",
              "delta": "+0 pts"
            },
            {
              "value": "00",
              "label": "Name the fourth count",
              "description": "Say who the fourth count covers.",
              "delta": ""
            }
          ]
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
titlestring'Say what changed over the period'Text, up to 120 characters.
descriptionstring'Say what changed for the reader aft…'Text, up to 300 characters.
look'centered'-One of 'centered'. Optional; empty is not rendered.
actions{ primary, secondary }-Fields: primary (optional), secondary (optional). Optional; empty is not rendered.
items{ value, label, description, delta }[]4 itemsList of 2 to 4. Each item: value, label, description, delta.
headingLevel'1' | '2'-One of '1', '2'. Optional; empty is not rendered.