Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →
Reference<VueFlow />

<VueFlow />

Source on Github 

The <VueFlow /> component is the heart of your Vue Flow application.

<script setup lang="ts"> import { shallowRef } from 'vue'; import { VueFlow, type Node, type Edge } from '@xyflow/vue'; import '@xyflow/vue/style.css'; const nodes = shallowRef<Node[]>([ { id: 'a', data: { label: 'node a' }, position: { x: 0, y: 0 } }, { id: 'b', data: { label: 'node b' }, position: { x: 0, y: 100 } } ]); const edges = shallowRef<Edge[]>([ { id: 'e1-2', source: 'a', target: 'b' } ]); </script> <template> <VueFlow v-model:nodes="nodes" v-model:edges="edges" fit-view /> </template>

This component takes a lot of different props, most of which are optional. We’ve tried to document them in groups that make sense to help you find your way.

Common props

These are the props you will most commonly use when working with Vue Flow.

NameTypeDefault
idstring

An optional id for the flow. Useful when you render multiple flows on one page.

nodesNode<Record<string, unknown>, string | undefined>[]

An array of nodes to render in a controlled flow.

[]
edgesEdge<Record<string, unknown>, string>[]

An array of edges to render in a controlled flow.

[]
edgeTypesEdgeTypesObject<Edge<Record<string, unknown>, string>>

Custom edge types to be available in a flow. Vue Flow matches an edge’s type to a component in the edgeTypes object. Alternatively, register edge components with the #edge-<type> slots.

nodeTypesNodeTypesObject<Node<Record<string, unknown>, string | undefined>>

Custom node types to be available in a flow. Vue Flow matches a node’s type to a component in the nodeTypes object. Alternatively, register node components with the #node-<type> slots.

forceColorModeColorMode

Forces a color scheme on the flow container via class name, overriding the system default. Page-level theming is typically done by setting data-theme on <html>.

proOptionsProOptions

By default, we render a small attribution in the corner of your flows that links back to the project.

Anyone is free to remove this attribution whether they’re a Pro subscriber or not but we ask that you take a quick look at our https://vueflow.dev/learn/troubleshooting/remove-attribution  removing attribution guide before doing so.

ariaLabelConfigPartial<AriaLabelConfig$1>

Customize the aria labels / a11y descriptions (node/edge descriptions, the aria-live move message, and the Controls/MiniMap/Handle labels). Merged over the defaults.

debugboolean

When true, Vue Flow logs its events to the console as they fire (high-frequency ones like move/drag are skipped) — handy for debugging which events run.

false
...propsHTMLAttributes

Viewport props

NameTypeDefault
defaultViewportPartial<Viewport$1>

Sets the initial position and zoom of the viewport. If a default viewport is provided but fitView is enabled, the default viewport will be ignored.

{ x: 0, y: 0, zoom: 1 }
fitViewboolean

When true, the flow will be zoomed and panned to fit all the nodes initially provided.

fitViewOptions{ padding?: Padding; includeHiddenNodes?: boolean; minZoom?: number; maxZoom?: number; duration?: number; ease?: (t: number) => number; interpolate?: 'smooth' | 'linear'; nodes?: (NodeType | { id: string; })[]; }

When you typically call fitView on a VueFlowInstance, you can provide an object of options to customize its behavior. This prop lets you do the same for the initial fitView call.

{ padding: '5%' }
minZoomnumber

Minimum zoom level.

0.5
maxZoomnumber

Maximum zoom level.

2
snapGridSnapGrid

If snapToGrid is enabled, this prop configures the grid that nodes will snap to.

onlyRenderVisibleElementsboolean

You can enable this optimisation to instruct Vue Flow to only render nodes and edges that would be visible in the viewport. This might improve performance when you have a large number of nodes and edges but also adds an overhead.

false
translateExtentCoordinateExtent

By default, the viewport extends infinitely. You can use this prop to set a boundary. The first pair of coordinates is the top left boundary and the second pair is the bottom right.

[[-∞, -∞], [+∞, +∞]]
preventScrollingboolean

Disabling this prop will allow the user to scroll the page even when their pointer is over the flow.

true
attributionPositionPanelPosition

Set position of the attribution

'bottom-right'
viewportViewport

Controlled viewport (v-model:viewport) — keeps the flow’s transform in sync with the bound value.

Node props

NameTypeDefault
nodeOriginNodeOrigin

The origin of the node to use when placing it in the flow or looking up its x and y position. An origin of [0, 0] means that a node’s top left corner will be placed at the x and y position.

[0, 0]
nodesDraggableboolean

Controls whether all nodes should be draggable or not. Individual nodes can override this setting by setting their draggable prop.

true
nodesConnectableboolean

Controls whether all nodes should be connectable or not. Individual nodes can override this setting by setting their connectable prop.

true
nodesFocusableboolean

When true, focus between nodes can be cycled with the Tab key and selected with the Enter key. This option can be overridden by individual nodes by setting their focusable prop.

true
nodeDragThresholdnumber

With a threshold greater than zero you can delay node drag events. If threshold equals 1, you need to drag the node 1 pixel before a drag event is fired.

1
nodeExtentCoordinateExtent

By default, nodes can be placed on an infinite flow. You can use this prop to set a boundary. The first pair of coordinates is the top left boundary and the second pair is the bottom right.

elevateNodesOnSelectboolean

Enabling this option will raise the z-index of nodes when they are selected.

true

Edge props

NameTypeDefault
edgesFocusableboolean

When true, focus between edges can be cycled with the Tab key and selected with the Enter key. This option can be overridden by individual edges by setting their focusable prop.

true
edgesReconnectableEdgeReconnectable

Whether edges can be updated once they are created. When both this prop is true and an onReconnect handler is provided, the user can drag an existing edge to a new source or target. Individual edges can override this value with their reconnectable property.

true
reconnectRadiusnumber

The radius around an edge connection that can trigger an edge reconnection.

10
elevateEdgesOnSelectboolean

Enabling this option will raise the z-index of edges when they are selected.

false
defaultMarkerColorstring | null

Color of edge markers. You can pass null to use the CSS variable --xy-edge-stroke for the marker color.

'#b1b1b7'
defaultEdgeOptionsDefaultEdgeOptions

Defaults to be applied to all new edges that are added to the flow. Properties on a new edge will override these defaults if they exist. Does not apply to the addEdge utility.

Event handlers

General Events

NameTypeDefault
init[paneEvent: VueFlowInstance<Node<Record<string, unknown>, string | undefined>, Edge<Record<string, unknown>, string>>]
error[error: VueFlowError<ErrorCode, [] | [id?: string | undefined] | [id: string | null] | [id: string, parentId: string] | [type: string] | [id: string] | [id: string] | [id: string] | [id: string] | [id: string, source: string] | [id: string, target: string] | [type: ...] | [id: ...] | [id: ...]>]
nodesChangeNodeChangeset<Node<Record<string, unknown>, string | undefined>>
edgesChangeEdgeChangeset<Edge<Record<string, unknown>, string>>
delete[event: { nodes: Node<Record<string, unknown>, string | undefined>[]; edges: Edge<Record<string, unknown>, string>[]; }]
nodesDelete[nodes: Node<Record<string, unknown>, string | undefined>[]]
edgesDelete[edges: Edge<Record<string, unknown>, string>[]]
onBeforeDeleteOnBeforeDelete<Node<Record<string, unknown>, string | undefined>, Edge<Record<string, unknown>, string>> | null

This handler is called before nodes or edges are deleted, allowing the deletion to be aborted by returning false or modified by returning updated nodes and edges.

updateNodeInternals[]

Viewport Events

NameTypeDefault
moveStart[moveEvent: { event: MouseTouchEvent | null; viewport: Viewport; }]
move[moveEvent: { event: MouseTouchEvent | null; viewport: Viewport; }]
moveEnd[moveEvent: { event: MouseTouchEvent | null; viewport: Viewport; }]
viewportChangeStart[viewport: Viewport]
viewportChange[viewport: Viewport]
viewportChangeEnd[viewport: Viewport]

Node Events

NameTypeDefault
nodeClick[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeDoubleClick[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeMouseEnter[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeMouseMove[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeMouseLeave[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeContextMenu[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
nodeDragStart[nodeDragEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
nodeDrag[nodeDragEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
nodeDragStop[nodeDragEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
nodesInitialized[nodes: Node<Record<string, unknown>, string | undefined>[]]
miniMapNodeClick[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
miniMapNodeDoubleClick[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
miniMapNodeMouseEnter[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
miniMapNodeMouseMove[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]
miniMapNodeMouseLeave[nodeMouseEvent: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>]

Edge Events

NameTypeDefault
edgeContextMenu[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
edgeMouseEnter[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
edgeMouseMove[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
edgeMouseLeave[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
edgeDoubleClick[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
edgeClick[edgeMouseEvent: EdgeMouseEvent<Edge<Record<string, unknown>, string>>]
reconnectStart[edgeReconnectEvent: EdgeReconnectStartEvent<Edge<Record<string, unknown>, string>>]
reconnect[reconnectEvent: EdgeReconnectEvent<Edge<Record<string, unknown>, string>>]
reconnectEnd[edgeReconnectEvent: EdgeReconnectEndEvent<Node<Record<string, unknown>, string | undefined>, Edge<Record<string, unknown>, string>>]

Selection Events

NameTypeDefault
selectionChange[selectionEvent: SelectionChangeEvent<Node<Record<string, unknown>, string | undefined>, Edge<Record<string, unknown>, string>>]
selectionContextMenu[selectionEvent: { event: MouseEvent; nodes: Node<Record<string, unknown>, string | undefined>[]; }]
selectionDragStart[selectionEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
selectionDrag[selectionEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
selectionDragStop[selectionEvent: NodeDragEvent<Node<Record<string, unknown>, string | undefined>>]
selectionStart[selectionEvent: MouseEvent]
selectionEnd[selectionEvent: MouseEvent]

Pane Events

NameTypeDefault
paneClick[paneEvent: MouseEvent]
paneContextMenu[paneEvent: MouseEvent]
paneMouseEnter[paneEvent: MouseEvent]
paneMouseMove[paneEvent: MouseEvent]
paneMouseLeave[paneEvent: MouseEvent]
paneScroll[paneEvent: WheelEvent | undefined]

Connection Events

NameTypeDefault
connect[connectionEvent: Connection]
connectStart[connectionEvent: { event?: MouseEvent; } & OnConnectStartParams]
connectEnd[connectionEvent: ConnectEndEvent<Node<Record<string, unknown>, string | undefined>>]
isValidConnectionIsValidConnection | null

This callback can be used to validate a new connection. If you return false, the edge will not be added to your flow. If you have custom connection logic it is preferred to use this callback over the isValidConnection prop on the handle component for performance reasons.

clickConnectStart[connectionEvent: { event?: MouseEvent; } & OnConnectStartParams]
clickConnectEnd[connectionEvent: ConnectEndEvent<Node<Record<string, unknown>, string | undefined>>]

Connection line props

NameTypeDefault
connectionRadiusnumber

The radius around a handle where you drop a connection line to create a new edge.

20
connectionDragThresholdnumber

The threshold in pixels that the pointer must move before a connection line starts to drag. This is useful to prevent accidental connections when clicking on a handle.

1
connectionLineTypeConnectionLineType

The path shape drawn while dragging a new connection, see ConnectionLineType .

Edges can be of any type once created, but the connection line has to know which path to draw before that.

'default'
connectionLineStyleCSSProperties

Inline style applied to the connection line itself.

connectionLineContainerStyleCSSProperties

Inline style applied to the <svg> the connection line is drawn in.

connectionLineClassClassValue

Additional class names applied to the connection line.

connectionLineMarkerStartEdgeMarkerType

Marker rendered at the start (source handle) of the connection line.

connectionLineMarkerEndEdgeMarkerType

Marker rendered at the end (pointer side) of the connection line.

Interaction props

NameTypeDefault
elementsSelectableboolean

When true, elements (nodes and edges) can be selected by clicking on them. This option can be overridden by individual elements by setting their selectable prop.

true
autoPanOnConnectboolean

When true, the viewport will pan automatically when the cursor moves to the edge of the viewport while creating a connection.

true
autoPanOnNodeDragboolean

When true, the viewport will pan automatically when the cursor moves to the edge of the viewport while dragging a node.

true
autoPanOnSelectionboolean

Pan the viewport automatically when the cursor reaches the edge of the viewport while dragging a selection box.

true
autoPanOnNodeFocusboolean

Pan the viewport to a node when it receives keyboard focus (Tab) and isn’t currently within the viewport — keeps keyboard navigation from landing on off-screen nodes.

true
autoPanSpeednumber

The speed at which the viewport pans while dragging a node or a selection box.

15
selectNodesOnDragboolean

If true, nodes get selected on drag.

true
panOnDragboolean | number[]

Enabling this prop allows users to pan the viewport by clicking and dragging. You can also set this prop to an array of numbers to limit which mouse buttons can activate panning.

true
selectionOnDragboolean

Draw a selection box on a plain pane drag (no key held). Pair it with panOnDrag set to a non-left button (e.g. [1, 2]) or false so a left-drag selects instead of panning. Has no effect when the left mouse button pans the viewport (panOnDrag is true or includes 0).

false
selectionModeSelectionMode

When set to "partial", when the user creates a selection box by click and dragging nodes that are only partially in the box are still selected.

'full'
panOnScrollboolean

Controls if the viewport should pan by scrolling inside the container. Can be limited to a specific direction with panOnScrollMode.

false
panOnScrollModePanOnScrollMode

This prop is used to limit the direction of panning when panOnScroll is enabled. The "free" option allows panning in any direction.

"free"
panOnScrollSpeednumber

Controls how fast viewport should be panned on scroll. Use together with panOnScroll prop.

0.5
zoomOnScrollboolean

Controls if the viewport should zoom by scrolling inside the container.

true
zoomOnPinchboolean

Controls if the viewport should zoom by pinching on a touch screen.

true
zoomOnDoubleClickboolean

Controls if the viewport should zoom by double-clicking somewhere on the flow.

true
connectionModeConnectionMode

A loose connection mode will allow you to connect handles with differing types, including source-to-source connections. However, it does not support target-to-target connections. Strict mode allows only connections between source handles and target handles.

'strict'
connectOnClickboolean

The connectOnClick option lets you click or tap on a source handle to start a connection and then click on a target handle to complete the connection. If you set this option to false, users will need to drag the connection line to the target handle to create a connection.

true
snapToGridboolean

When enabled, nodes will snap to the grid when dragged.

paneDragThresholdnumber

Distance in pixels the pointer has to move before dragging the pane starts panning or a selection. If the pointer moves less, the gesture is treated as a click: paneClick (or paneContextMenu when panning with the right mouse button) is emitted and the viewport does not move. This applies to every mouse button that is enabled via panOnDrag and to selectionOnDrag.

1
zIndexModeZIndexMode

controls how the z-index of nodes and edges is calculated.

  • basic (default): z-index is derived from the element’s zIndex, parentage and selection state
  • auto: same as basic, but parented nodes are always lifted above their parent
  • manual: the element’s explicit zIndex is used verbatim (no elevation)

Keyboard props

NameTypeDefault
deleteKeyCodeKeyFilter | null

If set, pressing the key or chord will delete any selected nodes and edges. Passing an array represents multiple keys that can be pressed.

'Backspace'
selectionKeyCodeKeyFilter | null

If set, holding this key will let you click and drag to draw a selection box around multiple nodes and edges. Passing an array represents multiple keys that can be pressed.

'Shift'
multiSelectionKeyCodeKeyFilter | null

Pressing down this key you can select multiple elements by clicking.

"Meta" for macOS, "Control" for other systems
zoomActivationKeyCodeKeyFilter | null

If a key is set, you can zoom the viewport while that key is held down even if panOnScroll is set to false. Setting this prop to null disables the functionality.

"Meta" for macOS, "Control" for other systems
panActivationKeyCodeKeyFilter | null

If a key is set, you can pan the viewport while that key is held down even if panOnScroll is set to false. Setting this prop to null disables the functionality.

'Space'
disableKeyboardA11yboolean

You can use this prop to disable keyboard accessibility features such as selecting nodes or moving selected nodes with the arrow keys.

false

Style props

Applying certain classes to elements rendered inside the canvas will change how interactions are handled. These props let you configure those class names if you need to.

NameTypeDefault
noPanClassNamestring

If an element in the canvas does not stop mouse events from propagating, clicking and dragging that element will pan the viewport. Adding the "nopan" class prevents this behavior and this prop allows you to change the name of that class.

"nopan"
noDragClassNamestring

If a node is draggable, clicking and dragging that node will move it around the canvas. Adding the "nodrag" class prevents this behavior and this prop allows you to change the name of that class.

"nodrag"
noWheelClassNamestring

Typically, scrolling the mouse wheel when the mouse is over the canvas will zoom the viewport. Adding the "nowheel" class to an element in the canvas will prevent this behavior and this prop allows you to change the name of that class.

"nowheel"

Notes

  • The props of this component get exported as VueFlowProps and its events as VueFlowEmits.
  • With v-model:nodes / v-model:edges Vue Flow applies node and edge changes for you. With a one-way :nodes / :edges binding the flow is controlled: handle @nodes-change / @edges-change and apply the NodeChangeset / EdgeChangeset yourself.