CompareStat

This period against the last. Totals and the change on top, paired bars below; point at a pair and the caption names both numbers. Cards.

Open playground

Orders

0+16.0%
MonTueWedThuFriSatSun
This weekLast week

About

CompareStat is a React component in the Cards category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { CompareStat } from "@ashutoshswamy/smoui" and set label, current, periods among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { CompareStat } from "@ashutoshswamy/smoui";

<CompareStat label="Orders" periods={days} current={thisWeek} previous={lastWeek} />

Props 5

label

Metric name.

string
current / previous

One value per period, this time and last.

number[]
periods

Labels under the bars.

string[]
currentLabel / previousLabel

Legend text. Default This week and Last week.

string
prefix / suffix

Around the numbers.

string