Skip to Content
🚨 New Example: Handling Node Collisions!
参考手册组件

<EdgeToolbar />

GitHub 上的源代码 

¥Source on GitHub 

此组件可以将工具栏渲染到自定义边的一侧。此工具栏不会随视口缩放,因此在缩小时内容不会变得太小。

¥This component can render a toolbar to one side of a custom edge. This toolbar doesn’t scale with the viewport so that the content doesn’t get too small when zooming out.

import { memo } from 'react'; import { EdgeToolbar, BaseEdge, getBezierPath, type EdgeProps } from '@xyflow/react'; function CustomEdge(props: EdgeProps) { const [edgePath, centerX, centerY] = getBezierPath(props); return ( <> <BaseEdge id={props.id} path={edgePath} /> <EdgeToolbar edgeId={props.id} x={centerX} y={centerY} isVisible > <button> some button </button> </EdgeToolbar> </> ); } export default memo(CustomEdge);

属性

¥Props

NameTypeDefault
xnumber

The x position of the edge toolbar.

ynumber

The y position of the edge toolbar.

isVisibleboolean

If true, edge toolbar is visible even if edge is not selected.

false
alignX"left" | "center" | "right"

Align the vertical toolbar position relative to the passed x position.

"center"
alignY"center" | "top" | "bottom"

Align the horizontal toolbar position relative to the passed y position.

"center"
edgeIdstring

An edge toolbar must be attached to an edge.

...propsHTMLAttributes<HTMLDivElement>

注释

¥Notes

  • 默认情况下,工具栏仅在选中边缘时可见。你可以通过将 isVisible 属性设置为 true 来覆盖此行为。

    ¥By default, the toolbar is only visible when the edge is selected. You can override this behavior by setting the isVisible prop to true.

Last updated on