Skip to content

Indicator

The Indicator component renders a compact KPI-style card for displaying a metric value, an optional label, and an optional delta (change) badge.

It is useful for dashboards and summaries such as:

  • number of users
  • revenue / costs
  • accuracy / AUC / latency
  • conversion rate changes
  • experiment comparisons

Indicators can be displayed:

  • as a single card, or
  • as a responsive row of cards (by passing a list of Indicator objects).
import mercury as mr
mr.Indicator(
value="123",
label="Users",
delta=5.4
)
  • value is displayed as the main metric
  • label is shown above the value
  • delta shows a directional badge (green/red/neutral) if numeric

delta can be numeric or text:

  • delta > 0 → green badge with ↑
  • delta == 0 → neutral badge, no arrow
  • delta < 0 → red badge with ↓
  • non-numeric delta → displayed as-is (no arrow logic)
mr.Indicator(value="98%", label="Accuracy", delta=-1.2)
mr.Indicator(value="0%", label="Change", delta=0)
mr.Indicator(value="OK", label="Status", delta="stable")

To render a row of indicators, pass a list of Indicator objects as the value of another Indicator:

import mercury as mr
mr.Indicator([
mr.Indicator(value="123", label="Users", delta=5.4),
mr.Indicator(value="98%", label="Accuracy", delta=-1.2),
mr.Indicator(value="1.3s", label="Latency"),
])

The row is responsive:

  • on wide screens it displays as a row of cards
  • on small screens it switches to a single-column layout

Use the variant parameter to apply a predefined color scheme. Each variant sets the accent bar, border, and badge colors automatically. The card background is always white.

mr.Indicator(value="1,024", label="Users", delta=5.4, variant="primary")
mr.Indicator(value="98%", label="Accuracy", delta=2.1, variant="success")
mr.Indicator(value="340ms", label="Latency", delta=18.0, variant="warning")
mr.Indicator(value="4.2%", label="Error rate", delta=-11.0, variant="danger")
mr.Indicator(value="1.3s", label="P99", variant="neutral")
VariantUse case
primaryDefault, Mercury brand blue
successGood metric, target hit
warningNeeds attention
dangerBad metric, threshold breached
neutralNo signal, structural info
mr.Indicator(value="0.94", label="AUC", delta=0.02, variant="ml")
mr.Indicator(value="17", label="Columns", variant="info")
mr.Indicator(value="$12k", label="Revenue", delta=3.1, variant="teal")
mr.Indicator(value="63%", label="CTR", delta=4.0, variant="pink")
mr.Indicator(value="82%", label="CPU", delta=-1.0, variant="orange")
VariantUse case
mlModel metrics — AUC, accuracy, F1
infoInformational counts
tealFinancial / revenue
pinkMarketing / engagement
orangePerformance / ops
mr.Indicator([
mr.Indicator(value="123", label="Users", delta=5.4, variant="primary"),
mr.Indicator(value="98%", label="Accuracy", delta=-1.2, variant="danger"),
mr.Indicator(value="1.3s", label="Latency", variant="warning"),
mr.Indicator(value="0.94", label="AUC", delta=0.02, variant="ml"),
])

For full control, override individual color parameters. These always take precedence over variant.

import mercury as mr
mr.Indicator(
value="$12,340",
label="Revenue",
delta=3.1,
accent_color="#7c3aed",
border_color="#ddd6fe",
value_color="#111827",
label_color="#6b7280",
)

accent_color controls the 3px top bar. border_color, value_color, and label_color are applied directly to the rendered HTML card.

type: any

Main value displayed in the card.

Special case: if value is a list of Indicator instances, they are rendered together as a row.


type: string

Optional label shown above the value.

Default: ""


type: float | string | None

Optional change badge.

  • delta > 0 → green badge with ↑
  • delta == 0 → neutral badge, no arrow
  • delta < 0 → red badge with ↓
  • string → shown as provided, no arrow logic
  • None → no badge

Default: None


type: string

Predefined color preset. Sets accent_color, border_color, and badge colors in one go.

Semantic: "primary", "success", "warning", "danger", "neutral"

Domain: "ml", "info", "teal", "pink", "orange"

Default: "primary"


type: string

Color of the 3px top accent bar. Overrides variant when set.

Default: None (resolved from variant)


type: string

Card background color.

Default: "#ffffff"


type: string

Card border color. Overrides variant when set.

Default: None (resolved from variant)


type: string

Text color of the main value.

Default: "#111827"


type: string

Text color of the label.

Default: "#6b7280"


  • Indicator renders HTML using the _repr_html_ protocol.
  • Multiple indicators can be grouped into a responsive row.
  • Numeric deltas are formatted as percentages (abs(delta)%) with trailing zeros stripped. Zero is treated as a neutral state — no arrow, badge color is taken from the active variant.
  • Explicit color params (accent_color, border_color) always take precedence over variant.