Skip to content
GitHub (opens in a new tab)

Scorecard

one KPI with label, value, optional delta/trend/hint/badge

stableMoleculecontracts/scorecard.json

Preview

Scorecard

Metric surfaces for dashboards with a label, value, and trend in lg, md, and sm. One piece. Not InsightCard. Not Card. Not a KpiCard cousin.

Master

One KPI tile at md, trending up, with a delta, hint and badge. Variants shows sizes and trends.

RevenueMonthly$48.2k+12.4%vs last 30 days

Usage

Use Scorecard to surface a key metric with optional trend. Keep labels short and values scannable.

Do's

  • Showing a single metric such as revenue, users, or conversion rate
  • A KPI with a trend against a target, or progress toward a goal or limit — sparklineVariant reference or meter
  • A KPI card with an icon, a trend badge and a small line or area chart in the trend's colour — icon, deltaAppearance badge, sparklineVariant area, sparklineTone trend
  • A KPI card with a footer link to its report, or a footer with an icon action and an outline Button — footer

Don'ts

<Scorecard
  label="Revenue"
  value="$48.2k"
  delta="+12.4%"
  trend="up"
  hint="vs last 30 days"
  badge="Monthly"
  size="md"
/>

When to use

  • Showing a single metric such as revenue, users, or conversion rate
  • A KPI with a trend against a target, or progress toward a goal or limit — sparklineVariant reference or meter
  • A KPI card with an icon, a trend badge and a small line or area chart in the trend's colour — icon, deltaAppearance badge, sparklineVariant area, sparklineTone trend
  • A KPI card with a footer link to its report, or a footer with an icon action and an outline Button — footer

When not to use

  • Multiple metrics — use Scoreboard
  • A full chart or a table — use LineChart, BarChart or Table; Scorecard only takes a small decorative sparkline
  • A framed content tile — use Card
  • A recommended action tile — use InsightCard

What an agent reads

import { Scorecard } from "agentic-ds-kit";
must
  • useId for label and value
  • aria-labelledby when both exist
  • Delta arrow is aria-hidden
  • delta text is the visible change
  • deltaTone is color only; the delta text carries the meaning
  • root is a button when onClick is set
  • with onClick and selected set, the button has aria-pressed and its name includes the badge text
  • sparkline is aria-hidden and not focusable, unless sparklineSummary is set: then it is role img named by the summary
  • with selectionRole radio, the button has role radio and aria-checked instead of aria-pressed
  • reference and expressive drawings, dates and legend are aria-hidden unless sparklineSummary is set (then the chart is one role img named by it); delta and hint carry the meaning
  • meter composes kit Meter: role progressbar named by the card label and meter label; the percent and label text under it are aria-hidden
  • with goodWhen the visible delta starts with Better or Worse (from kit Delta); the icons are aria-hidden and only repeat the word
  • icon is aria-hidden; the label names the metric
  • a trend-toned sparkline only repeats the delta's tone; the delta text and its sign or Better/Worse word carry the meaning
  • the sparkline marker is aria-hidden
  • footer link is a native link (kit Link) whose visible label says where it goes; aria-describedby points at the card label, so repeated links in a row are told apart. Generic labels (View, More, View all) warn in development
  • footer iconAction is a kit IconButton named by its label, with a kit Tooltip of the same words; its icon is aria-hidden
  • footer action is a kit Button with a visible label
  • footer is never rendered inside the onClick button
defaults
  • trend neutral
  • deltaAppearance inline
  • size md
  • iconAppearance plain
  • badgeTone neutral
  • sparklineVariant plain
  • sparklineTone chart
  • sparklineCurve linear
  • sparklineMarker false
  • highlightLast 0
  • appearance card
  • selectionRole toggle
  • fill false
stops if
  • Do not invent a KpiCard, Stat, or MetricCard cousin
  • Do not use raw hex colors in styles
  • Do not pack multiple KPIs into one Scorecard
  • Put links and buttons on a Scorecard only through footer; never with onClick, and never a solid primary in the footer
  • Do not invent a local Tag or Status on Scorecard — status uses kit Badge via badge
  • Do not put a change like +3.1% in badge — pass delta, which renders kit Delta
  • Do not draw a local sparkline beside Scorecard — pass sparkline
  • Do not use sparkline as the only sign of change; keep delta or hint
  • Do not draw a local meter or bar beside Scorecard — pass meter
  • Do not color the sparkline or meter with brand; brand is only for the selected card. Status colours come only from sparklineTone trend, never set by hand
  • Do not pass reference, highlightLast or sparklineDates without sparklineVariant reference, or compare without expressive; they are ignored
  • Do not colour a cost or latency rise green or red alone; pass goodWhen down so the delta says Worse
  • Do not draw a local footer, divider or link row on a Scorecard — pass footer, which renders Card's footer row. For Ask or several KPIs with actions, put a Scoreboard in a Card and use the Card footer
  • Do not colour the icon by status or brand; the delta and sparklineTone carry the direction
  • Do not pass sparklineTone with reference or expressive; it is ignored
  • Do not pass sparklineCurve or sparklineMarker with reference or expressive; they are ignored
  • Do not label a footer link View or More alone; say where it goes, e.g. View revenue report
  • Do not make the sparkline the only place a change is told: keep delta or hint, or pass sparklineSummary

From contracts/scorecard.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
labelstringYes——
valuestringYes——
deltastringNo—Visible change text with its sign, e.g. '+12.4%'. Renders as a kit Delta (size sm): the arrow comes from trend and the colour from trend or deltaTone.
trendup | down | flat | neutralNoneutralDelta direction: up ArrowUp, down ArrowDown, flat and neutral ArrowRight (no change).
deltaTonesuccess | warning | danger | neutralNo—Override the delta colour (default from trend: up success, down danger, flat and neutral neutral), e.g. danger when costs go up. With trend neutral the delta is a status, not a change: warning (text-warning) for an amber count such as '3 urgent', and the tone's status icon replaces the arrow (TriangleAlert, CircleX, CircleCheck).
goodWhenup | downNo—Which way a change is good: up (pass rate, revenue) or down (cost, latency). Passed through to kit Delta. With trend up or down the delta reads 'Better · +6.3 pts' with CircleCheck or 'Worse · +17%' with TriangleAlert in place of the arrow, so the word carries the meaning. Only Worse carries colour (danger); Better stays neutral. deltaTone still overrides the colour. Flat and neutral are not judged.
deltaAppearanceinline | badgeNoinlineinline: the delta as text with its arrow. badge: the same kit Delta with appearance soft, on the tone's subtle fill at Badge height, for a trend chip beside the hint (e.g. '+12.4%' badge, then 'vs last month'). Colour, arrow and Better/Worse are unchanged. A status delta (trend neutral with deltaTone) takes the same fill.
hintstringNo—Supporting context, e.g. 'vs last 30 days'
sizesm | md | lgNomdValue 18/24 on sm, 24/32 on md, 32/40 on lg. Padding space.4 on sm and md, space.6 on lg, the same scale as Card.
iconKitIconNo—A Lucide name before the label, e.g. 'CreditCard'. Decorative (aria-hidden): the label names the metric.
iconAppearanceplain | tintedNoplainWith icon. plain: the glyph alone in icon.muted. tinted: the glyph on a small surface.muted tile (space.6, radius.controlSm), like Card's icon. Never a status or brand colour.
badgestringNo—kit Badge on the header, aligned with label. Compose Badge; status is not a Tag. Status words only (Charted, Beta); a change goes in delta, never in badge.
badgeToneenumNoneutralkit Badge tone neutral | primary | brand | success | warning | danger | info | highlight
sparklinearrayNo—number[], oldest first. A small trend line under the value in --chart-1, full width, --space-6 tall. Decorative (aria-hidden) unless sparklineSummary is set: delta and hint carry the meaning. Needs two or more finite numbers; others are skipped.
sparklineVariantplain | area | reference | expressiveNoplainplain: the thin --chart-1 line (unchanged). area: the same line with a soft fill under it, space.8 tall, still under the value. reference: area fill, faint grid, a dashed reference line with its label, darker dots on the last highlightLast points, start and end dates (sparklineDates). expressive: smooth curve, soft area, dashed previous period (compare) in --chart-5 with a This period / Previous legend, an end dot with the latest point's value (compact, e.g. 4.3k) in a small mono tag, and a faint band on the latest point. Both move the chart to the card's foot so cards in a row line up. Needs two or more finite numbers; otherwise nothing is drawn.
sparklineTonechart | trendNochartplain and area only. chart: --chart-1. trend: the line and fill take the delta's tone from the same rule as kit Delta (trend, deltaTone, goodWhen): success icon.success on success.subtle, danger icon.danger on danger.subtle, warning icon.warning on caution.subtle, neutral text.muted on bg.tray. A down trend turns the delta and the chart red together; with goodWhen, Worse is red and Better stays neutral in both.
sparklineCurvelinear | smoothNolinearplain and area only. linear joins the points with straight lines (unchanged). smooth draws a monotone curve (the same one as expressive and LineChart) that never overshoots a peak or dip. reference stays linear and expressive stays smooth.
sparklineMarkerbooleanNofalseplain and area only. A dot (space.2) on the latest point with a soft ring (space.1 wide) in the line's tone: --chart-1, or the trend tone with sparklineTone trend. Decorative (aria-hidden).
sparklineSummarystringNo—A text summary of the chart, e.g. 'Revenue rose from $38k to $48k over 30 days'. Any sparklineVariant. With it the chart is role img named by this text; without it the chart stays aria-hidden. Not used with meter (kit Meter names itself).
referenceobjectNo—sparklineVariant reference only. A dashed text.muted guide on the same scale as the line, e.g. { value: 400, label: 'Target $400k' }.
comparearrayNo—sparklineVariant expressive only. number[], oldest first: the previous period, drawn dashed in --chart-5 on the same scale. Adds the legend.
highlightLastnumberNo0sparklineVariant reference only. Darker dots on the last N points, e.g. the weeks past a target.
sparklineDatesarrayNo—sparklineVariant reference only. Start and end labels under the line, e.g. ['Aug 28', 'Nov 20'].
meterobjectNo—A calm bar toward a target in place of the sparkline: kit Meter (bar, sm) with the percent of max on the left and label on the right, e.g. { value: 2.1, max: 3, label: 'of 3.0% limit', direction: 'lower' }. direction defaults to higher. The bar is neutral; with direction lower and value over max it turns warning and the row shows the word Over limit, so the state is not colour alone. max must be above 0. The progressbar is named by the card label and meter label.
footerobjectNo—Leave out for no footer (default). A divider that runs edge to edge, then Card's footer row (the same layout and padding as Card). link: a kit Link (standalone) on the right; label says where it goes, e.g. 'View revenue report', and the link is described by the card label. action: a kit Button sm outline neutral on the right, and an optional kit IconButton sm ghost neutral on the left with a kit Tooltip of the same words; iconAction.label is its accessible name. Always the last row, under any chart or meter. Ignored with onClick (a button cannot hold a link or other buttons), with a warning in development.
appearancecard | plainNocardcard is the framed tile (surface.card, border.faint, radius.surfaceMd, like Card). plain drops the border and background for a divided strip (Scoreboard appearance divided passes it); hover and selected states still draw, selected as an inset border.brand edge.
onClickfunctionNo—When set, the whole card is a button that opens a detail view
selectedbooleanNo—With onClick: the card is a toggle in a picker (e.g. the metric a chart shows). Sets aria-pressed, draws the selected style (border.brand on action.selected), and adds the badge to the button's name. Leave undefined for a plain button.
selectionRoletoggle | radioNotoggleWith onClick and selected. toggle sets aria-pressed. radio sets role radio and aria-checked, for a card inside a radiogroup; Scoreboard selectable sets it, so you rarely pass it.
fillbooleanNofalsePins the footer to the bottom of the card, so footers line up when cards in a row differ in height. Scoreboard passes fill.
  • Component
    →

    Scoreboard

    Metrics strip of kit Scorecards: two to six figures, and the only metric picker.

  • Component
    →

    Line

    Change and progress over ordered samples as a line or area chart.

  • Component
    →

    Bar

    Compare magnitudes across categories with vertical or horizontal bars.

  • Component
    →

    Table

    Simple semantic table for invoices, lists, and text rows, with optional sort, row menu, sticky header, loading, empty and error states, row dividers on or off, and one optional highlighted row.