Uptime scoreFree

Is reliability in the healthy band?

npx shadcn@latest add https://beautifulcharts.dev/r/uptime-score.json

Usage

A complete client module. Install the item first, then paste it into your app.

"use client";

import { UptimeScoreBlock, type UptimeRow } from "@/components/beautiful-charts/blocks/instrument/uptime-score";

// Your rows, in this shape. A missing value is null and stays a gap; the stats and copy recompute.
const data: UptimeRow[] = [{ value: 99.93, incidents: 2, minutesDown: 30 }];

export function Dashboard() {
  return <UptimeScoreBlock data={data} />;
}

Props

  • data

    UptimeRow[]

    Your rows (UptimeRow = { value: number | null; incidents: number | null; minutesDown: number | null }). Missing values are null and stay gaps; with no rows every stat shows a dash. Leave it out to see the sample.

  • footer

    ReactNode | false

    The line at the bottom: pass your own, or false to hide it. A line or action at the bottom of the card.

Every gauge prop works too, so you can restyle it without touching the source.

Sourcecomponents/beautiful-charts/blocks/instrument/uptime-score.tsx

Show the source (22 lines)
"use client";

import { Gauge, type InstrumentGaugeProps } from "../../themes/instrument/gauge";
import { pickFooter, type BlockOptions } from "../block";

/** Sample: 30-day availability and the incidents behind it. */
export type UptimeRow = { value: number | null; incidents: number | null; minutesDown: number | null };
export const uptimeSample: UptimeRow = { value: 99.93, incidents: 2, minutesDown: 30 };

/** "Is reliability in the healthy band?" A gauge with its bands, and the minutes behind the number. */
export function UptimeScoreBlock({ data = [uptimeSample], footer, ...gauge }: Omit<BlockOptions<UptimeRow>, "stats"> & Partial<InstrumentGaugeProps>) {
  // No row means no measurement: the gauge shows its empty state, never the sample's numbers.
  const now = data[0] ?? null;
  const incidents = now?.incidents ?? null, down = now?.minutesDown ?? null;
  const facts = [incidents === null ? null : `${incidents} ${incidents === 1 ? "incident" : "incidents"}`, down === null ? null : `${down} minutes down`].filter(Boolean).join(", ");
  return (
    <Gauge value={now?.value ?? null} min={99} max={100} target={99.9} eyebrow="Reliability · 30 days" title="Uptime" unit="uptime" valueFormatter={gauge.valueFormatter ?? ((v) => `${v.toFixed(2)}%`)}
      bands={[{ from: 99, to: 99.5, tone: "bad", label: "below SLA" }, { from: 99.5, to: 99.9, tone: "warn", label: "at risk" }, { from: 99.9, to: 100, tone: "good", label: "healthy" }]}
      footer={pickFooter(footer, now ? `${facts ? `${facts}. ` : ""}The SLA target is 99.9%.` : "No measurements for this period.")} {...gauge} />
  );
}

Details

Props every chart shares (2): locale, timeZone
  • locale

    string

    BCP 47 locale. Defaults to "en-US" so server and client render the same text.

  • timeZone

    string

    IANA time zone for dates. Defaults to "UTC" so server and client agree.

Pointer
Not interactive.
Keyboard
Not focusable: there's nothing to move between.
Screen readers
A meter (role="meter") with its range, value and band read as text, for example "99.20%, healthy".
Motion
The value rolls in and the marker settles on it. With reduced motion it appears settled at once.