Trend Card
A bento card with a key number and a smooth trend chart.
Features
- •Just a few numbers — Pass seven values, or any handful, oldest to newest. The latest figure, the change in money and percent, the scale and the labels are all worked out.
- •Days or months — Labels run Sunday to Saturday, or the months ending now; pass your own labels for anything else.
- •Read any value — Point, drag on touch, or use the arrow keys: the figure, change and label follow, with the dot and guide line lit.
- •Honest, smooth line — A monotone curve passes through every value without inventing dips or peaks. It draws itself in from the left when the card scrolls into view, with each dot popping in, and morphs when the data changes.
- •Monochrome by default — Near-black card, hairline border, white line and grey labels in Inter; every colour, the radius and the chart height are props.
- •No dependencies to style — One file with inline styles, so it drops into any React app or Framer. Currency and locale formatting via Intl, and a screen reader summary.
Props API Reference
14 configurable props| Prop | Type | Default | Description |
|---|---|---|---|
| values | number[] | required | The figures to chart, oldest to newest. |
| label | string | "Sales" | Small heading above the figure. |
| period | "months" | "days" | "months" | Automatic labels: the months ending now, or weekdays from Sunday. |
| labels | string[] | undefined | Your own label under each value, instead of the automatic ones. |
| endDate | string | Date | today | Month of the last value when period is months. |
| currency | string | "USD" | ISO 4217 currency code. |
| locale | string | "en-US" | Locale for numbers and names. |
| accentColor | string | "#FFFFFF" | Line, dots and area colour. |
| background | string | "#08080A" | Card background. |
| textColor / mutedColor | string | "#FFFFFF" / "#8F8F99" | Figure colour, and label colour. |
| borderColor | string | "rgba(255,255,255,0.08)" | Card border. |
| chartHeight | number | 120 | Chart height in px. |
| radius | number | 0 | Corner radius in px. |
| className / style | string / CSSProperties | undefined | On the card. |