Uptime card
A multi-service system status card with 45 uniform daily status ticks per service and a live hover/focus incident banner.
pnpm dlx shadcn@latest add @haze/uptime-card---
import { CircleCheck, CircleX, TriangleAlert } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";
type ServiceStatus = "operational" | "degraded" | "outage";
interface UptimeDay {
date: string;
status: ServiceStatus;
note?: string;
}
interface UptimeService {
name: string;
uptime: string;
days: UptimeDay[];
}
interface Props {
title?: string;
subtitle?: string;
status?: ServiceStatus;
statusLabel?: string;
services?: UptimeService[];
rangeStartLabel?: string;
rangeEndLabel?: string;
headingLevel?: 2 | 3 | 4;
class?: string;
}
const dayLabels = [
"Aug 31", "Sep 1", "Sep 2", "Sep 3", "Sep 4", "Sep 5", "Sep 6", "Sep 7", "Sep 8",
"Sep 9", "Sep 10", "Sep 11", "Sep 12", "Sep 13", "Sep 14", "Sep 15", "Sep 16", "Sep 17",
"Sep 18", "Sep 19", "Sep 20", "Sep 21", "Sep 22", "Sep 23", "Sep 24", "Sep 25", "Sep 26",
"Sep 27", "Sep 28", "Sep 29", "Sep 30", "Oct 1", "Oct 2", "Oct 3", "Oct 4", "Oct 5",
"Oct 6", "Oct 7", "Oct 8", "Oct 9", "Oct 10", "Oct 11", "Oct 12", "Oct 13", "Today",
];
function makeHistory(
overrides: Record<number, { status: ServiceStatus; note: string }>,
): UptimeDay[] {
return dayLabels.map((date, idx) => {
const incident = overrides[idx];
return incident
? { date, status: incident.status, note: incident.note }
: { date, status: "operational" };
});
}
const defaultServices: UptimeService[] = [
{
name: "API",
uptime: "99.98%",
days: makeHistory({
17: { status: "degraded", note: "Elevated edge latency for 9 min in EU-West." },
34: { status: "degraded", note: "Brief rate-limiter spike resolved in 4 min." },
}),
},
{
name: "Dashboard",
uptime: "100.00%",
days: makeHistory({}),
},
{
name: "Webhooks",
uptime: "99.96%",
days: makeHistory({
11: { status: "degraded", note: "Retry queue backlog cleared after 14 min." },
28: { status: "outage", note: "Delivery worker outage for 11 min during deploy." },
39: { status: "degraded", note: "Elevated TLS handshake retries for 6 min." },
}),
},
{
name: "Database",
uptime: "99.99%",
days: makeHistory({
22: { status: "degraded", note: "Automated replica failover completed in 42 s." },
}),
},
];
const {
title = "System status",
subtitle = "Hover a day to see what happened",
status = "operational",
statusLabel,
services = defaultServices,
rangeStartLabel = "45 days ago",
rangeEndLabel = "Today",
headingLevel = 3,
class: className,
} = Astro.props;
const Heading = ({ 2: "h2", 3: "h3", 4: "h4" } as const)[headingLevel];
const overallMeta: Record<ServiceStatus, { label: string; text: string }> = {
operational: { label: "All systems operational", text: "text-success" },
degraded: { label: "Partial degradation", text: "text-warning" },
outage: { label: "Active service outage", text: "text-destructive" },
};
const dayMeta: Record<ServiceStatus, { label: string; tick: string }> = {
operational: { label: "Operational", tick: "bg-success/85 hover:bg-success" },
degraded: { label: "Degraded", tick: "bg-warning hover:bg-warning/90" },
outage: { label: "Outage", tick: "bg-destructive hover:bg-destructive/90" },
};
const resolvedStatusLabel = statusLabel ?? overallMeta[status].label;
const totalIncidents = services.reduce(
(sum, svc) => sum + svc.days.filter((d) => d.status !== "operational").length,
0,
);
const defaultSummary =
totalIncidents > 0
? `${services.length} services monitored · ${totalIncidents} incident ${totalIncidents === 1 ? "day" : "days"} in window.`
: `${services.length} services monitored · Zero incidents across the window.`;
---
<article
data-haze-uptime-card
class={cn(
"grid w-full max-w-[440px] min-w-0 gap-4 rounded-xl border border-border bg-card p-4.5 text-card-foreground",
className,
)}
>
<div class="flex min-w-0 flex-wrap items-start justify-between gap-x-3 gap-y-1.5">
<div class="grid min-w-0 gap-0.5">
<Heading class="text-sm/5 font-semibold tracking-tight text-card-foreground wrap-anywhere">
{title}
</Heading>
{subtitle && <p class="text-[0.8125rem]/5 text-muted-foreground wrap-anywhere">{subtitle}</p>}
</div>
<span
class={cn(
"inline-flex shrink-0 items-center gap-1.5 text-xs/4 font-medium",
overallMeta[status].text,
)}
>
{status === "operational" && <CircleCheck aria-hidden="true" class="size-3.5 shrink-0" />}
{status === "degraded" && <TriangleAlert aria-hidden="true" class="size-3.5 shrink-0" />}
{status === "outage" && <CircleX aria-hidden="true" class="size-3.5 shrink-0" />}
<span>{resolvedStatusLabel}</span>
</span>
</div>
<div class="grid min-w-0 gap-3.5">
{services.map((svc) => (
<div class="grid min-w-0 gap-1.5" data-uptime-service-row>
<div class="flex min-w-0 items-baseline justify-between gap-2">
<span class="truncate text-xs/4 font-medium text-foreground">{svc.name}</span>
<span class="shrink-0 font-mono text-xs/4 text-muted-foreground tabular-nums">{svc.uptime}</span>
</div>
<div
role="slider"
tabindex="0"
data-uptime-track
aria-label={`${svc.name} daily availability`}
aria-valuemin={1}
aria-valuemax={Math.max(1, svc.days.length)}
aria-valuenow={Math.max(1, svc.days.length)}
aria-valuetext={svc.days.length > 0 ? `${svc.days.at(-1)!.date}: ${dayMeta[svc.days.at(-1)!.status].label}` : svc.uptime}
class="flex h-6 w-full min-w-0 items-center gap-[2px] rounded-xs focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"
>
{svc.days.map((day) => {
const info = dayMeta[day.status];
return (
<span
aria-hidden="true"
data-uptime-tick
data-service={svc.name}
data-date={day.date}
data-state={day.status}
data-state-label={info.label}
data-note={day.note ?? ""}
class={cn(
"h-full min-w-0 flex-1 cursor-pointer rounded-[2px] transition-[background-color,scale] duration-150 ease-snappy hover:scale-y-110 data-[active]:scale-y-110 data-[active]:ring-1 data-[active]:ring-ring motion-reduce:transition-none",
info.tick,
)}
/>
);
})}
</div>
</div>
))}
</div>
<div class="grid min-w-0 gap-2">
<div
data-uptime-banner
data-status={status}
aria-live="polite"
class="flex min-h-8 min-w-0 items-center gap-2 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5 text-xs/4 text-muted-foreground"
>
<span
aria-hidden="true"
data-uptime-dot
data-state={status}
class="size-2 shrink-0 rounded-full data-[state=degraded]:bg-warning data-[state=operational]:bg-success data-[state=outage]:bg-destructive"
/>
<p
data-uptime-readout
data-default-summary={defaultSummary}
data-default-state={status}
class="min-w-0 flex-1 truncate tabular-nums"
>
{defaultSummary}
</p>
</div>
<div class="flex min-w-0 items-center justify-between gap-2 text-xs/4 text-muted-foreground tabular-nums">
<span>{rangeStartLabel}</span>
<span>{rangeEndLabel}</span>
</div>
</div>
</article>
<script>
function enhance(root: HTMLElement) {
if (root.hasAttribute("data-enhanced")) return;
const readout = root.querySelector<HTMLElement>("[data-uptime-readout]");
const dot = root.querySelector<HTMLElement>("[data-uptime-dot]");
const tracks = Array.from(root.querySelectorAll<HTMLElement>("[data-uptime-track]"));
const allTicks = Array.from(root.querySelectorAll<HTMLElement>("[data-uptime-tick]"));
if (!readout || !dot || allTicks.length === 0) return;
const defaultSummary = readout.dataset.defaultSummary ?? readout.textContent ?? "";
const defaultState = readout.dataset.defaultState ?? "operational";
let pinned: HTMLElement | null = null;
const renderTick = (tick: HTMLElement | null) => {
if (!tick) {
readout.textContent = defaultSummary;
dot.setAttribute("data-state", defaultState);
return;
}
const svc = tick.dataset.service ?? "";
const date = tick.dataset.date ?? "";
const label = tick.dataset.stateLabel ?? "";
const state = tick.dataset.state ?? "operational";
const note = tick.dataset.note ?? "";
readout.textContent = note ? `${svc} · ${date} · ${label} — ${note}` : `${svc} · ${date} · ${label}`;
dot.setAttribute("data-state", state);
};
const setActive = (tick: HTMLElement | null) => {
allTicks.forEach((el) => {
if (el === tick) el.setAttribute("data-active", "");
else el.removeAttribute("data-active");
});
};
const setPinned = (tick: HTMLElement | null) => {
pinned = tick;
setActive(pinned);
renderTick(pinned);
};
tracks.forEach((track) => {
const ticks = Array.from(track.querySelectorAll<HTMLElement>("[data-uptime-tick]"));
let currentIdx = Math.max(0, ticks.length - 1);
const focusIdx = (nextIdx: number) => {
currentIdx = Math.max(0, Math.min(ticks.length - 1, nextIdx));
const tick = ticks[currentIdx];
if (!tick) return;
track.setAttribute("aria-valuenow", String(currentIdx + 1));
const date = tick.dataset.date ?? "";
const label = tick.dataset.stateLabel ?? "";
const note = tick.dataset.note ?? "";
track.setAttribute("aria-valuetext", note ? `${date}: ${label}. ${note}` : `${date}: ${label}`);
setActive(tick);
renderTick(tick);
};
track.addEventListener("focus", () => focusIdx(currentIdx));
track.addEventListener("blur", () => {
setActive(pinned);
renderTick(pinned);
});
track.addEventListener("keydown", (event) => {
if (event.key === "Escape") {
setPinned(null);
return;
}
if (event.key === "ArrowRight") {
event.preventDefault();
focusIdx(currentIdx + 1);
} else if (event.key === "ArrowLeft") {
event.preventDefault();
focusIdx(currentIdx - 1);
} else if (event.key === "Home") {
event.preventDefault();
focusIdx(0);
} else if (event.key === "End") {
event.preventDefault();
focusIdx(ticks.length - 1);
} else if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
const tick = ticks[currentIdx] ?? null;
setPinned(pinned === tick ? null : tick);
}
});
ticks.forEach((tick, idx) => {
tick.addEventListener("pointerenter", () => {
currentIdx = idx;
setActive(tick);
renderTick(tick);
});
tick.addEventListener("pointerleave", () => {
setActive(pinned);
renderTick(pinned);
});
tick.addEventListener("click", () => {
currentIdx = idx;
setPinned(pinned === tick ? null : tick);
});
});
});
root.setAttribute("data-enhanced", "");
}
const init = () => document.querySelectorAll<HTMLElement>("[data-haze-uptime-card]").forEach(enhance);
init();
if (!document.documentElement.hasAttribute("data-haze-uptime-card-listener")) {
document.documentElement.setAttribute("data-haze-uptime-card-listener", "");
document.addEventListener("astro:page-load", init);
}
</script>When to use
- A status dashboard presents multiple core services side-by-side with their 45-day uptime history and percentages
- Users need to inspect individual days on hover, focus, or click to see service status and incident notes without layout shift
When not to use
- Only a single compact status strip without service breakdown is needed. Use uptime-tracker.
- You only need an inline indicator for current status without historical days. Use status.
Installation
Add the Haze registry to components.json once, then install Uptime card with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/uptime-cardnpx shadcn@latest add @haze/uptime-cardyarn dlx shadcn@latest add @haze/uptime-cardbunx --bun shadcn@latest add @haze/uptime-cardFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "System status" | Card heading text. |
| subtitle | string | "Hover a day to see what happened" | Helper caption beneath the heading. |
| status | "operational" | "degraded" | "outage" | "operational" | Overall system status indicator in the header. |
| statusLabel | string | – | Custom label for the header status indicator; defaults to a phrase matching status. |
| services | { name: string; uptime: string; days: { date: string; status: "operational" | "degraded" | "outage"; note?: string }[] }[] | – | List of monitored services with their formatted uptime percentage and daily tick records. |
| rangeStartLabel | string | "45 days ago" | Left-hand timeline axis label. |
| rangeEndLabel | string | "Today" | Right-hand timeline axis label. |
| headingLevel | 2 | 3 | 4 | 3 | Heading level for the card title. |
| class | string | – | Additional classes on the outer card element. |
Keyboard interactions
- TabLeft or Right Arrow
- Move focus across daily status ticks within a service row and update the live banner.
- Enter or Space
- Pin or unpin the focused day in the inspection banner.
- Escape
- Clear the pinned day and restore the summary readout.
Accessibility
- Every daily status tick is a native focusable button with a descriptive aria-label naming the service, date, status, and any incident note.
- Hovering, focusing, or pinning a tick updates an aria-live="polite" inspection banner with a fixed minimum height to avoid layout shifts.
- The header status pairs an icon with explicit text so system health is never conveyed by color alone.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Uptime card" with `npx shadcn@latest add @haze/uptime-card`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import UptimeCard from "@/components/haze/ui/uptime-card.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/uptime-card.md
Customize with real content
Adapt the Haze uptime-card ui for our product. Replace the demo values of these props with our real content: title, subtitle, status, statusLabel, services, rangeStartLabel, rangeEndLabel, headingLevel, class. Keep the layout, the heading level rules and these accessibility details: Every daily status tick is a native focusable button with a descriptive aria-label naming the service, date, status, and any incident note. Hovering, focusing, or pinning a tick updates an aria-live="polite" inspection banner with a fixed minimum height to avoid layout shifts. The header status pairs an icon with explicit text so system health is never conveyed by color alone. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using uptime-card, check it fits: use it when a status dashboard presents multiple core services side-by-side with their 45-day uptime history and percentages; users need to inspect individual days on hover, focus, or click to see service status and incident notes without layout shift. Avoid it when only a single compact status strip without service breakdown is needed. use uptime-tracker.; you only need an inline indicator for current status without historical days. use status.. Alternatives: @haze/uptime-tracker, @haze/status, @haze/metric-card.
Dependencies
- npm: @lucide/astro
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.