nook
Browse the docs

Components

Uptime bar

Built on Base UI

Square daily availability cells and a service monitor with latency trends.

See the prompt

1 service degraded

  • Public API

    Operational

    99.93%

    90 days uptime

    2026-08-012026-10-29
  • Build pipeline

    Degraded

    99.94%

    90 days uptime

    2026-08-012026-10-29
  • Asset delivery

    Operational

    99.97%

    90 days uptime

    2026-08-012026-10-29
  • Operational
  • Degraded
  • Outage
  • No data

Installation

npx nook-ui@latest add uptime-bar

Prompt

Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.

Short. For assistants that can run commands in your project.

Plain text
Add the Nook "Uptime bar" component to this project, exactly as Nook ships it.

Square daily availability cells and a service monitor with latency trends.

Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add uptime-bar`. It writes `components/ui/uptime-bar.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/uptime-bar.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:

```tsx
import { StatusMonitor, type UptimeDay } from "@/components/ui/uptime-bar";
function history(seed: number): UptimeDay[] {
  let state = seed;
  return Array.from({ length: 90 }, (_, index) => {
    state = (state * 1664525 + 1013904223) >>> 0;
    const status =
      state % 71 === 0
        ? "outage"
        : state % 29 === 0
          ? "degraded"
          : "operational";
    return {
      date: new Date(Date.UTC(2026, 7, index + 1)).toISOString().slice(0, 10),
      status,
      uptime:
        status === "operational" ? 100 : status === "degraded" ? 99.2 : 97.8,
      incident:
        status === "outage"
          ? "Requests failed for 32 minutes. Resolved."
          : status === "degraded"
            ? "Elevated response times for 12 minutes. Resolved."
            : "No incidents reported.",
    };
  });
}
const services = [
  {
    id: "api",
    name: "Public API",
    status: "operational" as const,
    days: history(17),
    latency: [42, 38, 51, 45, 39, 43, 36, 40, 38, 35],
  },
  {
    id: "builds",
    name: "Build pipeline",
    status: "degraded" as const,
    days: history(31),
    latency: [80, 74, 83, 95, 110, 120, 140, 156, 148, 161],
  },
  {
    id: "cdn",
    name: "Asset delivery",
    status: "operational" as const,
    days: history(53),
    latency: [18, 21, 20, 17, 19, 16, 18, 19, 17, 18],
  },
];
export default function UptimeDefault() {
  return <StatusMonitor className="max-w-xl" services={services} />;
}
```

API
- `UptimeBar`: A wrapping row of supplied daily cells, usually 90.
  - `days` (`UptimeDay[]`): ISO date, status, incident and optional daily uptime percentage.
  - `legend` (`boolean`): Show status labels; default true.
  - `label` (`string`): Names the daily availability group.
- `StatusMonitor`: An overall banner and service list.
  - `services` (`MonitoredService[]`): id, name, days, current status, latency values and optional uptime override.
- `uptimePercentage`: Average known daily availability; no data returns null.
  - `days` (`UptimeDay[]`): No-data days are excluded. Non-operational days without a measured uptime count as unavailable.

Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Every day is focusable and names its date, status and incident. A tooltip repeats the information. Degraded, outage and no-data cells have distinct marks; the legend names all states. Sparkline labels include values.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { StatusMonitor, type UptimeDay } from "@/components/ui/uptime-bar";
function history(seed: number): UptimeDay[] {
  let state = seed;
  return Array.from({ length: 90 }, (_, index) => {
    state = (state * 1664525 + 1013904223) >>> 0;
    const status =
      state % 71 === 0
        ? "outage"
        : state % 29 === 0
          ? "degraded"
          : "operational";
    return {
      date: new Date(Date.UTC(2026, 7, index + 1)).toISOString().slice(0, 10),
      status,
      uptime:
        status === "operational" ? 100 : status === "degraded" ? 99.2 : 97.8,
      incident:
        status === "outage"
          ? "Requests failed for 32 minutes. Resolved."
          : status === "degraded"
            ? "Elevated response times for 12 minutes. Resolved."
            : "No incidents reported.",
    };
  });
}
const services = [
  {
    id: "api",
    name: "Public API",
    status: "operational" as const,
    days: history(17),
    latency: [42, 38, 51, 45, 39, 43, 36, 40, 38, 35],
  },
  {
    id: "builds",
    name: "Build pipeline",
    status: "degraded" as const,
    days: history(31),
    latency: [80, 74, 83, 95, 110, 120, 140, 156, 148, 161],
  },
  {
    id: "cdn",
    name: "Asset delivery",
    status: "operational" as const,
    days: history(53),
    latency: [18, 21, 20, 17, 19, 16, 18, 19, 17, 18],
  },
];
export default function UptimeDefault() {
  return <StatusMonitor className="max-w-xl" services={services} />;
}

Examples

Website uptime

2026-10-012026-10-30
  • Operational
  • Degraded
  • Outage
  • No data

All operational

2026-11-012026-11-14
  • Operational
  • Degraded
  • Outage
  • No data

Props

UptimeBar

A wrapping row of supplied daily cells, usually 90.

PropTypeDefaultDescription
daysUptimeDay[]–ISO date, status, incident and optional daily uptime percentage.
legendboolean–Show status labels; default true.
labelstring–Names the daily availability group.

StatusMonitor

An overall banner and service list.

PropTypeDefaultDescription
servicesMonitoredService[]–id, name, days, current status, latency values and optional uptime override.

uptimePercentage

Average known daily availability; no data returns null.

PropTypeDefaultDescription
daysUptimeDay[]–No-data days are excluded. Non-operational days without a measured uptime count as unavailable.

Accessibility

Every day is focusable and names its date, status and incident. A tooltip repeats the information. Degraded, outage and no-data cells have distinct marks; the legend names all states. Sparkline labels include values.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.