Rost

← All components

component

Sparkline

Which way something has been going, as a small line with a dot at now. Green when that's good, red when it isn't, grey when it's neither.

In code Contract: review Guidance: proposed Contract on GitHub Figma 753:22 As markdown
Neutral
Positive
Negative

Install

npx github:Runceanu/rost add sparkline

It lands in src/rost/sparkline/, with what it needs and its contract. Install has the rest.

When to use

  • Next to a figure

    Beside a Stat, to say whether this month's number is part of a rise or a dip.

When not to use

Behaviour

It scales the values to fit: the lowest touches the bottom, the highest the top, so it shows shape, not size. A flat series sits in the middle.

Accessibility

  • Element

    <span role="img">; the SVG inside is hidden from screen readers.

  • Name

    label, which has to say what the line shows, since nobody can hear its shape.

  • Colour

    A graphic that carries meaning: the grey is 7:1, the green 10:1, the red 7:1 on the dark page.

Content

The label ends with where it ended up: up to €12,000, not just Income.

Props

PropTypeValuesDefault
data node
tone enum neutral · positive · negative neutral
label string
width number 120

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • height 32px spacing/size/small-medium

displayinline-block · flex-shrink0

svg

displayblock · overflowvisible

line

  • stroke-width 2px spacing/outline/medium

fillnone · stroke-linecapround · stroke-linejoinround

dot

strokenone

Changes by variant

3 variants. Each table is what one thing changes with: a column per tone, a row per property. Where every row starts with the same token path, it's written once, under the property.

Follows tone

PropertyNeutralPositiveNegative
dot.fillsparkline/… neutral #999999 positive #00d669 negative #f2705f
line.strokesparkline/… neutral #999999 positive #00d669 negative #f2705f