Status Monitor
8starlabs-ui/status-monitorFreeComponent
A compact status history bar for showing service uptime across days or hours.
Live preview
live · rendered by the registry
Rendered by 8starlabs-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.8starlabs.com/r/status-monitor.jsonSource
1"use client";23import React, { useEffect, useMemo, useRef, useState } from "react";4import {5 AlertTriangleIcon,6 CheckCircle2Icon,7 CircleOffIcon,8 XCircleIcon9} from "lucide-react";1011import {12 Tooltip,13 TooltipContent,14 TooltipProvider,15 TooltipTrigger16} from "@/registry/8starlabs-ui/ui/tooltip";17import { cn } from "@/lib/utils";1819type AppStatus = "normal" | "warning" | "error" | "empty";2021export type AppStatusData = {22 status: AppStatus;23 timestamp?: string | Date;24 info?: string;25};2627export interface StatusMonitorProps28 extends React.HTMLAttributes<HTMLDivElement> {29 statuses: AppStatusData[];30 unit?: "days" | "hours";31 title?: string;32 showUptime?: boolean;33}3435interface AppStatusConfigData {36 label: string;37 defaultInfo: string;38 barClassName: string;39 textClassName: string;40 Icon: React.ComponentType<React.SVGProps<SVGSVGElement>>;41}4243const statusConfig = {44 normal: {45 label: "Normal",46 defaultInfo: "Systems are operating normally.",47 barClassName: "bg-green-600",48 textClassName: "text-green-600",49 Icon: CheckCircle2Icon50 },51 warning: {52 label: "Warning",53 defaultInfo:54 "Systems are operating with elevated risk or degraded service.",55 barClassName: "bg-amber-600",56 textClassName: "text-amber-600",57 Icon: AlertTriangleIcon58 },59 error: {60 label: "Error",61 defaultInfo: "A service-impacting incident is active.",62 barClassName: "bg-red-600",63 textClassName: "text-red-600",64 Icon: XCircleIcon65 },66 empty: {67 label: "No data",68 defaultInfo: "No status data was recorded for this period.",69 barClassName: "bg-muted",70 textClassName: "text-muted-foreground",71 Icon: CircleOffIcon72 }73} satisfies Record<AppStatus, AppStatusConfigData>;7475const BAR_WIDTH_PX = 5;76const BAR_GAP_PX = 2;77const MIN_VISIBLE_SLOTS = 30;78const SLOT_COUNTS = [90, 60, MIN_VISIBLE_SLOTS] as const;7980function getTimelineWidth(numSlots: number) {81 return numSlots * BAR_WIDTH_PX + (numSlots - 1) * BAR_GAP_PX;82}8384function calculateNumDisplayableBars(width: number) {85 return SLOT_COUNTS.find((slots) => width >= getTimelineWidth(slots)) ?? 30;86}8788function formatTimestamp(timestamp: AppStatusData["timestamp"]) {89 if (!timestamp) return undefined;9091 if (timestamp instanceof Date) {92 return new Intl.DateTimeFormat("en-US", {93 month: "short",94 day: "2-digit",95 year: "numeric"96 }).format(timestamp);97 }9899 return timestamp;100}101102export default function StatusMonitor({103 statuses,104// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from 8starlabs-ui
All 74 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Buttonbutton | 8starlabs-ui | Components | Free | 2 deps | |
| Collapsiblecollapsible | 8starlabs-ui | Components | Free | 1 dep | |
| Dropdown Menudropdown-menu | 8starlabs-ui | Components | Free | 2 deps | |
| Flip clockflip-clock | 8starlabs-ui | Components | Free | no deps | |
| Heatmapheatmap | 8starlabs-ui | Components | Free | no deps | |
| Inputinput | 8starlabs-ui | Components | Free | no deps | |
| JSON Viewerjson-viewer | 8starlabs-ui | Components | Free | 1 dep · 3 files | |
| Labellabel | 8starlabs-ui | Components | Free | no deps |
