Config
Vue Flow allows you to configure zoom, graph and flow behavior. Configuration can be passed either as props to the VueFlow
component or as options to the useVueFlow
composable.
<!-- Pass configuration as props -->
<template>
<VueFlow :default-zoom="0.5" :max-zoom="4" :min-zoom="0.1" />
</template>
<script setup>
import { useVueFlow } from '@braks/vue-flow'
useVueFlow({
defaultZoom: 0.5,
maxZoom: 4,
minZoom: 0.1,
})
</script>
Updating Config
You can update the configuration at any point, either by having them bound as props or using the state values returned by useVueFlow
.
<script setup>
const defaultZoom = ref(1)
onMounted(() => {
// change the default zoom value of the state
defaultZoom.value = 1
})
</script>
<template>
<VueFlow :default-zoom="defaultZoom" />
</template>
<script setup>
const { defaultZoom } = useVueFlow({
defaultZoom: 0.5,
})
onMounted(() => {
// change the default zoom value of the state
defaultZoom.value = 1
})
</script>
Basic Options
optional
idType:
string
Details:
Unique id of Vue Flow.
It is used for the lookup and injection of the state instance.
optional
modelValueType:
Elements
Details:
An array of elements (nodes + edges).
Use either the modelValue prop or nodes/edges separately. Do not mix them!
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
const elements = ref([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
{ id: '4', type: 'output', label: 'Node 4', position: { x: 400, y: 200 } },
{ id: 'e1-3', source: '1', target: '3' },
{ id: 'e1-2', source: '1', target: '2', animated: true },
])
</script>
<template>
<div style="height: 300px">
<VueFlow v-model="elements" />
</div>
</template>
optional
nodesType:
Node[]
Details:
An array of nodes.
Use either the modelValue prop or nodes separately. Do not mix them!
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
const nodes = ref([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
{ id: '4', type: 'output', label: 'Node 4', position: { x: 400, y: 200 } },
])
</script>
<template>
<div style="height: 300px">
<VueFlow :nodes="nodes" />
</div>
</template>
optional
edgesType:
Edge[]
Details:
An array of edges.
Use either the modelValue prop or edges separately. Do not mix them!
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
const nodes = ref([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
{ id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
{ id: '4', type: 'output', label: 'Node 4', position: { x: 400, y: 200 } },
])
const edges = ref([
{ id: 'e1-3', source: '1', target: '3' },
{ id: 'e1-2', source: '1', target: '2', animated: true },
])
</script>
<template>
<div style="height: 300px">
<VueFlow :nodes="nodes" :edges="edges" />
</div>
</template>
optional
node-typesDefault:
DefaultNodeTypes
Details:
An object mapping node-type names to component definitions/name.
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
import CustomNode from './CustomNode.vue'
const nodeTypes = {
custom: CustomNode,
}
const nodes = ref([
{ id: '1', type: 'custom', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
])
const edges = ref([
{ id: 'e1-2', source: '1', target: '2', animated: true },
])
</script>
<template>
<div style="height: 300px">
<VueFlow :nodes="nodes" :edges="edges" :node-types="nodeTypes" />
</div>
</template>
optional
edge-typesDefault:
DefaultEdgeTypes
Details:
An object mapping edge-type names to component definitions/name.
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
import CustomEdge from './CustomEdge.vue'
const edgeTypes = {
custom: CustomEdge,
}
const nodes = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
])
const edges = ref([
{ id: 'e1-2', type: 'custom', source: '1', target: '2', animated: true },
])
</script>
<template>
<div style="height: 300px">
<VueFlow :nodes="nodes" :edges="edges" :edge-types="edgeTypes" />
</div>
</template>
optional
apply-defaultType:
boolean
Default:
true
Details:
Enable/disable default state update handlers.
If you want to have full control of state changes, you can disable the default behavior and apply your own change handlers to the state.
Example:
<script setup>
import { VueFlow } from '@braks/vue-flow'
const nodes = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
])
const edges = ref([
{ id: 'e1-2', type: 'custom', source: '1', target: '2', animated: true },
])
</script>
<template>
<div style="height: 300px">
<VueFlow :nodes="nodes" :edges="edges" :apply-default="false" />
</div>
</template>
optional
connection-modeType:
ConnectionMode
Default:
ConnectionMode.Loose
Details:
If set to
loose
all handles are treated as source handles (thus allowing for connections on target handles as well.)
optional
connection-line-typeType:
ConnectionLineType
Default:
ConnectionLineType.Bezier
Details:
The path to use when drawing a connection-line (
bezier
,step
,smoothstep
).When using a custom connection line this prop does nothing.
optional
connection-line-styleType:
CSSProperties
|null
Details:
Additional styles to add to the default connection-line.
optional
fit-view-on-initType:
boolean
Default:
false
Details:
Trigger fit view when viewport is mounted.
Viewport Options
optional
zoom-activation-key-codeType:
KeyCode
Default:
Meta
Details:
Define a key which can be used to activate zoom.
Overwrites zoom-on-scroll or pan-on-scroll behavior as long as the key is pressed.
optional
zoom-on-scrollType:
boolean
Default:
true
Details:
Whether to allow zooming in and out when scrolling inside the Vue Flow container.
optional
zoom-on-pinchType:
boolean
Default:
true
Details:
Whether to allow zooming in and out when pinching (touch or trackpad) inside the Vue Flow container.
optional
zoom-on-double-clickType:
boolean
Default:
true
Details:
Whether to allow zooming in and out when double-clicking (or tapping) inside the Vue Flow container.
optional
pan-on-scrollType:
boolean
Default:
false
Details:
Whether to allow panning inside the Vue Flow container.
Does not work together with
zoom-on-scroll
but will work together withzoom-activation-key-code
.
optional
pan-on-scroll-speedType:
number
Default:
0.5
optional
pan-on-scroll-modeType:
PanOnScrollMode
Default:
PanOnScrollMode.Free
Details:
Specify on which axis panning is allowed (x, y or both).
optional
pan-on-dragOld name:
paneMovable
Type:
boolean
Default:
true
Details:
Whether to allow moving the pane when dragging inside the Vue Flow container.
optional
prevent-scrollingType:
boolean
Default:
true
Details:
Enable this to prevent vue flow from scrolling inside its container, i.e. allow for the page to scroll.
optional
no-wheel-class-nameType:
string
Default:
nowheel
Details:
Set a class name which prevents elements from triggering wheel-scroll events (thus disabling zoom/pan-scroll behavior on the element).
Useful if you want to allow for scrolling inside a node
optional
no-pan-class-nameType:
string
Default:
nopan
Details:
Set a class name which prevents elements from triggering pan-scroll events.
optional
min-zoomType:
number
Default:
0.5
optional
max-zoomType:
number
Default:
2
optional
default-zoomType:
number
Default:
1
optional
default-positionType:
[x: number, y: number]
Default:
[0, 0]
Details:
Default viewport position on initial load.
optional
translate-extentType:
CoordinateExtent
Default:
[
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
]
Details:
The area in which the viewport can be moved around.
Selection Options
optional
selection-key-codeType:
KeyCode
Default:
Shift
Details:
Define a key which can be used to activate the selection rect.
optional
multi-selection-key-codeType:
KeyCode
Default:
Meta
Details:
Define a key which can be used to activate multi-selection.
Multi-selection can be used to select multiple nodes with clicks.
optional
delete-key-codeType:
KeyCode
Default:
Backspace
Details:
Define a key which can be used to activate remove elements from the pane.
Global Node Options
optional
nodes-draggableType:
boolean
Default:
true
Details:
Globally enable/disable dragging nodes.
Can be overwritten by setting
draggable
on a specific node element.Example:
<script setup>
const elements = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
// This will overwrite the globally set option of nodes-draggable
{ id: '2', draggable: true, label: 'Node 2', position: { x: 100, y: 100 } },
])
</script>
<template>
<VueFlow :nodes-draggable="false" />
</template>
optional
nodes-connectableType:
boolean
Default:
true
Details:
Globally enable/disable connecting nodes.
Can be overwritten by setting
connectable
on a specific node element.Example:
<script setup>
const elements = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
// This will overwrite the globally set option of nodes-connectable
{ id: '2', connectable: true, label: 'Node 2', position: { x: 100, y: 100 } },
])
</script>
<template>
<VueFlow :nodes-connectable="false" />
</template>
optional
nodes-extentType:
CoordinateExtent
Default:
[
[Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY],
[Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY],
]
Details:
The area in which nodes can be moved around.
Can be overwritten by setting
extent
on a specific node element.Example:
<script setup>
const elements = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
// This will overwrite the globally set option of node-extent
{ id: '2', extent: [[-100, -100], [100, 100]], label: 'Node 2', position: { x: 100, y: 100 } },
])
</script>
<template>
<VueFlow />
</template>
optional
select-nodes-on-dragType:
boolean
Default:
true
optional
snap-to-gridType:
boolean
Default:
false
Details:
If enabled, nodes will be placed and moved in a grid-like fashion.
optional
snap-gridType:
SnapGrid
Default:
[15, 15]
Details:
If
snapToGrid
is enabled, nodes will be placed and moved in a grid-like fashion according to thesnapGrid
value.
Global Edge Options
optional
edges-updatableType:
boolean
Default:
true
Details:
Globally enable/disable updating edges.
Can be overwritten by setting
updatable
on a specific edge element.Example:
<script setup>
const elements = ref([
{ id: '1', label: 'Node 1', position: { x: 250, y: 5 } },
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
{ id: 'e1-3', source: '1', target: '3' },
// Overwrites global edges-updatable config
{ id: 'e1-2', updatable: true, source: '1', target: '2', animated: true },
])
</script>
<template>
<VueFlow :edges-updatable="false" />
</template>
optional
default-marker-colorType:
string
Default:
#b1b1b7
Details:
The default color value which is used when presenting edge-markers (arrowheads).
optional
edge-updater-radiusType:
number
Default:
10
Details:
The radius at which an edge-updater can be triggered.
optional
connect-on-clickType:
boolean
Default:
true
Details:
Allow edges to be created by clicking two handles in a row.
Useful if you want to enable creating edges on a touch device.
optional
default-edge-optionsType:
DefaultEdgeOptions
Details:
Default values when creating a new edge.
Does not work for the
addEdge
utility!
Global Element Options
optional
only-render-visible-elementsType:
boolean
Default:
false
Details:
Skip rendering elements that are not visible currently (either hidden or outside the current pane dimensions).
optional
elements-selectableType:
boolean
Default:
true
Details:
Enable/disable selecting elements. This will also disable pointer-events in general.