Skip to main content

<ArcherContainer>

Wraps the area in which arrows are drawn. Every <ArcherElement> must be rendered inside an ArcherContainer.

The styling props below set the defaults for every arrow in the container. Any individual arrow can override them through its relation's style — see Line styling.

Props

PropTypeDefaultDescription
childrenReactNode | (context) => ReactNodeYour layout. May also be a function of the internal context for third‑party renderers.
strokeColorstring'#f00'Default arrow color.
strokeWidthnumber2Default arrow thickness, in px.
strokeDasharraystringDefault dash pattern, e.g. '5,5'. See the SVG stroke docs.
lineStyle'angle' | 'straight' | 'curve''curve'How lines are drawn. Overrides noCurves.
noCurvesbooleanfalseDraw angles instead of curves (equivalent to lineStyle="angle").
offsetnumberSpace between an element and the start/end of its strokes, in px.
endShapeEndShapearrowDefault shape at the end of arrows.
startMarkerbooleanfalseRender a marker at the start of arrows too.
endMarkerbooleantrueRender a marker at the end of arrows.
svgContainerStyleCSSProperties{}Style of the SVG layer. Useful to set a z-index so arrows draw under your elements, for example.
styleCSSPropertiesStyle of the container div.
classNamestringClass on the container div.

Ref — refreshScreen()

The container exposes an imperative handle. Hold a ref to recompute all arrow positions on demand — useful when the viewport or some elements move without the container itself resizing.

import { useRef } from 'react';
import { ArcherContainer, ArcherContainerRef } from 'react-archer';

const ref = useRef<ArcherContainerRef>(null);
// ...
<ArcherContainer ref={ref}>{/* ... */}</ArcherContainer>;
// later, e.g. on scroll:
ref.current?.refreshScreen();

See Troubleshooting for when you need this.