Skip to content

HTML Edge Labels & Drag Handles

An EdgeLabelTemplate turns every edge label into HTML - here with a delete button in it - drawn in an overlay that keeps a constant size at any zoom. The purple nodes set UseCustomDragHandle, so only the BlowDragHandle grip in their template moves them.

⠿
Source
⠿
Process
Plain (drag anywhere)
validate
emit
Arrow keys move the view, Home shows the whole flow.
bit Blow

Try it

  • Drag a purple node by its ⠿ grip to move it. Dragging its body does not move it - a press there only selects it.
  • Drag the plain node from anywhere on it, as any node without a custom drag handle.
  • Click × on an edge's label to delete that edge.
  • Scroll to zoom in and out: the nodes grow and shrink, while the labels and their buttons keep the same size on screen.
  • Connect two nodes: the new edge has no Label, so its HTML label shows the edge's id instead.

How it works

  • EdgeLabelTemplate is a RenderFragment<BlowEdgeContext> rendered as HTML at each edge's label point, in a layer above the graph that is not zoomed. Once it is set it replaces the built-in SVG labels.
  • The delete button carries nodrag nopan: without them a press on it would start a pan, the pane would capture the pointer, and the click would never reach the button. It removes the edge from _edges, and the canvas drops it on the next render.
  • UseCustomDragHandle = true on a node stops its body from starting drags; only a BlowDragHandle inside its template does, and its Class styles the grip.
  • The plain node is handed back to BlowDefaultNode, the built-in look, from the same NodeTemplate.
  • Every node element carries bit-blow-node-{Type}, so the page tints the panel nodes with a .bit-blow-node-panel rule alone, mixed into --bit-blow-node-bg so it suits both colour modes.
  • The edges are a SmoothStep path and a bezier with a closed arrowhead (MarkerType = ArrowClosed).
An unhandled error has occurred. Reload 🗙