<EdgeText />
你可以使用 <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
对于 TypeScript 用户,<EdgeText /> 组件的 props 类型被导出为 EdgeTextProps。
🌐 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 | ReactNodeThe label or custom element to render along the edge. This is commonly a text label or some custom controls. | |
labelStyle | CSSPropertiesCustom styles to apply to the label. | |
labelShowBg | boolean | |
labelBgStyle | CSSProperties | |
labelBgPadding | [number, number] | |
labelBgBorderRadius | number | |
...props | Omit<SVGAttributes<SVGElement>, "x" | "y"> |
此外,你还可以传递任何标准的 React HTML 属性,例如 onClick、className 等等。
🌐 Additionally, you may also pass any standard React HTML attributes such as onClick,
className and so on.
Last updated on