Data✨ Premium

Sparkline

Key figure with its change and a mini line that draws itself underneath as it comes into view, green with an up arrow or red with a down arrow.

SVGTrend

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Data has 28 effects, including 1 free. Explore the category →

3 usage examples

Three key-figure tiles at the top of a food bank's volunteer area — Sparkline example 1

① Three key-figure tiles at the top of a food bank's volunteer area

WhenA charity's volunteer area: under the “This month” title, three tiles (donations, active volunteers, parcels handed out) first show a skeleton while loading, then their figure, their change since September and their line drawing itself. Parcels, going down, turn red with a down arrow.
WhyVolunteers see at a glance what is going well and what needs attention. Three independent copies, each with its own series, pick their colour on their own.
SettingsThree roots: data-currency="EUR" for donations, data-decimals="0" for the other two, value and change computed, --sprk-height: 38px, --sprk-value-size: 1.15rem, --sprk-up: #15803d, --sprk-down: #b91c1c.
Price trend for each product in a co-op grocery's price tracker — Sparkline example 2

② Price trend for each product in a co-op grocery's price tracker

WhenThe “Price watch” page of a bulk grocery: one row per product (flour, lentils, rice, oil, coffee) with, on the right, the line of the last eight weeks, the current price and its change. The five lines draw together when the page opens.
WhyShoppers spot straight away what is going up. Here the convention is reversed for the buyer: rises in orange, falls in green, which the two colour variables allow.
SettingsFive roots, data-currency="EUR", data-decimals="2", --sprk-up: #b45309, --sprk-down: #15803d, --sprk-height: 30px; the page CSS puts the header to the right of the line (flex-direction: row-reverse on .sprk-box).
Snow depth at the summit and its eight-day curve — snow report of a ski resort — Sparkline example 3

③ Snow depth at the summit and its eight-day curve — snow report of a ski resort

WhenA resort's home page: the visitor scrolls past the summit photo down to “This morning's snow report”. “142 cm” appears large with “+11 cm overnight”, and the curve of the last eight days draws itself next to the open runs and the “Day pass” button. In the capture the page scrolls by itself.
WhySkiers decide whether to drive up by looking at this number: the rising curve shows snow has been building for days, the overnight line says what just fell.
Settingsdata-unit="cm", data-decimals="0", eight readings from 96 to 142, .sprk-delta text written in the HTML (so it is kept), --sprk-value-size: 2rem, --sprk-height: 58px, --sprk-up: #2563eb.

How it works

The series goes into data-values on the .fx-0232-root root. If .sprk-value is empty, the script writes the last value into it; if .sprk-delta is empty, it writes the change between the first and last values as a signed percentage (“+12.5%”). Both go through Intl.NumberFormat in the page language, with data-currency for an amount (“$4,832”, “4 832 €”), data-unit for a unit and data-decimals for decimals. Text you write yourself in those two elements is kept as is.

The direction comes from the data: if the last value is lower than the first, the root gets the sprk-down class, which switches the colour to --sprk-down (red) and flips the arrow; otherwise everything stays --sprk-up (green). data-trend="up" or "down" forces it. The line is an SVG built at the real size of .sprk-chart (height --sprk-height), from the smallest to the largest value, with a dot on the last one; a ResizeObserver recomputes it when the width changes.

When 35% of the line is visible, the sprk-on class draws it from left to right in 1.5 s (ease-out), fades the area in over 1 s from 0.5 s, then lights the end dot at 1.5 s. Only once.

Accessibility

  • The figure and the change are real text, read in order (“$4,832 +12.5%”); the arrow is decorative and hidden, the sign of the percentage carries the direction.
  • The line has an equivalent: .sprk-chart has role="img" and an aria-label made of data-title followed by the values in the page format.
  • Reduced motion: under prefers-reduced-motion: reduce, the line, the area and the dot show straight away.
  • Colour is backed up: green and red never stand alone, the arrow and the sign also say whether it goes up or down. No interaction: nothing takes focus.

Browser compatibility

SVG built in JavaScript, CSS animations on stroke-dashoffset and opacity, IntersectionObserver, ResizeObserver and Intl.NumberFormat with signDisplay. Measured on 8 Nov 2026 in Chromium 151, Firefox 153 and WebKit 26.5 (Playwright): two independent copies, reduced motion, 390 px wide, no errors.

Chrome 77+✓ Full (measured in Chromium 151)
Firefox 78+✓ Full (measured in Firefox 153)
Safari 14.1+✓ Measured in WebKit 26.5, not in real Safari
Edge 79+✓ Full (Chromium engine)
Safari iOS 14.5+✓ Not checked on a device
Chrome Android 77+✓ Full (Chromium engine)

Without IntersectionObserver, the line draws on load. Without JavaScript the card only shows the arrow: write the value and the change straight into the HTML in that case.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0232-root" data-currency="USD" data-title="Revenue over the last nine weeks" data-values="4295,4380,4330,4520,4470,4690,4610,4760,4832">
  <div class="sprk-box">
    <div class="sprk-header">
      <span class="sprk-value"></span>
      <span class="sprk-change">
        <svg class="sprk-arrow" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
          <path d="M12 19V5M5 12l7-7 7 7"></path>
        </svg>
        <span class="sprk-delta"></span>
      </span>
    </div>
    <div class="sprk-chart" role="img"></div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Series (HTML — data-values on the root) 4295,4380,4330,4520,4470,4690,4610,4760,4832 At least two comma-separated numbers, decimal point.
Format (HTML — data-currency, data-unit, data-decimals) USD (EN page), EUR (FR page); 0 decimals for a currency, 1 otherwise ISO currency or free unit for the value; 0 to 4 decimals.
Value and change (HTML — text of .sprk-value and .sprk-delta) Empty: computed from the series Write your own text to show it instead (e.g. “+€1,260 this week”).
Direction (HTML — data-trend="up" or "down") Inferred: down if the last value is below the first Forces the colour and the arrow direction.
Spoken description (HTML — data-title) “Revenue over the last nine weeks” Start of the line's aria-label, followed by the values.
Colours (CSS — --sprk-up, --sprk-down, --sprk-text) #22c55e, #ef4444, #fff Colour when rising, when falling, and colour of the figure.
Sizes and background (CSS — --sprk-height, --sprk-value-size, --sprk-max-width, --sprk-min-height, --sprk-bg) 40 px, 1.5rem, 280 px, 300 px, #0a0a0f Line height, figure size, maximum block width, minimum root height, background.

FAQ

Yes: swap the colours with --sprk-up and --sprk-down. The arrow always follows the real direction of the data, only the meaning of the colour changes.
It is the difference between the last and the first value of data-values, divided by the first: from 4,295 to 4,832, “+12.5%”. For another comparison (previous week, a target), write your text in .sprk-delta.
Yes, each copy is independent and takes the width of its cell. Set --sprk-min-height: 0 and --sprk-max-width: none, then lay .sprk-box out in a row if you want the figure next to the line.