How it works
Each instance adds one <svg class="arc-svg"> to its container, absolutely positioned over the container's content, and draws every line into it. The overlay doesn't block clicks (pointer-events: none), and is hidden from assistive technology (aria-hidden); see accessibility.
- Put all the elements you connect inside the container. If the container is
position: staticit is changed toposition: relativeso the overlay scrolls and clips with it (and changed back ondestroy()). The default container isdocument.body. - Positions are measured relative to the overlay itself, so lines stay correct in scrolled containers and when the container is scaled with CSS transforms (for example by a pan/zoom library).
- The overlay is the container's first child, so it is painted below positioned elements that come after it. Set
z-indexon.arc-svgto change that.
Keeping lines in sync
With the default autoUpdate: true, lines are redrawn (at most once per frame) when:
- the window resizes or anything scrolls
- the container or a connected element changes size
- elements are added or removed in the container, or their
style,classorhiddenattributes change. Dragging by settingstyle.left/toporstyle.transformjust works.
For movement it can't observe, like CSS transitions and animations, either call arclace.update() yourself or use autoUpdate: 'frame'.
With frameworks
Create the instance after the elements are mounted and destroy it on unmount. In React:
tsx
useEffect(() => {
const arclace = new Arclace({ container: containerRef.current });
arclace.connect(aRef.current, bRef.current, { arrow: 'end' });
return () => arclace.destroy();
}, []);