Skip to content
WANCRAFT

G.89Data & Feedback

Uptime Bar

Status-page uptime bars: one bar per day, computed overall uptime, a legend and tooltips on hover, tap and keyboard focus.

NewReactCSSTailwindintermediate

Overview

Uptime Bar renders the familiar status-page strip: a thin bar for each of the last 90 days, coloured by status, with the overall uptime worked out from your data. On narrow screens it drops the oldest days instead of squeezing bars into slivers. Hover, tap or arrow through the days to see the date, status, uptime and any incident note. Status never relies on colour alone: degraded days are hatched, days without data are outlined, the legend and tooltip name each status, and every bar has a full text label in a one-row ARIA grid with a single tab stop.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/uptime-bar.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/uptime-bar.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/uptime-bar.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { UptimeBar, type UptimeDay } from "@/components/ui/uptime-bar";

export function UptimeBarExample() {
  // Replace with your monitoring data, oldest first.
  const days: UptimeDay[] = Array.from({ length: 90 }, (_, i) => ({
    date: new Date(Date.UTC(2026, 6, 15) + i * 86_400_000).toISOString().slice(0, 10),
    status: i === 41 ? "down" : i % 23 === 7 ? "degraded" : "up",
    uptime: i === 41 ? 97.9 : i % 23 === 7 ? 99.6 : 100,
  }));

  return (
    <UptimeBar label="API" days={days} />
  );
}

03Props

PropTypeDefaultDescription
days{ date: string; status: "up" | "degraded" | "down" | "none"; uptime?: number; note?: string }[]—Required. Days oldest first; the most recent ones are shown.
labelstring"Uptime"Service name for the header and the grid's accessible name.
maxBarsnumber90Maximum number of days shown.
minBarWidthnumber3Narrowest bar in px; older days are dropped when the container is too narrow.
barHeightnumber32Bar height in px.
gapnumber2Gap between bars in px.
radiusnumber1Bar corner radius in px.
showSummarybooleantrueHeader with the latest status and the overall uptime.
showLegendbooleantrueKey for every status.
upColor / degradedColor / downColorstring"#2FBF71" / "#F5B83D" / "#E5484D"Status colours.
localestring"en-GB"Locale for dates and percentages.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root element.

04Features

  • 01One bar per day with up, degraded, down and no-data states
  • 02Overall uptime computed from the visible days
  • 03Responsive: shows fewer days on narrow containers instead of slivers
  • 04Shared tooltip for hover, tap and keyboard focus with date, status, uptime and note
  • 05Legend and header with the latest status
  • 06UTC date handling; deterministic output for SSR
input · hoverinput · keyboardinput · focusinput · click

05Accessibility

  • The bars form a one-row role="grid" with a single roving tab stop on the latest day; arrows move by day, Page Up / Down by a week, Home / End to the ends, Escape hides the tooltip.
  • Each bar has a text label such as “13 Oct 2026: Outage, 97.90% uptime. API errors in eu-west”, and a visually hidden summary gives the overall uptime and incident count.
  • Status is not colour-only: degraded days are hatched, no-data days are outlined, and the legend and tooltip spell out each status.
  • Tooltips open on keyboard focus and on tap as well as on hover.

06Limitations

  • Days without an uptime value count as 100% (up or degraded) or 0% (down) in the overall figure; pass uptime for accurate numbers.
  • Before the first measurement (server render) all maxBars days are drawn; narrow screens then drop the oldest.