Create

General

Flow

Experimental
Copy page View as Markdown Open in ChatGPT Open in Claude

A canvas of nodes connected by edges for flow charts, metric trees and pipelines, built on the core of React Flow.

Usage#

app.component.ts
import { WdsFlowComponent } from '@wds/angular/flow';

Examples#

Default#

A lead routing workflow. nodes and edges are properties (in HTML set them from a script); each step is your own card in the slot named after its node id, and positions are placed by hand. Drag the pane to move it, scroll to zoom, drag a step to move it and drag from a handle to another step to connect them; click selects and Delete removes the selection. type: 'step' draws right-angled edges, label names a branch (Yes / No) and animated moves dashes along the path that ran. The controls call zoomIn(), zoomOut() and fitView(), and the lock sets readonly. The flow needs the @xyflow/system package: pnpm add @xyflow/system.

WorkflowsLead Routing5 steps, 4 connections · 2h ago
Add step Update
Form submitted
Webhook: demo.request
OM0.2s Success
Plan is Enterprise
company.size > 200
OM0.1s Success
Enrich company
Clearbit lookup
JL8.0s Failed
Create deal
HubSpot pipeline: Inbound
JLNot run Idle
Notify sales
Slack #inbound-leads
INNot run Skipped
100%

Growth map#

A metric map built from WDS components: each node is your own card in the slot named after its id, dagre (@dagrejs/dagre) lays the columns out from left to right, and edge labels show the correlation. The toolbar switches between mode="pan" and mode="select" (selection box) and calls zoomIn(), zoomOut() and fitView(); wds-viewport-change updates the zoom level. A click on a card opens the inspector; isValidConnection refuses loops and duplicate links. A right click opens a wds-context-menu around the flow: wds-node-context-menu, wds-edge-context-menu and wds-pane-context-menu say what was clicked (with the pointer in flow coordinates) before the menu opens, so it shows node, link or canvas actions.

MapsRepeat Order Growth7 days6 weeks12 months Add metric Auto layoutFit viewReset map
Free first returns
Initiative
62%In Progress
GitHub Project · 3 open
SMS restock alerts
Initiative
40%To Do
Growth Team · 5 open
Loyalty upgrade email
Initiative
0%Blocked
Lifecycle Team · 4 open
Checkout completion
Input
68.4%+1.2%
Past 7 days · Average
Restock alert opt-ins
Input
1,240+3.1%
Past 7 days · Sum
Average discount depth
Input
14.2%−0.8%
Past 7 days · Average58%
Weekly repeat orders
North Star
3,912+0.9%
Past 7 days · Sum
Repeat customer revenue
Output
$184.2K+1.4%
Past 7 days · Sum
90-day retention
Output
41.8%+0.4%
Past 7 days · Average
Add metric here Auto layoutFit view
100%

API References#

wds-flow#

A canvas of nodes connected by edges (flow charts, metric trees, pipelines), built on @xyflow/system, the core of React Flow. Pan with the mouse or by scrolling, zoom with the wheel or a pinch, drag nodes, connect handles and select with a click or a selection box (mode="select"). Node content is your own markup in the slot named after the node id (<div slot="metric-1">); a node without slotted content shows data.label. The flow draws the handles on the node edges itself. Moved, connected and deleted elements come out in wds-nodes-change and wds-edges-change; assign the arrays back to nodes and edges to keep them in your state. Requires the @xyflow/system package (an optional dependency of @wds/core, loaded only by @wds/core/flow).

Attributes

AttributeTypeDefaultDescription
mode'pan' | 'select''pan'Dragging the pane: pan moves it, select draws a selection box.
pan-on-scroll.panOnScrollbooleanfalseScrolling moves the pane instead of zooming (zoom with Ctrl + wheel or a pinch).
readonlybooleanfalseNodes cannot be moved, connected or deleted; the pane still pans, zooms and selects.
fit-view-on-init.fitViewOnInitbooleanfalseFits all nodes in view once they have been measured.
fit-view-padding.fitViewPaddingnumber0.1Space around the nodes in fit-view-on-init and fitView(), as a share of the pane.
min-zoom.minZoomnumber0.25Smallest zoom.
max-zoom.maxZoomnumber2Largest zoom.
backgroundWdsFlowBackground'dots'Background pattern.
gapnumber16Distance between background dots or lines, and the snap step.
snap-to-grid.snapToGridbooleanfalseSnaps dragged nodes to the gap grid.
labelstring'Flow'Accessible name of the flow.

Properties

PropertyDescription
nodesWdsFlowNode[]Nodes. Each is drawn at position with the slotted element named after its id as content.
edgesWdsFlowEdge[]Edges between nodes.
isValidConnection(connection: WdsFlowConnection) => boolean | undefinedDecides whether a new connection may be made. By default it refuses a node connected to itself and a second edge between the same handles.

Events

EventDescription
wds-viewport-changeCustomEvent<WdsFlowViewport>The pane was moved or zoomed.
wds-selection-changeCustomEvent<WdsFlowSelectionChangeDetail>Selected nodes or edges changed.
wds-node-clickCustomEvent<WdsFlowNodeClickDetail>Click on a node.
wds-edge-clickCustomEvent<WdsFlowEdgeClickDetail>Click on an edge or its label.
wds-pane-clickCustomEvent<void>Click on the empty pane.
nameCustomEvent
wds-nodes-changeCustomEvent<WdsFlowNodesChangeDetail>Nodes moved (after the drag) or deleted.
wds-edges-changeCustomEvent<WdsFlowEdgesChangeDetail>An edge added by a connection or edges deleted.
wds-connectCustomEvent<WdsFlowConnectDetail>Two handles connected; cancel it to stop the edge from being added.
wds-node-context-menuCustomEvent<WdsFlowNodeContextMenuDetail>Right click (or the context menu key) on a node, fired before the browser or a wds-context-menu around the flow opens its menu.
wds-edge-context-menuCustomEvent<WdsFlowEdgeContextMenuDetail>Right click on an edge or its label.
wds-pane-context-menuCustomEvent<WdsFlowPaneContextMenuDetail>Right click on the empty pane.

Methods

MethodDescription
getViewport()Current pan and zoom.
setViewport(viewport: WdsFlowViewport, options: { duration?: number })Moves and zooms the pane.
setCenter(x: number, y: number, options: { zoom?: number; duration?: number })Centers the pane on a point in flow coordinates.
zoomIn(options: { duration?: number })Zooms in one step.
zoomOut(options: { duration?: number })Zooms out one step.
zoomTo(zoom: number, options: { duration?: number })Sets the zoom, keeping the center of the pane in place.
fitView(options: WdsFlowFitViewOptions)Zooms and pans so that all nodes (or options.nodes) are in view.
screenToFlowPosition(point: WdsFlowXY)Converts a point in viewport coordinates (clientX, clientY) to flow coordinates.
setSelection(nodes: string[], edges: string[])Selects nodes and edges by id (replacing the selection).

Slots

SlotDescription
(default)Node content: elements with slot set to a node id.

CSS parts (::part)

PartDescription
paneThe pane that takes pointer and wheel input.
nodeThe wrapper of every node.
edge-labelAn edge label.

CSS custom properties

PropertyDescription
--wds-flow-heightHeight (default 24rem).
--wds-flow-backgroundBackground of the pane.
--wds-flow-patternColor of the background dots or lines.
--wds-flow-edgeColor of edges.
--wds-flow-edge-selectedColor of a selected edge and of the connection line.
--wds-flow-handleColor of handles.
--wds-flow-node-radiusCorner radius of the selection ring around a node (default --wds-radius-lg).
--wds-flow-successColor of a success edge label.

Accessibility#

Screen reader#

The pane has role="application" and label as its name. Each node is a focusable group named by ariaLabel or data.label (your slotted content is read inside it), and each edge is a focusable group named "Edge from … to …" with its label.

The handles are visual only (aria-hidden); connecting needs a pointer. Offer another way to link nodes, such as the Links tab in the Growth map example.

Built-in texts (the keyboard hint and edge names) are in English for now.

Keyboard support#

KeyFunction
TabMoves focus through the nodes, then the edges.
EnterSpaceSelects the focused node or edge.
ArrowUpArrowDownArrowLeftArrowRightMoves the selected nodes by 5 px (20 px with Shift, one grid step with snap-to-grid).
DeleteBackspaceRemoves the selected nodes (with their edges) and edges.
EscapeClears the selection.
Footer