Edge
Edge variants for a Canvas. Temporary (dashed simple-bezier) and Animated (flowing dot along a bezier). Register both via the edgeTypes prop.
Overview
Edge is a namespace object that ships two production-ready edge components for xyflow workflows:
Edge.Temporary- a dashed simple-bezier path tinted withvar(--color-ring). Use it to represent in-flight or speculative connections that have not been committed.Edge.Animated- a standard bezier path with a small primary-colored circle that animates along it via<animateMotion>. Use it to represent live data flow between nodes (streaming tokens, observability traces, agent message passing).
Both variants are React components that conform to xyflow's EdgeProps contract. You register them on the Canvas through the edgeTypes prop and then reference them by key when constructing the edge data.
Preview
'use client';import '@xyflow/react/dist/style.css';import { Canvas, Edge } from '@gremorie/rx-ai';import { type Edge as FlowEdge, type EdgeTypes, type Node as FlowNode, ReactFlowProvider,} from '@xyflow/react';const edgeTypes: EdgeTypes = { temporary: Edge.Temporary, animated: Edge.Animated,};const edgeNodes: FlowNode[] = [ { id: 'a', position: { x: 0, y: 60 }, data: { label: 'Source' } }, { id: 'b', position: { x: 280, y: 0 }, data: { label: 'Target A' } }, { id: 'c', position: { x: 280, y: 140 }, data: { label: 'Target B' } },];const edgeEdges: FlowEdge[] = [ { id: 'a-b', source: 'a', target: 'b', type: 'animated' }, { id: 'a-c', source: 'a', target: 'c', type: 'temporary' },];export function EdgePreview() { return ( <div className="h-[360px] w-full"> <ReactFlowProvider> <Canvas edgeTypes={edgeTypes} edges={edgeEdges} nodes={edgeNodes} /> </ReactFlowProvider> </div> );}Anatomy
Edge custom React Flow edge
├─ Edge.Temporary dashed provisional edge
└─ Edge.Animated solid edge with a traveling dotInstallation
bash npx gremorie@latest add rx-edge bash pnpm dlx gremorie@latest add rx-edge bash yarn dlx gremorie@latest add rx-edge bash bunx --bun gremorie@latest add rx-edge Requires @xyflow/react.
Usage
import { Canvas, Edge } from "@gremorie/rx-ai";
const edgeTypes = {
temporary: Edge.Temporary,
animated: Edge.Animated,
};
const edges = [
{ id: "e1", source: "1", target: "2", type: "animated" },
{ id: "e2", source: "2", target: "3", type: "temporary" },
];
export function Workflow() {
return (
<Canvas nodes={nodes} edges={edges} edgeTypes={edgeTypes}>
{/* ... */}
</Canvas>
);
}The Angular edition of this component is planned; the React edition is production-ready today.
API
Edge.Temporary
A dashed simple-bezier edge. Renders BaseEdge with stroke-1 stroke-ring and strokeDasharray: "5, 5".
Accepts standard EdgeProps from @xyflow/react:
| Prop | Type | Description |
|---|---|---|
id | string | Edge ID. Forwarded to the SVG <path id>. |
sourceX / sourceY | number | Source handle coordinates (provided by xyflow). |
targetX / targetY | number | Target handle coordinates (provided by xyflow). |
sourcePosition / targetPosition | Position | Handle sides. Used by getSimpleBezierPath. |
You do not call these props yourself - xyflow forwards them automatically.
Edge.Animated
A bezier edge with a circle (fill="var(--primary)", r="4") animating along the path via <animateMotion> (2-second loop). Resolves the actual handle coordinates by reading InternalNode data so the animation lines up with the rendered handles even after node movement.
Returns null if either the source or target node has not yet hydrated through useInternalNode.
Accepts standard EdgeProps:
| Prop | Type | Description |
|---|---|---|
id | string | Edge ID. |
source | string | Source node ID. |
target | string | Target node ID. |
markerEnd | string | Optional arrowhead marker URL. |
style | CSSProperties | Forwarded to BaseEdge. |
Internal helpers:
getHandleCoordsByPosition(node, position)- resolves the absolute handle coordinates fromnode.internals.getEdgeParams(source, target)- computes source and target points usingPosition.Right->Position.Left.
The Animated variant is hardcoded to a left-to-right flow direction (source on the right of one node, target on the left of the next).
Composition
<Canvas>owns theedgeTypesregistry. PassEdge.TemporaryandEdge.Animatedkeyed by whatever name you want to use in edge data.- Edge data carries
type: "temporary"ortype: "animated"(or your custom key) per edge. xyflow picks the matching component. - Style overrides flow through the
styleprop on each edge entry, or via CSS targeting.react-flow__edge[data-id="..."].
Variations
Speculative connection
Show a dashed Edge.Temporary while the user is still configuring the connection, then swap to a solid edge once committed.
const edges = [{ id: 'draft-1', source: 'a', target: 'b', type: 'temporary' }];Live agent message flow
Use Edge.Animated to visualize messages flowing between agents in a multi-agent graph.
const edges = [
{ id: 'trace-1', source: 'planner', target: 'tools', type: 'animated' },
{ id: 'trace-2', source: 'tools', target: 'synthesizer', type: 'animated' },
];Mix with default xyflow edges
xyflow's built-in edge types remain registered. Combine them with the Gremorie variants for variety.
const edgeTypes = {
temporary: Edge.Temporary,
animated: Edge.Animated,
// built-ins: "default", "straight", "step", "smoothstep", "simplebezier"
};Accessibility
-
Pointer / keyboard parity: xyflow allows selecting edges with click and supports keyboard deletion (Backspace / Delete) when the edge has focus. Both variants are real SVG elements, so focus follows.
-
Reduced motion:
Edge.Animateduses SVG<animateMotion>. Wrap with CSS to disable the animation for users who prefer reduced motion:@media (prefers-reduced-motion: reduce) { .react-flow__edge animateMotion { display: none; } } -
Color contrast:
var(--color-ring)(Temporary stroke) andvar(--primary)(Animated dot) must clear 3:1 for non-text UI. Gremorie tokens meet this in both themes - re-verify if you swap to a custom palette. -
Screen readers: Edges by default carry no accessible name. If the relationship matters for users on assistive tech, supply
aria-labelon the wrappingCanvasor use xyflow'saria-labelsconfig.
Related
- Canvas - the surface that hosts edges via
edgeTypes - Connection - the in-progress drag line shown before an edge is committed
- Node - the source and target of every edge