Data & Media
@hacline/ui/waterfallWaterfall
Display request durations or trace spans along a unified timeline axis.
Usage
Expand or collapse nested requests under the root item with Left/Right arrow keys. Each entry provides millisecond start and duration timings, while children determines nesting.
"use client";
import { Waterfall } from "@/components/ui/hacline/components/waterfall";
import type { WaterfallData } from "@/components/ui/hacline/components/waterfall";
const requests: WaterfallData = [
{
children: [
{ duration: 210, label: "Stylesheet", start: 130, value: "styles" },
{ duration: 390, label: "Script", start: 210, value: "script" },
],
duration: 170,
label: "Document",
start: 0,
value: "document",
},
{ duration: 160, label: "User profile", start: 620, value: "profile" },
];
export const Example = () => (
<Waterfall
aria-label="Page request timing"
className="max-w-md"
defaultExpanded={["document"]}
items={requests}
/>
);Marking Key Timeline Milestones
Highlight a 400ms checkpoint with WaterfallAxis and WaterfallMark while locking an explicit time domain.
"use client";
import {
Waterfall,
WaterfallAxis,
WaterfallBar,
WaterfallColumnHeader,
WaterfallHeaderRow,
WaterfallMark,
WaterfallRow,
WaterfallRowHeader,
} from "@/components/ui/hacline/components/waterfall";
import type { WaterfallData } from "@/components/ui/hacline/components/waterfall";
const spans: WaterfallData = [
{ duration: 190, label: "Validate request", start: 0, value: "validate" },
{ duration: 230, label: "Read cache", start: 190, value: "cache" },
{ duration: 95, label: "Serialize response", start: 430, value: "response" },
];
export const Example = () => (
<Waterfall
aria-label="API response timing"
className="max-w-md"
items={spans}
range={[0, 600]}
>
<WaterfallHeaderRow>
<WaterfallColumnHeader>Step</WaterfallColumnHeader>
<WaterfallColumnHeader>
<WaterfallAxis className="h-5" maxTicks={4}>
<WaterfallMark time={400}>400 ms</WaterfallMark>
</WaterfallAxis>
</WaterfallColumnHeader>
</WaterfallHeaderRow>
{spans.map(({ label, value }) => (
<WaterfallRow key={value} value={value}>
<WaterfallRowHeader>{label}</WaterfallRowHeader>
<WaterfallBar />
</WaterfallRow>
))}
</Waterfall>
);Parts
| Part | Description |
|---|---|
WaterfallAxis | The ruler of round times above the bars, hidden from screen readers. Without children, it renders its ticks. |
WaterfallBar | The cell on the time axis, which screen readers hear as the span's start and duration. |
WaterfallCell | A cell of your own, like a status or a size. |
WaterfallColumnHeader | A column's header, like "Name" or "Timeline". |
WaterfallHeaderRow | The row of column headers, above the rows. |
WaterfallIndicator | The arrow that expands and collapses a span with children. |
WaterfallMark | A moment across every row, like DOMContentLoaded, placed by --waterfall-mark. |
WaterfallRow | One span's row. Its --waterfall-start and --waterfall-size place the span's bar. |
WaterfallRowHeader | The cell that names the span. Put the indicator and the span's label in it. |
WaterfallTick | One time on the axis, placed by --waterfall-tick. Without children, it shows the time. |
Props
Prop
Type