Xzero UI
Pro library

Realtime streamPro

A live line that scrolls at 60fps as readings arrive, holds still on hover to read, and pops a marker on every anomaly.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/realtime-stream
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/realtime-stream

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { RealtimeStream, type StreamPoint } from "@/components/xzero/realtime-stream/realtime-stream";

export function Latency({ socket }: { socket: WebSocket }) {
  const [points, setPoints] = useState<StreamPoint[]>([]);
  useEffect(() => {
    const onMessage = (event: MessageEvent) => {
      const { t, p95 } = JSON.parse(event.data);
      setPoints(list => [...list.slice(-200), { t, value: p95, anomaly: p95 > 300 ? "Spike" : undefined }]);
    };
    socket.addEventListener("message", onMessage);
    return () => socket.removeEventListener("message", onMessage);
  }, [socket]);
  return <RealtimeStream points={points} label="p95 latency" unit="ms" interval={500} />;
}

API reference

RealtimeStream

A live line chart on a canvas that scrolls continuously at the display rate. It draws one interval behind the newest reading so each point slides in, eases its value axis, pops a marker for anomalies, and holds still on hover so a point can be read while new ones queue.

PropTypeDefaultDescription
points (required)StreamPoint[]–Append-only feed in ascending time: { t, value, anomaly? }. A string anomaly becomes the marker tag.
label (required)string–What is measured. Names the chart, the current value, and the table.
unitstring""Unit after values, such as "ms".
windowMsnumber30000Visible span of time.
intervalnumber1000Typical time between points. The view trails the newest point by this much.
heightnumber200Plot height in pixels.
formatValue(value: number) => string–Formats values in the readout, tooltip, and table.
formatTime(t: number) => stringHH:MM:SSFormats times in the tooltip and table.
pausedboolean–Controlled pause.
defaultPausedbooleanfalseInitial pause when uncontrolled.
onPausedChange(paused: boolean) => void–Called when the status button or Space toggles the pause.
pauseOnHoverbooleantrueHolds the view while the pointer is over the plot.
minnumber–Fixed bottom of the value axis. Leave it out to follow the data.
maxnumber–Fixed top of the value axis.
emptyLabelstring"Waiting for data"Shown before the first point.
refRef<HTMLElement>–Forwarded to the figure.
classNamestring–Extra class on the figure.

Keyboard interactions

KeysAction
TabFocuses the plot, holds the view, and reads the newest visible point.
ArrowLeft / ArrowRightPrevious or next point.
PageUp / PageDownTen points back or forward.
Home / EndOldest or newest visible point.
Space / EnterPauses or resumes the stream.
EscapeClears the reading and resumes.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in advanced charts

Guidance for AI tools

Realtime stream: A live line that scrolls at 60fps as readings arrive, holds still on hover to read, and pops a marker on every anomaly. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components