Documentation

API reference

The supported exports in React Arch Diagrams 0.1.0. Unlisted source files are implementation details.

React exports

ExportPurpose
DiagramRenders positioned nodes, SVG edges, labels, ports, camera interaction, selection, and dragging.
DefaultNodeThe default HTML node renderer.
DefaultEdgeThe default SVG edge renderer.
useDiagramLayoutRuns asynchronous layout and discards stale results.

Builders

ExportPurpose
defineDiagram(document)Preserves generic inference for a diagram document.
node(id, options?)Creates a serializable node.
edge(id, from, to, options?)Creates a serializable edge.
anchors.auto(nodeId)Clips toward the next route point.
anchors.side(nodeId, side, position?, offset?)Targets an exact side position.
anchors.port(nodeId, portId)Targets a named port.
anchors.point(x, y)Creates an absolute endpoint.
routes.straight()Creates a direct route.
routes.elbow(axis?, radius?)Creates a one-bend route.
routes.orthogonal(axis?, split?, radius?)Creates a middle-corridor route.
routes.manual(points, radius?)Preserves supplied waypoints.
routes.auto(radius?)Uses an engine route or orthogonal fallback.
layouts.manual()Uses node positions.
layouts.row(options?)Places nodes left to right.
layouts.column(options?)Places nodes top to bottom.
layouts.grid(options?)Places nodes into measured grid cells.
layouts.layered(options?)Requests layered ELK layout.

Headless functions

ExportPurpose
computeDiagramRuns layout and routing.
arrangeDocumentRuns manual, row, column, or grid layout synchronously.
routeEdge / routeEdgesResolves endpoints and returns SVG paths.
resolveEndpointResolves point, node, side, and port endpoints.
rectangleIntersectionIntersects a center ray with a rectangle.
ellipseIntersectionIntersects a center ray with an ellipse.
pointsToPathConverts points to a rounded SVG path.
boundsOfNodesCalculates positioned diagram bounds.
animateElementReduced-motion-aware Web Animations wrapper.

ELK exports

Import layoutWithElk and elkLayoutEngine from react-arch-diagrams/elk.

Public types

PointSizeBoundsDirectionSideEndpointPortSpecRouteSpecDiagramNode<T>DiagramEdge<T>LayoutSpecDiagramDocument<NodeData, EdgeData>PositionedNode<T>RoutedEdge<T>DiagramResult<NodeData, EdgeData>ShapeDefinitionShapeRegistryLayoutEngineDiagramProps<NodeData, EdgeData>DiagramHandleNodeRendererProps<T>EdgeRendererProps<T>

Diagram handle

MethodPurpose
fit()Fits all positioned nodes.
zoomTo(zoom, center?)Sets zoom relative to fitted bounds.
panTo(center)Centers the current camera.
getSvgElement()Returns the live SVG element.
toSvgString()Serializes SVG and foreignObject node content.