Skip to content
IndexRequest a UIAboutContact

Sparkline Trend Rows

Compact trend lines beside each metric; hovering a line replaces the number with that point's value.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create three metric rows (Revenue, Users, Churn) in a 300px wide card, each 52px tall with three columns: a label with a small delta text (+8.2%, +3.1%, -0.4%), a 100x28px SVG sparkline of 12 points and the current value (right aligned, 14px semibold). Draw each sparkline as a 1.5px polyline with no axes and animate it drawing over 700ms ease-out using stroke-dasharray. On pointermove over a sparkline find the nearest point, draw a 4px dot there and replace the displayed value with that point's value; on pointerleave restore the latest value. Support touch dragging with touch-action pan-y. Rows are focusable and ArrowLeft and ArrowRight move through the points while focused. Delta text uses a plus or minus sign, plus a colour: green for good and red for bad (churn down is good). Under prefers-reduced-motion skip the drawing.

About this pattern

Definition

A tiny line chart without axes, placed next to a metric. It shows the shape of change at a glance, and hovering it reveals the value at that point.

Purpose & UX principles

  • Packs trend and current value into one row, ideal for dashboards and tables.
  • The number is always the source of truth; the line adds context.
  • Direction is also written as text (+8.2%) so it is not carried by colour alone.

Interaction states

  • Rest (latest value), hover or drag (value of the nearest point and a dot), focus-visible ring on the row.

Motion specification

  • The line draws in 700ms ease-out on load.
  • The value updates immediately while hovering.
  • Reduced motion: lines appear drawn.

Responsive behaviour

  • Each sparkline fills the middle column; rows stay at 52px tall.
  • On touch, dragging across the line updates the value.

Code

HTML
<div class="card" id="card"></div>

Related patterns

Line Chart with Crosshair

↗
Line Chart with CrosshairData Visualization

Number Count Up

↗
Number Count UpData Visualization

Interactive Bar Chart

↗
Interactive Bar ChartData Visualization