Skip to Content
Reference<SvelteFlow />

<SvelteFlow />

Source on Github 

The <SvelteFlow /> component is the heart of your Svelte Flow application.

<script> import { SvelteFlow } from '@xyflow/svelte'; import '@xyflow/svelte/dist/style.css'; let nodes = $state.raw([ { id: 'a', data: { label: 'node a' }, position: { x: 0, y: 0 } }, { id: 'b', data: { label: 'node b' }, position: { x: 0, y: 100 } } ]); let edges = $state.raw([ { id: 'e1-2', source: 'a', target: 'b' } ]); </script> <SvelteFlow bind:nodes bind:edges fitView />

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 Svelte Flow.

NameTypeDefault
...propsHTMLAttributes<HTMLDivElement>

Viewport props

NameTypeDefault
viewportSvelteFlowProps
initialViewportSvelteFlowProps
fitViewSvelteFlowProps
fitViewOptionsSvelteFlowProps
minZoomSvelteFlowProps
maxZoomSvelteFlowProps
snapGridSvelteFlowProps
onlyRenderVisibleElementsSvelteFlowProps
translateExtentSvelteFlowProps
preventScrollingSvelteFlowProps
attributionPositionSvelteFlowProps

Node props

NameTypeDefault
nodeOriginSvelteFlowProps
nodesDraggableSvelteFlowProps
nodesConnectableSvelteFlowProps
nodesFocusableSvelteFlowProps
nodeDragThresholdSvelteFlowProps
nodeClickDistanceSvelteFlowProps
nodeExtentSvelteFlowProps
elevateNodesOnSelectSvelteFlowProps

Edge props

NameTypeDefault
edgesFocusableSvelteFlowProps
elevateEdgesOnSelectSvelteFlowProps
defaultMarkerColorSvelteFlowProps
defaultEdgeOptionsSvelteFlowProps

Event handlers

General Events

NameTypeDefault
oninitSvelteFlowProps
onflowerrorSvelteFlowProps
ondeleteSvelteFlowProps
onbeforedeleteSvelteFlowProps

Node Events

NameTypeDefault
onnodeclickSvelteFlowProps
onnodedragstartSvelteFlowProps
onnodedragSvelteFlowProps
onnodedragstopSvelteFlowProps
onnodepointerenterSvelteFlowProps
onnodepointermoveSvelteFlowProps
onnodepointerleaveSvelteFlowProps
onnodecontextmenuSvelteFlowProps

Edge Events

NameTypeDefault
onedgeclickSvelteFlowProps
onedgecontextmenuSvelteFlowProps
onedgepointerenterSvelteFlowProps
onedgepointerleaveSvelteFlowProps
onreconnectSvelteFlowProps
onreconnectstartSvelteFlowProps
onreconnectendSvelteFlowProps
onbeforereconnectSvelteFlowProps

Selection Events

NameTypeDefault
onselectionchangeSvelteFlowProps
onselectionclickSvelteFlowProps
onselectioncontextmenuSvelteFlowProps
onselectiondragstartSvelteFlowProps
onselectiondragSvelteFlowProps
onselectiondragstopSvelteFlowProps
onselectionstartSvelteFlowProps
onselectionendSvelteFlowProps

Pane Events

NameTypeDefault
onpaneclickSvelteFlowProps
onpanecontextmenuSvelteFlowProps
onmovestartSvelteFlowProps
onmoveSvelteFlowProps
onmoveendSvelteFlowProps

Connection Events

NameTypeDefault
onconnectSvelteFlowProps
onconnectstartSvelteFlowProps
onbeforeconnectSvelteFlowProps
onconnectendSvelteFlowProps
isValidConnectionSvelteFlowProps
clickConnectSvelteFlowProps
onclickconnectstartSvelteFlowProps
onclickconnectendSvelteFlowProps

Connection line props

NameTypeDefault
connectionRadiusSvelteFlowProps
connectionLineComponentSvelteFlowProps
connectionLineTypeSvelteFlowProps
connectionLineStyleSvelteFlowProps
connectionLineContainerStyleSvelteFlowProps

Interaction props

NameTypeDefault
elementsSelectableSvelteFlowProps
autoPanOnConnectSvelteFlowProps
autoPanOnNodeDragSvelteFlowProps
autoPanOnSelectionSvelteFlowProps
selectNodesOnDragSvelteFlowProps
panOnDragSvelteFlowProps
selectionOnDragSvelteFlowProps
selectionModeSvelteFlowProps
panOnScrollSvelteFlowProps
panOnScrollModeSvelteFlowProps
zoomOnScrollSvelteFlowProps
zoomOnPinchSvelteFlowProps
zoomOnDoubleClickSvelteFlowProps
connectionModeSvelteFlowProps
paneClickDistanceSvelteFlowProps
zIndexModeSvelteFlowProps

Keyboard props

NameTypeDefault
deleteKeySvelteFlowProps
selectionKeySvelteFlowProps
multiSelectionKeySvelteFlowProps
zoomActivationKeySvelteFlowProps
panActivationKeySvelteFlowProps
disableKeyboardA11ySvelteFlowProps

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
noPanClassSvelteFlowProps
noDragClassSvelteFlowProps
noWheelClassSvelteFlowProps

Notes

  • The props of this component get exported as SvelteFlowProps
Last updated on