Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →

<Controls />

Source on GitHub 

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.

NameTypeDefault
showZoomboolean

Show the zoom control buttons (zoom-in and zoom-out)

true
showFitViewboolean

Show the fit view control button

true
showInteractiveboolean

Show 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
positionPanelPosition

The PanelPosition position of the <Controls> panel

'bottom-left'
ariaLabelstring | null

Accessible label for the controls panel; falls back to ariaLabelConfig['controls.ariaLabel'].

'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 /> emits zoom-in, zoom-out, fit-view, and interaction-change so you can react to the built-in buttons.