API Reference

Flow Diagram

The installed preset combines data, config and replaceable widgets. Import it from your copied source.

Data Format

type FlowDiagramData = {
  nodes: { id: string; position: { x: number; y: number }; data: Record<string, unknown>; type?: string }[];
  edges: { id: string; source: string; target: string; sourceHandle?: string; targetHandle?: string }[];
};
Default Style Config

Nested overrides merge with the defaults. The full typed config lives in your installed style/config.ts.

Appearance

PropertyTypeDefaultDescription
colorMode"light" | "dark""light"Preset palette.
colorsPartial<DefaultColors>lightColorsOverride individual color tokens.
nodeobjectwidth: 150, padding: 10, borderRadius: 3Default node sizing, border and text.
edgeobjectstrokeWidth: 1, curvature: 0.25Default stroke, routing and markers.
handleobjectsize: 6, hitPadding: 4Default handle appearance.

Layout and overlays

PropertyTypeDefaultDescription
controlsobjectvisible: true, position: "bottom-left"Visibility, placement and button sizing.
minimapobjectvisible: true, position: "bottom-right"Size, palette and panning.
backgroundobjectvisible: true, variant: "dots", gap: 20Canvas pattern.
contextMenuobjectborderRadius: 8Menu and item styling. Commands use getContextMenuItems.

Custom Parts

Every builder is (args, context) → Widget. Parent slots receive child widgets with behavior already attached. Leaves receive data and derived interaction state.

PartArgsDescription
layoutbackground, viewport, selectionBox, toolbars, controls, minimap, contextMenuArranges the viewport and screen-space overlays; override it to add extra UI.
viewportedges, nodes, connectionLine, nodesSelectionRect, guides, itemsArranges cached nodes and edges in paint order, then flow-space overlays.
nodeBoxnode, handles, resizeControls, toolbar, args, placementsPlaces the pre-built node, connection handles, resize controls and toolbar.
edgeBoxedge, label, reconnectHandles, edgeHandles, argsArranges the pre-built edge, label and editing handles.
controlszoomIn, zoomOut, fitView, interactiveArranges zoom, fit and lock child widgets with their actions already attached.
controlButtonkind, isHovered, isDisabled, isInteractiveOne control button's appearance. Click and hover behavior are attached by the engine.
minimapwidth, height, background, nodes, mask, viewportArranges background, node, mask and viewport widgets; the engine owns panning.
minimapNodenode, rect, isSelectedOne node in minimap coordinates.
minimapBackgroundwidth, heightMinimap background widget.
minimapMaskwidth, height, rectMask around the visible portion of the minimap.
minimapViewportrectCurrent viewport outline in minimap coordinates.
contextMenutarget, ids, position, screenPosition, itemsMenu for a right-click or long-press. Return SizedBox.shrink() for no menu.
menuItemlabel, index, isHovered, isDisabled, isSeparatorOne menu item's appearance. Selection, disabled state and menu dismissal are wired by the engine.
guideslinesAlignment guide lines while snapping.
edgeHandleedge, kind, index, isActiveWaypoint pins and midpoint grips on an editable edge.
nodenode, isSelected, isDragging, isHovered, isDraggable, isSelectable, isConnectable, positionAbsolute, zIndex, isConnectionTarget, isResizable, isResizing, isEditing, isDropTarget, isOverlapping, isCollapsed, hiddenChildCount, isNeighbour, label, handlesNode body. Receives a built label and inline handle widgets; the engine attaches node gestures.
nodeLabelnode, isSelected, isDragging, isHovered, isDraggable, isSelectable, isConnectable, positionAbsolute, zIndex, isConnectionTarget, isResizable, isResizing, isEditing, isDropTarget, isOverlapping, isCollapsed, hiddenChildCount, isNeighbourNode label widget, including the preset's editable text.
nodeToolbarnode, isSelectedScreen-space toolbar for a selected node.
edgeedge, path, origin, size, endpoints, isSelected, isHovered, isAnimated, sourceNode, targetNode, markerStart, markerEnd, interactionWidth, isReconnecting, waypoints, activeHandle, isNeighbourEdge visual. The engine retains hit testing, selection and hover.
edgeLabeledge, label, isSelected, isHovered, x, yLabel drawn at the edge's label point.
handlenode, handle, isConnectable, isConnecting, isConnectionCandidate, isValidCandidate, isConnectionInProgressA connection handle.
connectionLineconnection, path, from, to, fromPosition, toPosition, isValid, origin, sizeThe line drawn while connecting.
backgroundviewport, width, heightPane backdrop. Return SizedBox.shrink() for none.
selectionBoxrectThe rectangle drawn while box-selecting.
nodesSelectionRectrect, nodesBounds drawn around a multi-selection.
resizeControlnode, position, variant, isResizingResize lines and corner handles.
reconnectHandleedge, end, sizeGrab area at an edge end. Invisible by default.

Override Example

import FlowDiagram from "@/components/diagram/flow-diagram";
import { MainAxisSize, Row } from "flitterjs";

FlowDiagram({
  data,
  config: { colorMode: "dark", minimap: { visible: false } },
  custom: {
    controls: ({ zoomIn, zoomOut, fitView }) => Row({
      mainAxisSize: MainAxisSize.min,
      children: [zoomOut, fitView, zoomIn],
    }),
  },
});

Context

Builders receive FlowDiagramController plus the resolved config. Use derived args such as isHovered and isSelected to draw your widgets. Standard gestures are wired by the engine. Controller methods support application actions such as search, save and adding nodes.

Geometry and behavior

Use getHandles for connection points, getEdgePath for routing, nodeOptions for per-type interaction metadata, and getContextMenuItems for application commands. These strategies return data, while custom contains only widgets. See the common API for all props and events.