Interactive Answers

Tick Gauge

A meter drawn as ticks around an arc, with a target marker and the shortfall to it in red — success rates, SLOs, budgets.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/tick-gauge.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { StatusPill } from "@/components/ui/status-pill";
import { TickGauge } from "@/components/ui/tick-gauge";

export function SuccessRate({ ok, total }: { ok: number; total: number }) {
  const rate = ok / total;
  return (
    <TickGauge
      title="Tool call success"
      subtitle="warehouse.query · last 24 h"
      value={rate}
      target={0.99}
      targetLabel="SLO 99%"
      caption={`${total - ok} of ${total} failed`}
      aside={<StatusPill tone={rate >= 0.99 ? "positive" : "negative"}>{rate >= 0.99 ? "Within SLO" : "Below SLO"}</StatusPill>}
    />
  );
}

// Pass null while the check-run request is in flight; keep the stale value
// and set loading when refetching.
export function GaugeState({ query }: { query: GaugeQuery }) {
  return (
    <TickGauge
      title="Success rate"
      value={query.data?.rate ?? null}
      loading={query.isRefetching}
      caption={query.data ? query.data.passing + " of " + query.data.total + " checks" : null}
      target={0.95}
      targetLabel="target"
    />
  );
}

Props

PropTypeDefaultDescription
value*number | null—Current value, 0–1. Pass null while loading.
loadingbooleanfalseForce the fixed-footprint skeleton while refetching, even when a stale value is available.
title*string—Header title.
subtitlestring—Secondary line under the title.
targetnumber—Goal, 0–1. Ticks between the value and the target turn red.
targetLabelstring—Label under the right end of the arc.
captionstring | null—Line under the big number. Pass null while it loads; omit it when the gauge has no caption.
format(value: number) => string—Formats the big number. Defaults to a percent with one decimal.
ticksnumber44Number of ticks on the arc.
asideReactNode—Right side of the header, e.g. a status pill.
labelsPartial<TickGaugeLabels>—Your own UI strings (loading announcement and screen-reader target text), for translating. Right-to-left works under `dir="rtl"`; the arc still fills clockwise.
localestring—BCP 47 locale for the default percent format. Defaults to en-US.
classNamestring—Extra classes for the root element.
// Exposed as role="meter" with the value, caption and target in aria-valuetext.
// Ticks fill in order on mount; later values recolor them in place.