<Controls />
<Controls /> 组件会渲染一个小面板,其中包含一些便捷的按钮,可用于放大、缩小、适配视图和锁定视口。
¥The <Controls /> component renders a small panel that contains convenient
buttons to zoom in, zoom out, fit the view, and lock the viewport.
import { ReactFlow, Controls } from '@xyflow/react'
export default function Flow() {
return (
<ReactFlow nodes={[...]} edges={[...]}>
<Controls />
</ReactFlow>
)
}属性
¥Props
对于 TypeScript 用户,<Controls /> 组件的 props 类型导出为 ControlProps。
¥For TypeScript users, the props type for the <Controls /> component is exported
as ControlProps.
| Name | Type | Default |
|---|---|---|
showZoom | booleanWhether or not to show the zoom in and zoom out buttons. These buttons will adjust the viewport zoom by a fixed amount each press. | true |
showFitView | booleanWhether or not to show the fit view button. By default, this button will adjust the viewport so that all nodes are visible at once. | true |
showInteractive | booleanShow button for toggling interactivity | true |
fitViewOptions | FitViewOptionsBase<NodeType>Customise the options for the fit view button. These are the same options you would pass to the fitView function. | |
onZoomIn | () => voidCalled in addition the default zoom behavior when the zoom in button is clicked. | |
onZoomOut | () => voidCalled in addition the default zoom behavior when the zoom out button is clicked. | |
onFitView | () => voidCalled when the fit view button is clicked. When this is not provided, the viewport will be adjusted so that all nodes are visible. | |
onInteractiveChange | (interactiveStatus: boolean) => voidCalled when the interactive (lock) button is clicked. | |
position | PanelPositionPosition of the controls on the pane | PanelPosition.BottomLeft |
children | ReactNode | |
style | CSSPropertiesStyle applied to container | |
className | stringClass name applied to container | |
aria-label | string | 'React Flow controls' |
orientation | "horizontal" | "vertical" | 'vertical' |
注释
¥Notes
-
要扩展或自定义控件,你可以使用
<ControlButton />组件¥To extend or customize the controls, you can use the
<ControlButton />component