Waterfall
Spans — a page's requests, a trace, a build — as bars on a shared time axis; a span that started others opens on them.
Usage
Usage
import { Component, ViewEncapsulation } from '@angular/core';import { ScWaterfall, ScWaterfallAxis, ScWaterfallBar, type ScWaterfallBarLabel, ScWaterfallCell, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator,Anatomy
You loop over the rows shown — rows(), the spans whose parents are open — a row each: its header (the indicator and the label), your cells, its bar. The header row, the axis and the marks are optional.
import { ScWaterfall, ScWaterfallAxis, ScWaterfallBar, ScWaterfallCell, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator, ScWaterfallMark, ScWaterfallRow, ScWaterfallRowHeader } from '@semantic-components/ui';<div scWaterfall #waterfall="scWaterfall" aria-label="Requests" [items]="spans"> <div scWaterfallHeaderRow> <div scWaterfallColumnHeader class="w-48">Name</div> <div scWaterfallColumnHeader aria-label="Timeline" class="flex-1"> <div scWaterfallAxis> <span scWaterfallMark [time]="620">DOMContentLoaded</span> </div> </div> </div> @for (row of waterfall.rows(); track row.item.value) { <div scWaterfallRow [row]="row"> <div scWaterfallRowHeader> <button scWaterfallIndicator><svg siChevronRightIcon></svg></button> {{ row.item.label }} </div> <div scWaterfallCell class="w-20">…</div> <div scWaterfallBar></div> </div> }</div>Spans and time
A span is { value, label, start, duration, children? }, in milliseconds on a shared clock. Its bar is a share of the range (by default, the first start to the last end) — --sc-waterfall-start, --sc-waterfall-size — from the start of the line; out of it, held to its edge. Times are written with format (milliseconds by default), in the app's language; a bar is read as its times ("120–460 ms"), or as barLabel says.
Keyboard
| Key | Does |
|---|---|
| ↓ / ↑ | The next / previous row |
| → | Opens the span, or goes to its first child |
| ← | Closes the span, or goes to its parent |
| Home / End, Page Up / Page Down | The first / last row; ten rows |
| Enter / Space | Selects |
| Letters | The next row whose label starts with them |
Accessibility
- A tree grid (name it): rows with their level, their place among their siblings, open or not, selected or not; a row header names each span; one Tab stop.
- A bar is a cell read as its times; the axis and the marks are hidden from screen readers. The indicator is for the pointer: the arrows open and close.
Examples
Nested spans
None · 0 open
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScWaterfall, ScWaterfallAxis, ScWaterfallBar, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator, type ScWaterfallItem,Zoom
import { Component, ViewEncapsulation, signal } from '@angular/core';import { ScButton, ScWaterfall, ScWaterfallAxis, ScWaterfallBar, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator, type ScWaterfallItem,Large trace
import { Component, ViewEncapsulation } from '@angular/core';import { ScWaterfall, ScWaterfallAxis, ScWaterfallBar, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator, type ScWaterfallItem, ScWaterfallRow,RTL
import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import { ScWaterfall, ScWaterfallAxis, ScWaterfallBar, ScWaterfallColumnHeader, ScWaterfallHeaderRow, ScWaterfallIndicator, type ScWaterfallItem,API reference
Each part takes class, merged over its own (cn: a later class wins). The rows and cells are the style's table; the bar's corners its waterfall.
| Part | Selector | Description |
|---|---|---|
ScWaterfall | div[scWaterfall] | The tree grid: items, range, [(value)], [(expanded)], format, barLabel. exportAs scWaterfall: rows(), toggle(), expandAll(), collapseAll(), reveal(), focus(). |
ScWaterfallHeaderRow / ColumnHeader | div[scWaterfallHeaderRow], [scWaterfallColumnHeader] | The column names; the timeline’s holds the axis. |
ScWaterfallAxis | [scWaterfallAxis] | Round times (maxTicks) — or your ticks; holds the marks. |
ScWaterfallTick | [scWaterfallTick] | A time on the axis: [time]. |
ScWaterfallMark | [scWaterfallMark] | A moment across the rows: [time], your text; data-outside. |
ScWaterfallRow | div[scWaterfallRow] | A span: [row], one of rows(). data-level, data-branch, data-expanded, data-selected. |
ScWaterfallRowHeader | [scWaterfallRowHeader] | Names the span, indented by its level. |
ScWaterfallIndicator | button[scWaterfallIndicator] | Opens and closes (the pointer’s): your chevron, turned when open. |
ScWaterfallCell | [scWaterfallCell] | Another column: a status, a size. |
ScWaterfallBar | [scWaterfallBar] | The span on the axis, read as its times. |
| Input | Type | Default | Description |
|---|---|---|---|
items | ScWaterfallItem[] | — | The spans: { value, label, start, duration, children? }. |
range | [number, number] | null | null | The time shown (ms); by default, all of it. |
value | string | null | null | The selected span: two-way. |
expanded | string[] | [] | The spans open: two-way. |
format | Intl.NumberFormatOptions | (ms) => string | milliseconds | How times are written. |
barLabel | (item, { start, duration, range }) => string | its range | A bar’s label for screen readers. |