<EdgeText />
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.
| Name | Type | Default |
|---|---|---|
# x | numberThe x position where the label should be rendered. | |
# y | numberThe y position where the label should be rendered. | |
# label | string | React.ReactNodeThe text or label to render along an edge. | |
# labelStyle | React.CSSPropertiesCustom styles to apply to the label. | |
# labelShowBg | boolean | |
# labelBgStyle | React.CSSProperties | |
# labelBgPadding | [number, number] | |
# labelBgBorderRadius | number | |
Additionally, you may also pass any standard React HTML attributes such as onClick,
className and so on.