Krizaka UI
Krizaka UI
Patterns

KPI explained

A figure with its meaning, formula, source, freshness and host-defined thresholds.

Web · ✓Mobile · n/aDesktop · ✓BetaBlocks
import { KpiExplained } from "@krizaka/ui/kpi-explained";

Web only — React, from @krizaka/ui/kpi-explained. Beta: its API may still change in a minor version.

  • Mobile · n/a. The native twin is a follow-up; compose the same data in a native screen for now. → Stat

Why it is here. Akinaza's shop dashboard: monthly sales, spend and margin explained with their source and cadence; Orazaka later.

When to use

  • A shop owner needs to understand a monthly figure, not just read a number.
  • A dashboard must show the origin and age of a key figure.

When not to use

  • A value needs only a label and a trend.Use instead: Stat
  • A reader needs to change or enter the value.Use instead: Field

Installation

Install

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { KpiExplained } from "@krizaka/ui/kpi-explained";

Examples

A salon's month

A shop owner's revenue figure, explained in French with its source and read cadence.

A founder's cockpit

A masked figure for a public capture, without exposing its raw value.

Props

A key figure that explains what it means, how it is calculated and where it came from.

PropTypeDefaultDescription
formatrequiredKpiFormat—How to format the value with @krizaka/intl.
formularequiredstring—The calculation in words, e.g. “dépenses TTC ÷ ventes TTC”.
formulaLabelrequiredReactNode—The localized label for the formula row.
freshnessrequired{ lastRead: DateInput; expectedAt: DateInput; now: DateInput; lastReadLabel: ReactNode; staleLabel: ReactNode; }—Reading time and the expected next reading time (the host derives it from its cadence).
labelrequiredReactNode—The figure's name.
localerequiredLocale—The app's locale, e.g. fr-CA.
maskedLabelrequiredstring—The accessible name shown instead of the value when masked.
meaningrequiredstring—One plain-language sentence about what the figure means.
sourcerequiredReactNode—The source link or file name, supplied by the host.
sourceLabelrequiredReactNode—The localized label for the source row.
stateLabelsrequiredRecord<KpiState, ReactNode>—Host-provided words for the derived state.
thresholdsrequired{ direction: "above" | "below"; watchAt: number; actAt: number; }—Host-provided thresholds in the same units as value.
valuerequirednumber—The raw number: money is integer minor units; percentages are ratios such as 0.125.
maskedbooleanfalseReplace every non-space character in the value while preserving its formatted shape.
sparklineReactNode—An optional Sparkline from @krizaka/charts, with its own accessible summary.
timeZonestringUTCThe IANA time zone for freshness dates; defaults to UTC for deterministic rendering.
verifyReactNode—A host-provided action such as “Verify”, next to the source.

Accessibility

  • The state and stale words remain visible; colour is never the only signal.
  • When masked, the figure is replaced in the DOM and its accessible name is maskedLabel.

Keyboard

KeysAction
TabMoves to the optional source and verify actions.

Best practices

  • Give the meaning and formula in the host's plain language; thresholds and state words come from the host too.
  • Pass the expected read time derived from the host's cadence and an injected now for stable rendering.
  • Pass the host's IANA time zone for freshness dates; the default is UTC.
  • Pass a Sparkline from @krizaka/charts in sparkline; it owns its accessible summary.

Generated from the code of @krizaka/ui 3.63.1: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page