React library to draw arrows or lines between DOM elements using refs or IDs. Current stable version is 2.0.2, released in 2022, requiring React >= 16.8.0. Ships TypeScript definitions. Key differentiator: simple declarative API with smart SVG arrow rendering, auto-updating on element moves, and customizable styles (color, dash, head shape). Stable with occasional patch releases. Alternative to react-archer or custom SVG solutions.
npm install react-xarrowsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Draws an arrow from a ref to an element ID. Shows basic Xarrow usage with start/end anchors.
Wrap all arrows and connected elements in <Xwrapper> and use useXarrow() in draggable components.
Use props directly: lineColor, headShape, etc. Update strokeColor to lineColor and advance to advanced.
Refer to v1.4.0+ docs for new label usage (e.g., label as ReactNode or object with position).
Ensure Xarrow is placed inside Xwrapper (v2) or a common parent with elements (v1).
In v2, use useXarrow hook and call updateXarrow() after position changes. In v1, use key prop to remount.
Change to: import Xarrow from 'react-xarrows'
Import: import { useXarrow, Xwrapper } from 'react-xarrows'. Wrap component tree with <Xwrapper>.In v2: wrap with <Xwrapper> and call useXarrow() in draggable component's onDrag handler.