MetricTabs

A row of headline numbers that is also a switch. Pick one and its trend takes over the chart; slide across it to read any point. Arrow keys switch tabs. Cards.

Open playground

About

MetricTabs 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 { MetricTabs } from "@ashutoshswamy/smoui" and set metrics, height.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

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

<MetricTabs metrics={[{ id: "rev", label: "Revenue", value: 48200, prefix: "$", delta: 12.4, data: series }]} />

Props 2

metrics

The tabs. data is the trend in the same units as value, oldest first. lowerIsBetter turns a negative delta green.

{ id; label; value; delta?; lowerIsBetter?; data: number[]; labels?; prefix?; suffix?; decimals? }[]
height

Chart height. Default 120.

number