Menu

Engine API

Shared data, behavior and controller APIs. The installed preset fills the visual slots; pass only the widgets you want to replace.

Start with Widget Structure to understand composition and customization. Use this reference for exact props, builder arguments and controller members.

Props

PropTypeDescription
dataFlowDiagramDataThe graph: { nodes, edges }.
customFlowDiagramCustom<TConfig>Builder for every visual part. FlowDiagram fills all of them; pass only the ones you replace.
config?TConfigYour theme object. Builders read it as context.config.
nodeOptions?Record<string, NodeOptions>Per-type interaction metadata: handles, editability, groups and zoom breakpoints. Render through custom.node.
getHandles?GetHandlesFn<TConfig>Declare connection points. Inline handles are placed as widgets and measured by the engine.
getEdgePath?GetEdgePathFn<TConfig>Compute edge geometry used for drawing and hit testing.
getContextMenuItems?GetContextMenuItemsFn<TConfig>Return application commands. The engine wires their gestures before calling custom.menuItem.
getControlsOptions?GetControlsOptionsFn<TConfig>Control action timings; the installed preset derives them from config.controls.
getMinimapOptions?GetMinimapOptionsFn<TConfig>Minimap geometry and panning; the installed preset derives them from config.minimap.
highlightConnected?booleanRebuild visual slots on graph-wide hover and selection changes for dimming unrelated elements.
layout?LayoutAlgorithm | LayoutConfigAn algorithm, or { algorithm, options, runOn, fitView }.
viewport?{ initial?: Viewport; fitView?: boolean | FitViewOptions; minZoom?: number; maxZoom?: number; extent?: CoordinateExtent }Initial viewport, fit on mount, zoom limits and pan extent.
interaction?| InteractionPreset | (DeepPartial<FlowInteraction> & { preset?: InteractionPreset })A preset name, or groups merged over a preset. See Interaction below.
can?(gesture: Gesture, target: GestureTarget) => booleanOne permission check per gesture and target. Wins over per-item flags.
on?FlowEventsEvent callbacks. before* hooks return false to veto or a value to patch.
controller?FlowDiagramControllerYour own FlowDiagramController, to drive the graph from outside.
key?unknownWidget key.
Events: on
EventTypeDescription
nodesChange?(changes: NodeChange<FlowNode>[]) => voidEvery node change, after it is applied.
edgesChange?(changes: EdgeChange<FlowEdge>[]) => voidEvery edge change, after it is applied.
connect?(connection: Connection) => voidA new connection was made.
nodeClick?(event: MouseEvent, node: FlowNode) => voidA node was clicked.
nodeDoubleClick?(event: MouseEvent, node: FlowNode) => voidA node was double-clicked.
dragStart?(event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => voidA node drag started. nodes holds every node that moves.
drag?(event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => voidEach frame of a node drag.
dragEnd?(event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => voidA node drag ended.
edgeClick?(event: MouseEvent, edge: FlowEdge) => voidAn edge was clicked.
edgeDoubleClick?(event: MouseEvent, edge: FlowEdge) => voidAn edge was double-clicked.
paneClick?(event: MouseEvent) => voidThe empty pane was clicked.
paneDoubleClick?(event: MouseEvent) => voidThe empty pane was double-clicked.
selectionChange?(selection: { nodes: FlowNode[]; edges: FlowEdge[] }) => voidThe selected nodes or edges changed.
delete?(deleted: { nodes: FlowNode[]; edges: FlowEdge[] }) => voidNodes and edges were deleted.
beforeDelete?(deleted: { nodes: FlowNode[]; edges: FlowEdge[] }) => | boolean | { nodes: FlowNode[]; edges: FlowEdge[] } | Promise<boolean | { nodes: FlowNode[]; edges: FlowEdge[] }>Return false to keep everything, or the subset to delete.
reconnect?(oldEdge: FlowEdge, newConnection: Connection) => voidAn edge end moved to another handle.
resizeStart?(event: MouseEvent, node: FlowNode) => voidA resize started.
resize?(event: MouseEvent, node: FlowNode, params: ResizeParams) => voidEach frame of a resize.
resizeEnd?(event: MouseEvent, node: FlowNode, params: ResizeParams) => voidA resize ended.
init?(controller: FlowDiagramController) => voidThe controller is ready.
error?(code: "layout", message: string) => voidSomething failed, such as a layout.
viewportChange?(change: { phase: "start" | "move" | "end"; viewport: Viewport }) => voidPan or zoom, with phase start, move or end.
connectStart?(state: ConnectionState) => voidA connection drag started.
connectEnd?(result: { state: ConnectionState; dropPosition: XYPosition }) => voidA connection drag ended. dropPosition is in flow coordinates.
beforeConnect?(connection: Connection) => false | Connection | voidReturn false to refuse, or a patched connection.
reshapeStart?(args: EdgeHandleCustomArgs) => voidA waypoint drag started.
reshape?(args: EdgeHandleCustomArgs) => voidEach frame of a waypoint drag.
reshapeEnd?(args: EdgeHandleCustomArgs) => voidA waypoint drag ended.
editStart?(args: { node: FlowNode }) => voidInline text editing started.
editEnd?(args: { node: FlowNode; committed: boolean }) => voidInline text editing ended. committed is false after Esc.
historyChange?(state: { canUndo: boolean; canRedo: boolean }) => voidcanUndo or canRedo changed.
contextMenu?(args: ContextMenuCustomArgs) => voidA context menu opened.
can: (gesture: "pan" | "zoom" | "select" | "drag" | "connect" | "reconnect" | "resize" | "reshape" | "edit" | "delete" | "copy" | "contextMenu",
     target: { kind: "node" | "edge" | "pane" | "selection"; id?: string }) => boolean

Interaction

Values per preset. Mod is ⌘ on macOS and Ctrl elsewhere.

interaction: "viewer"                                   // a preset
interaction: { preset: "whiteboard", drag: { overlap: "push" } } // preset + overrides
interaction: { keys: { duplicate: null } }               // editor + one change
pane
PropertyTypeeditorviewerwhiteboardDescription
drag"pan" | "select""pan""pan""select"What dragging the empty pane does.
scroll"zoom" | "pan""zoom""zoom""zoom"What the wheel does without a modifier.
scrollSpeednumber0.50.50.5Pan speed when the wheel pans.
pinchbooleantruetruetruePinch and trackpad zoom.
doubleClick"zoom" | "none""zoom""zoom""zoom"Double-click on the pane zooms in, or does nothing.
autoPanboolean | { speed: number }{ speed: 15 }{ speed: 15 }{ speed: 15 }Pan while dragging near the border. Speed in px per frame.
panKeyKeyCode"Space""Space""Space"Hold to pan with a drag when drag selects.
selectKeyKeyCode"Shift""Shift""Shift"Hold to box-select with a drag when drag pans.
select
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruetruetrueClick selection of nodes and edges.
boxbooleantruefalsetrueDrag a selection box: with selectKey held, or plainly when pane.drag is select. false frees both.
modeSelectionMode"full""full""full"full: the box must contain a node. partial: touching is enough.
toggleKeyKeyCode"Mod""Mod""Mod"Hold to add or remove from the selection.
elevatebooleantruetruetrueRaise selected and dragged nodes above the rest.
edgeHitWidthnumber202020Invisible stroke width that hits edges, in px.
drag
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruefalsetrueNode dragging.
thresholdnumber111Pixels a press moves before it becomes a drag.
snap.gridfalse | [number, number]falsefalsefalseSnap positions to this grid, or false.
snap.guidesbooleanfalsefalsetrueSnap to other nodes and draw alignment guides.
snap.radiusnumber555Distance in px at which guides snap.
overlap"allow" | "push" | "reject""allow""allow""allow"On drop: allow keeps overlaps, push moves the dropped nodes clear, reject cancels the drag.
dropIntoGroupbooleantruefalsetrueDropping a node on a group makes it a child. Dropping it outside detaches it.
connect
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruefalsetrueDragging from a handle creates an edge.
modeConnectionMode"strict""strict""strict"strict: source to target only. loose: any handle to any handle.
radiusnumber202020Snap distance to a handle, in px.
onClickbooleantruefalsetrueClick one handle, then another, to connect.
reconnectbooleantruefalsetrueDrag an edge end onto another handle.
reconnectRadiusnumber101010Grab radius at edge ends, in px.
lineTypestring"default""default""default"Path type of the line while connecting.
validate(connection: Connection) => boolean———Return false to refuse a connection.
edit
PropertyTypeeditorviewerwhiteboardDescription
textbooleanfalsefalsetrueDouble-click a node to edit its label.
waypointsbooleanfalsefalsefalseOn a selected edge, drag a midpoint grip to add a bend. Double-click a bend to remove it.
resizeboolean | NodeResizeOptionsfalsefalsetrueResize controls on selected nodes. Options set size limits.
history
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruefalsetrueUndo and redo, one step per gesture.
limitnumber100100100Undo steps kept.
clipboard
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruefalsetrueCopy, paste and duplicate.
offsetXYPosition{ x: 20, y: 20 }{ x: 20, y: 20 }{ x: 20, y: 20 }Shift applied to each duplicated copy.
systembooleanfalsefalsefalseAlso write to the system clipboard.
contextMenu
PropertyTypeeditorviewerwhiteboardDescription
enabledbooleantruefalsetrueRight-click and long-press open custom.contextMenu.
longPressnumber500500500Touch hold time in ms.
keys
PropertyTypeeditorviewerwhiteboardDescription
deleteKeyCode["Backspace", "Delete"]null["Backspace", "Delete"]Delete the selection.
undoKeyCode"Mod+z"null"Mod+z"Undo.
redoKeyCode["Mod+Shift+z", "Mod+y"]null["Mod+Shift+z", "Mod+y"]Redo.
copyKeyCode"Mod+c"null"Mod+c"Copy the selection.
pasteKeyCode"Mod+v"null"Mod+v"Paste at the pointer.
duplicateKeyCode"Mod+d"null"Mod+d"Duplicate the selection.
selectAllKeyCode"Mod+a"null"Mod+a"Select every node.
fitViewKeyCode"Shift+1""Shift+1""Shift+1"Fit the graph in view.
zoomInKeyCode["+", "="]["+", "="]["+", "="]Zoom in.
zoomOutKeyCode"-""-""-"Zoom out.
nudgeKeyCode["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"]null["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"]Move the selection by 1 px, or 10 px with Shift.
escapeKeyCode"Escape""Escape""Escape"Clear the selection, or cancel a connection or edit.
general
PropertyTypeeditorviewerwhiteboardDescription
touchbooleantruetruetrueTouch input: drag, two-finger pan and pinch, long-press.

Custom parts

SlotSignatureDescription
layout(args: LayoutCustomArgs, context) => WidgetArranges the viewport and screen-space overlays; override it to add extra UI.
viewport(args: ViewportCustomArgs, context) => WidgetArranges cached nodes and edges in paint order, then flow-space overlays.
nodeBox(args: NodeBoxCustomArgs, context) => WidgetPlaces the pre-built node, connection handles, resize controls and toolbar.
edgeBox(args: EdgeBoxCustomArgs, context) => WidgetArranges the pre-built edge, label and editing handles.
controls(args: ControlsCustomArgs, context) => WidgetArranges zoom, fit and lock child widgets with their actions already attached.
controlButton(args: ControlButtonCustomArgs, context) => WidgetOne control button's appearance. Click and hover behavior are attached by the engine.
minimap(args: MinimapCustomArgs, context) => WidgetArranges background, node, mask and viewport widgets; the engine owns panning.
minimapNode(args: MinimapNodeCustomArgs, context) => WidgetOne node in minimap coordinates.
minimapBackground(args: MinimapBackgroundCustomArgs, context) => WidgetMinimap background widget.
minimapMask(args: MinimapMaskCustomArgs, context) => WidgetMask around the visible portion of the minimap.
minimapViewport(args: MinimapViewportCustomArgs, context) => WidgetCurrent viewport outline in minimap coordinates.
contextMenu(target: ContextMenuCustomArgs & { items: Widget[] }, context) => WidgetMenu for a right-click or long-press. Return SizedBox.shrink() for no menu.
menuItem(args: MenuItemCustomArgs, context) => WidgetOne menu item's appearance. Selection, disabled state and menu dismissal are wired by the engine.
guides(args: GuidesCustomArgs, context) => WidgetAlignment guide lines while snapping.
edgeHandle(args: EdgeHandleCustomArgs, context) => WidgetWaypoint pins and midpoint grips on an editable edge.
node(args: NodeBodyCustomArgs, context) => WidgetNode body. Receives a built label and inline handle widgets; the engine attaches node gestures.
nodeLabel(args: NodeCustomArgs, context) => WidgetNode label widget, including the preset's editable text.
nodeToolbar(args: NodeToolbarCustomArgs, context) => WidgetScreen-space toolbar for a selected node.
edge(args: EdgeCustomArgs, context) => WidgetEdge visual. The engine retains hit testing, selection and hover.
edgeLabel(args: EdgeLabelCustomArgs, context) => WidgetLabel drawn at the edge's label point.
handle(args: HandleCustomArgs, context) => WidgetA connection handle.
connectionLine(args: ConnectionLineCustomArgs, context) => WidgetThe line drawn while connecting.
background(args: BackgroundCustomArgs, context) => WidgetPane backdrop. Return SizedBox.shrink() for none.
selectionBox(args: SelectionBoxCustomArgs, context) => WidgetThe rectangle drawn while box-selecting.
nodesSelectionRect(args: NodesSelectionRectCustomArgs, context) => WidgetBounds drawn around a multi-selection.
resizeControl(args: ResizeControlCustomArgs, context) => WidgetResize lines and corner handles.
reconnectHandle(args: ReconnectHandleCustomArgs, context) => WidgetGrab area at an edge end. Invisible by default.
Builder args
SlotArgTypeDescription
layoutbackgroundWidget
viewportWidgetCurrent x, y and zoom.
selectionBoxWidget
toolbarsWidget
controlsWidget
minimapWidget
contextMenuWidget
viewportedgesWidget[]
nodesWidget[]
connectionLineWidget
nodesSelectionRectWidget
guidesWidget
itemsWidget[]Interleaved nodes/edges in controller paint order, preserving group-edge elevation.
nodeBoxnodeWidgetThe node.
handlesWidget[]
resizeControlsWidget[]
toolbarWidgetThe pre-built screen-space toolbar, also supplied to layout.toolbars for unscaled placement.
argsNodeCustomArgs
placementsNodeAttachmentPlacement[]Placement rules measured against the node body's laid-out size.
edgeBoxedgeWidgetThe edge.
labelWidgetedge.label.
reconnectHandlesWidget[]
edgeHandlesWidget[]
argsEdgeCustomArgs
controlszoomInWidget
zoomOutWidget
fitViewWidget
interactiveWidget
controlButtonkindControlKindwaypoint for a bend, midpoint for an insert grip.
isHoveredbooleanUnder the pointer.
isDisabledboolean
isInteractiveboolean
minimapwidthnumberPane width.
heightnumberPane height.
backgroundWidget
nodesWidget[]
maskWidget
viewportWidgetCurrent x, y and zoom.
minimapNodenodeFlowNodeThe node.
rectRect
isSelectedbooleanSelected now.
minimapBackgroundwidthnumberPane width.
heightnumberPane height.
minimapMaskwidthnumberPane width.
heightnumberPane height.
rectRect
minimapViewportrectRect
contextMenutargetGestureTarget["kind"]What was clicked: node, edge, pane or selection.
idsstring[]Ids the menu acts on.
positionXYPositionPointer in flow coordinates.
screenPositionXYPositionPointer in pane pixels.
itemsWidget[]
menuItemlabelstringedge.label.
indexnumberWaypoint or segment index.
isHoveredbooleanUnder the pointer.
isDisabledboolean
isSeparatorboolean
guideslinesGuide[]Overlay-local coordinates; controller.guides uses flow coordinates.
edgeHandleedgeFlowEdgeThe edge.
kind"waypoint" | "midpoint"waypoint for a bend, midpoint for an insert grip.
indexnumberWaypoint or segment index.
isActivebooleanBeing dragged.
nodenodeFlowNodeThe node.
isSelectedbooleanSelected now.
isDraggingbooleanBeing dragged.
isHoveredbooleanUnder the pointer.
isDraggablebooleanDrag is allowed.
isSelectablebooleanSelection is allowed.
isConnectablebooleanConnecting is allowed.
positionAbsoluteXYPositionTop-left in flow coordinates, after parents.
zIndexnumberPaint order.
isConnectionTargetbooleanA connection is being dragged over this node (any of its handles is the candidate).
isResizablebooleanResize controls apply.
isResizingbooleanA resize is in progress.
isEditingbooleanInline text editing is active.
isDropTargetbooleanA dragged node would drop into this group.
isOverlappingbooleanOverlaps another node.
isCollapsedbooleannode.collapsed. The nodes it hides are not drawn.
hiddenChildCountnumberHow many nodes this collapse hides right now.
isNeighbourbooleanConnected to the hovered or selected node.
labelWidgetedge.label.
handles{ id: string | null; type: HandleType; handle: Widget }[]Interaction-ready inline handles. Place each handle once in the node's widget tree.
nodeLabelnodeFlowNodeThe node.
isSelectedbooleanSelected now.
isDraggingbooleanBeing dragged.
isHoveredbooleanUnder the pointer.
isDraggablebooleanDrag is allowed.
isSelectablebooleanSelection is allowed.
isConnectablebooleanConnecting is allowed.
positionAbsoluteXYPositionTop-left in flow coordinates, after parents.
zIndexnumberPaint order.
isConnectionTargetbooleanA connection is being dragged over this node (any of its handles is the candidate).
isResizablebooleanResize controls apply.
isResizingbooleanA resize is in progress.
isEditingbooleanInline text editing is active.
isDropTargetbooleanA dragged node would drop into this group.
isOverlappingbooleanOverlaps another node.
isCollapsedbooleannode.collapsed. The nodes it hides are not drawn.
hiddenChildCountnumberHow many nodes this collapse hides right now.
isNeighbourbooleanConnected to the hovered or selected node.
nodeToolbarnodeFlowNodeThe node.
isSelectedbooleanSelected now.
edgeedgeFlowEdgeThe edge.
pathEdgePathResultGeometry in the edge widget's local coordinates (top-left is `origin`).
originXYPositionTop-left of the edge widget in flow coordinates.
sizeDimensionsSize of the widget.
endpointsEdgeEndpointsResolved source and target points and sides.
isSelectedbooleanSelected now.
isHoveredbooleanUnder the pointer.
isAnimatedbooleanedge.animated, resolved.
sourceNodeFlowNodeNode at the source end.
targetNodeFlowNodeNode at the target end.
markerStartEdgeMarker | nullResolved start marker.
markerEndEdgeMarker | nullResolved end marker.
interactionWidthnumberHit stroke width.
isReconnectingbooleanOne endpoint of this edge is being dragged to a new handle.
waypointsXYPosition[]Bend points in flow coordinates.
activeHandle{ kind: "waypoint" | "midpoint"; index: number } | nullThe waypoint or midpoint being dragged.
isNeighbourbooleanConnected to the hovered or selected node.
edgeLabeledgeFlowEdgeThe edge.
labelstringedge.label.
isSelectedbooleanSelected now.
isHoveredbooleanUnder the pointer.
xnumberLabel anchor in flow coordinates.
ynumberLabel anchor y in flow coordinates.
handlenodeFlowNodeThe node.
handleResolvedHandleResolved handle with absolute centre.
isConnectablebooleanConnecting is allowed.
isConnectingbooleanThis handle started the connection in progress.
isConnectionCandidatebooleanThis handle is the snapped candidate of the connection in progress.
isValidCandidateboolean | nulltrue valid, false refused, null not snapped.
isConnectionInProgressbooleanAny connection is being dragged.
connectionLineconnectionConnectionStateFull connection state.
pathEdgePathResultPath in local coordinates of the connection line widget.
fromXYPositionStart point.
toXYPositionEnd point: a snapped handle or the pointer.
fromPositionPositionSide the line leaves from.
toPositionPositionSide the line arrives at.
isValidboolean | nulltrue valid, false refused, null not snapped.
originXYPositionTop-left of the widget in flow coordinates.
sizeDimensionsSize of the widget.
backgroundviewportViewportCurrent x, y and zoom.
widthnumberPane width.
heightnumberPane height.
selectionBoxrectRectRectangle in pane pixels.
nodesSelectionRectrectRectBounds of the selected nodes in flow coordinates.
nodesFlowNode[]The selected nodes.
resizeControlnodeFlowNodeThe node.
positionResizeControlPositionWhich corner or side.
variant"line" | "handle"line for a side, handle for a corner.
isResizingbooleanA resize is in progress.
reconnectHandleedgeFlowEdgeThe edge.
endHandleTypesource or target.
sizenumberDiameter of the grab area in flow pixels.

Controller

Builders get it as context. P2 marks methods still being built.

Graph
MemberSignatureDescription
nodesnodes: FlowNode[]Current nodes.
edgesedges: FlowEdge[]Current edges.
getNodegetNode(id: string): FlowNode | undefinedOne node by id.
getEdgegetEdge(id: string): FlowEdge | undefinedOne edge by id.
setNodessetNodes(nodes: FlowNode[] | ((nodes: FlowNode[]) => FlowNode[])): voidReplace all nodes, or map them.
setEdgessetEdges(edges: FlowEdge[] | ((edges: FlowEdge[]) => FlowEdge[])): voidReplace all edges, or map them.
addNodesaddNodes(nodes: FlowNode | FlowNode[]): voidAdd one or more nodes.
addEdgesaddEdges(edges: (Partial<FlowEdge> & Connection) | FlowEdge | (Partial<FlowEdge> & Connection)[] | FlowEdge[]): voidAdd one or more edges.
updateNodeupdateNode(id: string, update: Partial<FlowNode> | ((node: FlowNode) => Partial<FlowNode>), options?: { replace?: boolean }): voidPatch a node. Rebuilds only that node.
updateNodeDataupdateNodeData(id: string, data: Record<string, unknown> | ((node: FlowNode) => Record<string, unknown>), options?: { replace?: boolean }): voidMerge into node.data, or replace it.
updateEdgeupdateEdge(id: string, update: Partial<FlowEdge> | ((edge: FlowEdge) => Partial<FlowEdge>), options?: { replace?: boolean }): voidPatch an edge.
updateEdgeDataupdateEdgeData(id: string, data: Record<string, unknown> | ((edge: FlowEdge) => Record<string, unknown>), options?: { replace?: boolean }): voidMerge into edge.data, or replace it.
deleteElementsdeleteElements(elements: { nodes?: (FlowNode | { id: string })[]; edges?: (FlowEdge | { id: string })[] } | string[], options?: { reconnect?: boolean }): Promise<{ deletedNodes: FlowNode[]; deletedEdges: FlowEdge[] }>Delete with cascade. reconnect: true links the neighbours. Runs on.beforeDelete.
reconnectEdgereconnectEdge(oldEdge: FlowEdge, connection: Connection, options?: { shouldReplaceId?: boolean }): voidMove an edge to a new connection.
getIncomersgetIncomers(node: FlowNode | { id: string }): FlowNode[]Nodes with an edge into this one.
getOutgoersgetOutgoers(node: FlowNode | { id: string }): FlowNode[]Nodes this one has an edge to.
getConnectedEdgesgetConnectedEdges(nodes: (FlowNode | { id: string })[]): FlowEdge[]Edges touching any of these nodes.
getNeighboursgetNeighbours(id: string): { nodes: FlowNode[]; edges: FlowEdge[] }Nodes one edge away.
toObjecttoObject(): { nodes: FlowNode[]; edges: FlowEdge[]; viewport: Viewport }Nodes, edges and viewport, for saving.
insertNodeOnEdgeinsertNodeOnEdge(edgeId: string, node: FlowNode): voidSplit an edge with a new node.
setParentsetParent(id: string, parentId: string | null): voidMove a node into a group, or out with null.
Selection
MemberSignatureDescription
getSelectedNodesgetSelectedNodes(): FlowNode[]Selected nodes.
getSelectedEdgesgetSelectedEdges(): FlowEdge[]Selected edges.
selectNodesselectNodes(ids: string[], options?: { additive?: boolean }): voidSelect nodes by id. additive keeps the rest.
selectEdgesselectEdges(ids: string[], options?: { additive?: boolean }): voidSelect edges by id.
clearSelectionclearSelection(): voidDeselect everything.
selectAllselectAll(): voidSelect every selectable node.
bringToFrontbringToFront(ids?: string[]): voidRaise nodes above the rest.
Viewport
MemberSignatureDescription
viewportviewport: ViewportCurrent x, y and zoom.
zoomzoom: numberCurrent zoom.
setViewportsetViewport(viewport: Partial<Viewport>, options?: { duration?: number }): Promise<void>Jump or animate to a viewport.
panBypanBy(delta: XYPosition): booleanPan by a pixel delta.
zoomInzoomIn(options?: { duration?: number }): Promise<void>Zoom in one step.
zoomOutzoomOut(options?: { duration?: number }): Promise<void>Zoom out one step.
zoomTozoomTo(zoom: number, options?: { duration?: number }): Promise<void>Zoom to a level around the centre.
zoomAtzoomAt(point: XYPosition, ratio: number, options?: { duration?: number }): Promise<void>Zoom by a ratio around a point.
fitViewfitView(options?: FitViewOptions): Promise<boolean>Fit all or some nodes in view.
fitBoundsfitBounds(bounds: Rect, options?: { padding?: number; duration?: number; minZoom?: number; maxZoom?: number }): Promise<void>Fit a rectangle in view.
setCentersetCenter(x: number, y: number, options?: { zoom?: number; duration?: number }): Promise<void>Centre a flow point.
Geometry
MemberSignatureDescription
screenToFlowPositionscreenToFlowPosition(point: XYPosition, options?: { snapToGrid?: boolean }): XYPositionBrowser point to flow coordinates.
flowToScreenPositionflowToScreenPosition(point: XYPosition): XYPositionFlow point to browser coordinates.
pointerFlowPositionpointerFlowPosition: XYPositionLast pointer position in flow coordinates.
getNodePositionAbsolutegetNodePositionAbsolute(node: FlowNode): XYPositionTop-left after parent offsets.
getNodeRectgetNodeRect(nodeOrId: FlowNode | string): Rect | nullAbsolute rectangle of a measured node.
getNodesBoundsgetNodesBounds(nodes?: (FlowNode | { id: string } | string)[]): RectBounds of some or all nodes.
getIntersectingNodesgetIntersectingNodes(target: FlowNode | { id: string } | Rect, partially?, nodes?: FlowNode[]): FlowNode[]Nodes that overlap a node or rectangle.
getNodeHandlesgetNodeHandles(nodeOrId: FlowNode | string): ResolvedHandle[]Resolved handles with absolute centres.
getEdgeEndpointsgetEdgeEndpoints(edge: FlowEdge): EdgeEndpoints | nullResolved endpoints and sides of an edge.
getVisibleNodesgetVisibleNodes(): FlowNode[]Nodes that are not hidden, in paint order.
History and clipboard
MemberSignatureDescription
historyhistoryundo, redo, canUndo, canRedo, mark, clear.
runrun(fn: () => T, options: { history: "ignore" | "merge" }): TBatch changes as one undo step, or keep them out of history.
getContentgetContent(ids?: string[]): FlowContentNodes and inner edges for copying.
putContentputContent(content: FlowContent, options?: { at?: XYPosition; offset?: XYPosition; select?: boolean }): FlowContentInsert copied content with fresh ids.
duplicateduplicate(ids?: string[]): FlowContentCopy and paste in one step.
copycopy(): Promise<void>Copy the selection.
pastepaste(): Promise<FlowContent>Paste at the pointer.
Context menu
MemberSignatureDescription
contextMenucontextMenu: ContextMenuCustomArgs | nullOpen menu args, or null.
openContextMenuopenContextMenu(target: GestureTarget, position: XYPosition): booleanOpen the menu for a target.
closeContextMenucloseContextMenu(): voidClose the menu.
Editing
MemberSignatureDescription
editingIdeditingId: string | nullNode in inline text edit, or null.
startEditingstartEditing(id: string): voidStart inline text edit on a node.
stopEditingstopEditing(options?: { commit?: boolean }): voidEnd the edit; commit or cancel.
insertWaypointinsertWaypoint(edgeId: string, index: number, point: XYPosition): voidAdd a bend to an edge.
moveWaypointmoveWaypoint(edgeId: string, index: number, point: XYPosition): voidMove a bend.
removeWaypointremoveWaypoint(edgeId: string, index: number): voidRemove a bend.
guidesguides: Guide[]Alignment guides of the current drag.
resolveOverlapsresolveOverlaps(ids?: string[], options?: { margin?: number; overlapThreshold?: number }): voidMove the given nodes, or the selection, clear of the nodes they overlap.
collapsecollapse(id: string): voidHide downstream nodes no other visible node reaches. Without outgoing edges, hide child nodes.
expandexpand(id: string): voidShow it again.
toggleCollapsedtoggleCollapsed(id: string): voidCollapse or expand.
hiddenChildCounthiddenChildCount(id: string): numberHow many nodes a collapsed node hides.
isNodeHiddenisNodeHidden(node: FlowNode): booleanHidden by node.hidden or by a collapse.
nudgenudge(direction: "left" | "right" | "up" | "down", multiplier?, merge?): voidMove the selection by multiplier flow pixels in a direction.
alignNodesalignNodes(ids: string[], mode: "left" | "centerX" | "right" | "top" | "centerY" | "bottom"): voidAlign nodes to one side or centre.
distributeNodesdistributeNodes(ids: string[], axis: "x" | "y"): voidSpace nodes evenly.
Layout
MemberSignatureDescription
layoutlayout(algorithm?: LayoutAlgorithm, options?: LayoutOptions & { fitView?: boolean }): Promise<void>Run the layout prop, or another algorithm, now.
State
MemberSignatureDescription
interactioninteraction: Readonly<FlowInteraction>Resolved interaction config.
setInteractionsetInteraction(partial: DeepPartial<FlowInteraction>): voidMerge a partial interaction config at runtime.
cancan(gesture: Gesture, target: GestureTarget, fallback?): booleanAsk whether a gesture is allowed on a target.
hoveredNodeIdhoveredNodeId: string | nullNode under the pointer.
hoveredEdgeIdhoveredEdgeId: string | nullEdge under the pointer.
connectionconnection: ConnectionState | nullConnection being dragged, or null.
isDraggingNodesisDraggingNodes: booleanA node drag is active.
setInteractivesetInteractive(interactive: boolean): voidLock or unlock editing, like the lock button in the controls.
cancelConnectioncancelConnection(): voidAbort the connection in progress.
disposedispose(): voidRelease listeners. Call it from your State's dispose.

Types

FlowNode
FieldTypeDescription
idstringUnique id.
positionXYPositionTop-left in flow coordinates (relative to the parent when `parentId` is set).
dataTDataYour data. Builders read it.
type?stringApplication-defined type. Select visual builders inside custom.node or custom.edge.
width?numberFixed size; when omitted the node is measured after layout.
height?numberFixed height; measured when omitted.
measured?DimensionsWritten by the engine after measurement.
selected?booleanSelected.
dragging?booleanWritten while dragging.
draggable?booleanPer-node drag permission.
selectable?booleanPer-item selection permission.
connectable?booleanPer-node connect permission.
deletable?booleanPer-item delete permission.
hidden?booleanNot drawn or hit tested.
parentId?stringParent group. position is then relative to it.
collapsible?booleanMarks a node that can collapse. The default context menu then offers Collapse and Expand.
collapsed?booleanHides downstream nodes no other visible node reaches. Without outgoing edges, hides its child nodes.
extent?CoordinateExtent | "parent"Drag bounds, or parent to stay inside the parent.
zIndex?numberPaint order.
sourcePosition?PositionFallback edge anchor sides when the node has no handles.
targetPosition?PositionFallback target side when there are no handles.
handles?HandleSpec[]Overrides the node type's handles.
resizable?booleanShows resize controls while selected. interaction.edit.resize sets the default.
resizeOptions?NodeResizeOptionsSize limits and visible controls for this node.
resizing?booleanWritten by the engine while a resize gesture is active.
toolbar?NodeToolbarOptionsPlacement of the node type's toolbar.
FlowEdge
FieldTypeDescription
idstringUnique id.
sourcestringSource node id.
targetstringTarget node id.
sourceHandle?string | nullSource handle id, or null for the default.
targetHandle?string | nullTarget handle id, or null for the default.
type?stringApplication-defined type. Select visual builders inside custom.node or custom.edge.
data?TDataYour data. Builders read it.
label?stringText for custom.edgeLabel.
selected?booleanSelected.
animated?booleanAnimated dash.
hidden?booleanNot drawn or hit tested.
deletable?booleanPer-item delete permission.
selectable?booleanPer-item selection permission.
reconnectable?boolean | "source" | "target"Which ends may be dragged to another handle.
markerStart?EdgeMarker | MarkerShapeMarker at the source end.
markerEnd?EdgeMarker | MarkerShapeMarker at the target end.
zIndex?numberPaint order.
style?EdgeStyleStroke colour and width.
waypoints?XYPosition[]Bend points in flow coordinates.
adjusting?"none" | "ends" | "stretch"How bends follow moved ends: ends shifts the nearest bends, stretch scales all, none keeps them.
pathOptions?{ curvature?: number; offset?: number; borderRadius?: number }Curvature, offset and corner radius for the built-in path types.