Custom Edges
If you want to introduce a new edge type you can pass an edgeTypes
object to the ReactFlow
component:
function Flow({ nodes, edges }) {
const edgeTypes = useMemo(() => ({ special: CustomEdgeComponent }), []);
return <ReactFlow edgeTypes={edgeTypes} nodes={nodes} edges={edges} />;
}
Now you can use the new type special
for an edge.
The straight
, default
and step
types would still be available unless you overwrote one of them.
There is an implementation of a custom edge in the custom edge example.
With a custom edge you can create editable edges or edges with controls like a button for example.
Prop Types​
Custom edges are wrapped. They receive the following props:
source
: string (node id)target
: string (node id)selected
: booleananimated
: booleanlabel
: stringlabelStyle
: svg attributeslabelShowBg
: booleanlabelBgStyle
: svg attributeslabelBgPadding
: numberlabelBgBorderRadius
: numberdata
: objectstyle
: svg attributessourceX
: numbersourceY
: numbertargetX
: numbertargetY
: numbersourcePosition
: 'left' | 'top' | 'right' | 'bottom'targetPosition
: 'left' | 'top' | 'right' | 'bottom'markerStart
: string or marker configmarkerEnd
: string or marker config