Skip to Content

<EdgeText />

Source on GitHub

You can use the <EdgeText /> component as a helper component to display text within your custom edges.

import { EdgeText } from '@xyflow/react'; export function CustomEdgeLabel({ label }) { return ( <EdgeText x={100} y={100} label={label} labelStyle={{ fill: 'white' }} labelShowBg labelBgStyle={{ fill: 'red' }} labelBgPadding={[2, 4]} labelBgBorderRadius={2} /> ); }

Props

For TypeScript users, the props type for the <EdgeText /> component is exported as EdgeTextProps.

NameTypeDefault
xnumber

The x position where the label should be rendered.

ynumber

The y position where the label should be rendered.

labelReactNode

The label or custom element to render along the edge. This is commonly a text label or some custom controls.

labelStyleCSSProperties

Custom styles to apply to the label.

labelShowBgboolean
labelBgStyleCSSProperties
labelBgPadding[number, number]
labelBgBorderRadiusnumber
...propsOmit<SVGAttributes<SVGElement>, "x" | "y">

Additionally, you may also pass any standard React HTML attributes such as onClick, className and so on.

Last updated on