Skip to content

Stat & Metric

Get Ritla UI

A key number with its trend: Metric card for dashboards, KPI stat for compact tiles, and the gauge for a value against a known range.

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add metric

    Also works with shadcn: npx shadcn@latest add @ritla/metric

  2. Dependencies it brings

    @phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

metric.tsx
import { MetricItem, MetricCard, MetricBars } from "@/components/ui/metric";<MetricItem label="Transfers this month" value="1,284" trend={{ value: "12%", direction: "up" }} /><MetricCard title="Card spending" value="1,240" trend={{ value: "25%", direction: "up" }} period="vs last month" chart={<MetricBars data={[25, 50, 100, 75, 50, 10]} />} />

Examples

Metric card

Bars beside the number, a progress bar above it, or a small gauge. The bars keep running left to right in Arabic; progress fills from the inline start.

EnglishMirroredArabic
LTR →

KPI stat types

type picks Figma's layout: an icon in a square, a mini chart beside or under the number, or a title band. The footer is a settings button and a View report button.

EnglishMirroredArabic
LTR →

Gauge

One value against a known range with good and bad zones. scale says which end is good. In Arabic the dial mirrors, so the scale runs from the right.

EnglishMirroredArabic
LTR →

Color follows meaning

More failed payments is bad news: the arrow points up, and the tag and the line are red (tone: "negative").

EnglishMirroredArabic
LTR →

API reference

MetricItem

PropTypeDefaultDescription
type"simple" | "icon-01" … "icon-04" | "chart-01" … "chart-04""simple"Figma's Type: the tile's layout.
labelReactNodeNoneThe metric and its period (“Views in 24 hours”).
valueReactNodeNoneThe number, formatted with its unit.
trend{ value, direction: "up" | "down", tone? }NoneThe change. tone says whether it is good news (green) or bad (red), by meaning, not direction.
periodReactNodeNoneThe comparison after the trend (“vs last month”).
iconIconComponentNoneThe holder's icon in the Icon types and Chart 02.
iconColor"brand" | "green" | "red" | "amber" | "gray""brand"The circle's color in Icon 01 and 02.
chartnumber[]NoneThe mini chart's values in time order, oldest first.
chartLabelstringNoneA text summary of the chart; without one it is hidden from screen readers.
menuReactNodeNoneAn icon button opening a Menu, at the top inline end.
footerReactNodeNoneFigma's Actions: a link or buttons in the footer.

MetricCard

PropTypeDefaultDescription
titleReactNodeNoneThe metric and its period.
value / trend / period…NoneAs in MetricItem; the trend is a tag here.
type"bar-chart" | "progress""bar-chart"Figma's Type: the chart beside the number, or a progress bar above it.
chartReactNodeNoneMetricBars, MetricProgress or MetricGauge size="sm".
menu / footerReactNodeNoneThe menu button, and the footer (usually a See details link).
footerContentReactNodeNoneThe footer's Figma Slot: content at its inline start, before the link (a last-updated time, a legend, a status).

MetricBars / MetricSparkline / MetricProgress

PropTypeDefaultDescription
datanumber[]NoneThe values in time order (two to six bars).
highlightnumberNoneThe strong bar; the highest by default.
size"sm" | "md" | "lg""lg"The bars' size: 12, 16 or 24px wide.
value / max / labelnumber, number, stringNoneIn MetricProgress: progress toward a goal, a named meter.

MetricGauge

PropTypeDefaultDescription
value / min / maxnumberNoneThe value and its known range.
scale"high-is-good" | "low-is-good""high-is-good"Figma's Scale: which end is good, which orders the red and green zones.
size"md" | "sm""md"md with the value, label and scale ends; sm the dial alone, inside a card.
labelstringNoneWhat it measures, printed under the value; the meter's name.
valueText / minText / maxTextReactNodeNoneThe value and the scale ends as printed.

Usage guidelines

A metric shows one number with its label. Which type, label and value, trends and their colors, mini charts and gauges, dashboard layout, what mirrors in Arabic and what doesn't, and the checks before handoff.

1. KPI stat, Metric card or Gauge

All three show one number with its label. Pick by how much context the number needs. For many numbers side by side, use a table; for exact values over time, use a chart.

You need toUseWhy
Show a row of key numbers on a dashboardKPI stat (KPI tile in fintech)Compact tile with a trend and an optional sparkline.
Show a number with its recent shape or progress to a goalMetric cardBar chart or Progress under the value, with a link to details.
Show one value against a known range with good and bad zonesGauge metric, or Radial chartThe dial shows at once whether the value is healthy. Use Radial chart when there are no good and bad zones.
Compare many numbers across recordsTableColumns line numbers up for comparison.
Read exact values over timeChartAxes, labels and tooltips give the detail.

2. Label and value

The label names the metric and its period. The value uses the product's number format: grouping separators, the currency or unit, and only the decimals people need. Abbreviate large numbers the same way everywhere.

A value people can read

A wallet dashboard tile.

Do: Named, rounded, comparedThe label says what and when, and the trend says compared to what.
Don't: Unnamed and rawTotal of what, since when? The decimals add noise and the change has no baseline.

Do

  • Name the metric and the period: Transfers this month.
  • Show the unit or currency with the value.
  • Round to what people act on: 1,284, not 1,284.372.
  • Abbreviate the same way on every tile: 1.2M, 840K.

Don't

  • Use vague labels such as Total or Data.
  • Leave out the period, so people can't tell what the number covers.
  • Mix 1.2M and 1,200,000 on one dashboard.

3. Trends and their colors

A trend tag shows the change and what it compares to. Its color says whether the change is good, not which way it went: more revenue is Success, more failed payments is Error. The arrow shows the direction.

Color follows meaning

Failed payments went up 8%.

Do: Error for a bad increaseMore failed payments is bad news, so the tag is red while the arrow still points up.
Don't: Green because it went upThe tag celebrates a problem.

Do

  • Always say what the change compares to: vs last month.
  • Color by meaning: Success for good, Error for bad, Gray for neutral.
  • Keep the arrow, so the direction doesn't rely on color.
  • Show the same comparison period on every tile in a row.

Don't

  • Make every increase green.
  • Show a percentage without a baseline.
  • Use color alone to show up or down.

4. Mini charts and gauges

Mini charts in KPI stat and Metric card show the shape of a trend, not exact values: no axes, no labels. A gauge needs a known range and zones. Set Scale to Low is good or High is good, and label the minimum, the maximum and the value.

Do

  • Use mini charts for shape; link to the full chart for detail.
  • Use a gauge only when the range and the healthy zone are known.
  • Set the gauge Scale to match whether low or high is good.
  • Print the value and its unit under the gauge.

Don't

  • Add axes or tooltips to a mini chart.
  • Use a gauge for a value with no upper limit.
  • Rely on the red and green zones alone.

5. Dashboard layout

Put metrics in a row at the top of a dashboard, most important first, at the inline start. Use one Type per row so values line up. On phones, use Breakpoint=Mobile and stack tiles or show two per row.

Do

  • Show three or four metrics in a row.
  • Put the most important metric first.
  • Use one Type and one comparison period per row.
  • Switch to Breakpoint=Mobile on phones.

Don't

  • Fill a row with eight tiles of equal weight.
  • Mix types in one row.
  • Truncate values to make tiles fit.

6. Arabic and RTL

Use the RTL variant in Arabic. The label, value and trend move to the right and the menu to the left. Gauges mirror, so 0 sits on the right. Mini charts and trend arrows don't mirror: time runs left to right. Numbers use Western digits unless the product switches to Arabic-Indic.

The layout mirrors, the chart doesn't

The transfers tile in Arabic.

Do: RTL variantThe label and value sit on the right in the Arabic fonts; the bars and the arrow keep their direction.
Don't: English variant with Arabic textThe label starts on the left and is set in the Latin fonts.

Before handoff

  • Every label names the metric and the period.
  • Values share one format, unit and rounding.
  • Trend colors follow meaning, with a baseline.
  • Gauges have a range, a Scale and a printed value.
  • Arabic tiles use the RTL variant; charts don't mirror.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabOnly to the menu button and the footer's link and buttons; numbers and charts aren't interactive.

ARIA

  • The trend is read in words (“Up 25%”) and the arrow is hidden, so color and the arrow are never the only signal.
  • Mini charts are hidden from screen readers because the tile says the number; pass label to give one a summary.
  • The gauge and the progress bar are meters with a minimum, maximum and value.
  • The menu button names its metric (“Transfers this month options”).

Do

  • The label, value and trend are read together, in order.
  • Read the trend in words: up 12% from last month.
  • Give a mini chart a text summary, or hide it if the tile already says it.
  • Mark a gauge as a meter with its minimum, maximum and current value.
  • Trend and value text at 4.5:1 contrast.

Don't

  • Announce the arrow icon as an image.
  • Rely on red and green to tell good from bad.

Arabic and RTL notes

Mirrors

  • The label, value and trend sit on the right; the menu on the left.
  • The gauge's dial mirrors and runs from the right.
  • The progress bar fills from the inline start, the right.

Does not mirror

  • Mini charts and bars: time runs left to right.
  • Trend arrows.
  • Numbers and percentages read left to right.
Numerals
Numbers are as you pass them; format them with formatNumber so they follow the product's numerals, the same way on every tile.
Arabic typography
Value heading-28 Semibold in the item and heading-42 Medium in the card; label body-14 or body-16; trend body-14 Medium.
Mixed-direction text
The value and percentage are isolated LTR, so the percent sign and separators don't reorder inside Arabic text.

Do

  • The RTL variant for every tile in an Arabic dashboard.
  • Mirror gauges; keep mini charts and trend arrows unmirrored.
  • Values left to right, with the same number format as English.
  • Write Arabic labels natively, not translated.

Don't

  • Arabic text in the English variant.
  • Flip a chart so time runs right to left.
  • Mix Western and Arabic-Indic digits on one screen.