Skip to content

Edge Renderer

EdgeLabelTemplate draws HTML at each edge's label point, in a layer that is not zoomed - React Flow's EdgeLabelRenderer. Here every edge gets its label as HTML with a button that removes the edge; the labels stay the same size at any zoom.

Node A
Node B
Node C
to B
to C
bit Blow

Try it

  • Click the × on an edge's label to remove that edge.
  • Scroll to zoom: the edges and nodes grow and shrink, the HTML labels keep their size and stay on their edges.
  • Drag a node: each label follows its edge's midpoint.
  • Drag from a node's bottom dot to another node's top dot: the new edge gets a × of its own, with no text since it has no label.
  • Reset edges puts the two starting edges back.

How it works

  • EdgeLabelTemplate is a RenderFragment<BlowEdgeContext> rendered once per edge, centred on the edge's label point (LabelX, LabelY) in an overlay that is positioned but not scaled, so the HTML keeps a constant screen size.
  • While it is set it replaces the built-in SVG labels, which is why the template draws ctx.Edge.Label itself. The edge path, its arrowhead and its selection are still drawn by the canvas.
  • Anything in the label that takes a press carries the nopan class (and nodrag), the canvas's NoPanClass and NoDragClass; BlowEdgeToolbar is a ready-made container that does the same.
  • The button removes the edge from the Edges list the canvas was given; Reset edges hands it a new list.
An unhandled error has occurred. Reload 🗙