Updated
Request Waterfall
NewCustomize
Color
Width640px
Installation
npx shadcn@latest add https://uibrik.com/r/request-waterfall.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/request-waterfall/request-waterfall.tsx"use client"; // A network waterfall, like the one in browser dev tools, without the noise. // Bars draw in from left to right in the order the requests started. Hovering a // row pulls its bar apart into phases (DNS, connect, TLS, waiting, download) // and names its time; opening it lays each phase out on its own line, on the // same time axis, so you can see where the time went. Phases are shades of one // colour; markers show when the page became interactive and finished loading. // Hovering a row draws guides at its start and end across the list and dims // the rest; hovering a marker dims every request that finished after it. import { IconAlertTriangle, IconArrowsExchange, IconCode, IconFile, IconFileText, IconPalette, IconPhoto, IconTypography } from "@tabler/icons-react"; import { AnimatePresence, motion, useInView, useReducedMotion } from "motion/react"; import { useId, useMemo, useRef, useState, type CSSProperties } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const OPEN = { type: "spring", duration: 0.36, bounce: 0 } as const; export type RequestPhases = { queued?: number; dns?: number; connect?: number; tls?: number;
Adds the files to
components/uibrik/request-waterfall and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/request-waterfall.Usage
import { RequestWaterfall } from "@/components/uibrik/request-waterfall/request-waterfall";const requests = [ { name: "acme.shop", type: "document", size: 18400, start: 0, status: 200, phases: { dns: 28, connect: 34, tls: 46, waiting: 142, download: 18 } }, { name: "app.css", type: "style", size: 32800, start: 276, status: 200, phases: { queued: 4, waiting: 58, download: 22 } }, // …10 more];const markers = [ { label: "DOMContentLoaded", time: 612 }, { label: "Load", time: 1184 },];<RequestWaterfall title="Network" color="#2f7cf6" showSize width={640} requests={requests} markers={markers} defaultOpen={null} // open={0} // onOpenChange={(index) => {}}/>Where to use Request Waterfall
Performance and observability tools
Phases that pull apart on hover show where a request spent its time without a separate panel.
Pairs with Stack Trace
Developer tool landing pages
A waterfall that draws itself in explains page loading in a few seconds.
Pairs with Performance Meter
API and CDN dashboards
Markers for DOMContentLoaded and Load put every request in the context of the page.
Props
RequestWaterfall- title
- Type string
- "Network"
- Heading above the totals.
- color
- Type string
- "#2f7cf6"
- Colour the phases are shaded from.
- showSize
- Type boolean
- true
- Show transfer sizes when there is room.
- width
- Type number
- 640
- Width of the card; never wider than its container.
- requests
- Type { name: string; type: string; size?: number; start: number; status?: number; phases: { queued?, dns?, connect?, tls?, waiting?, download?: number } }[]
- –
- One row per request. start and phases are in ms; statuses of 400 and up are marked.
- markers
- Type { label: string; time: number }[]
- –
- Dashed lines across the rows, e.g. DOMContentLoaded and Load.
- open / onOpenChange
- Type number | null / (index) => void
- –
- Index of the open row, controlled.
- defaultOpen
- Type number | null
- null
- Open row on mount when uncontrolled.
- className
- Type string
- –
- Classes for the wrapper.