<Controls />
The <Controls /> component renders a small panel with convenient buttons to
zoom in, zoom out, fit the view, and lock the viewport.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Controls, VueFlow } from '@xyflow/vue';
const nodes = shallowRef([]);
const edges = shallowRef([]);
</script>
<template>
<VueFlow v-model:nodes="nodes" v-model:edges="edges">
<Controls />
</VueFlow>
</template>Props
The type for props of <Controls /> component is exported as ControlProps.
| Name | Type | Default |
|---|---|---|
showZoom | booleanShow the zoom control buttons (zoom-in and zoom-out) | true |
showFitView | booleanShow the fit view control button | true |
showInteractive | booleanShow the interactivity toggle control button | true |
fitViewOptions | {
padding?: Padding;
includeHiddenNodes?: boolean;
minZoom?: number;
maxZoom?: number;
duration?: number;
ease?: (t: number) => number;
interpolate?: 'smooth' | 'linear';
nodes?: (NodeType | {
id: string;
})[];
}FitViewOptionsBase Options to use when the fit view control button is pressed | undefined |
position | PanelPositionThe PanelPosition position of the | 'bottom-left' |
ariaLabel | string | nullAccessible label for the controls panel; falls back to | 'Control Panel' |
orientation | "horizontal" | "vertical"The direction the control buttons are laid out in | 'vertical' |
onZoomIn | (() => any) | undefined | |
onZoomOut | (() => any) | undefined | |
onFitView | (() => any) | undefined | |
onInteractionChange | ((isInteractive: boolean) => any) | undefined |
Notes
- To extend or customize the controls, add your own buttons with the
<ControlButton />component in the<Controls />default slot. <Controls />emitszoom-in,zoom-out,fit-view, andinteraction-changeso you can react to the built-in buttons.