<SvelteFlow />
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.
| Name | Type | Default |
|---|---|---|
...props | HTMLAttributes<HTMLDivElement> |
Viewport props
Node props
Edge props
| Name | Type | Default |
|---|---|---|
edgesFocusable | SvelteFlowProps | |
elevateEdgesOnSelect | SvelteFlowProps | |
defaultMarkerColor | SvelteFlowProps | |
defaultEdgeOptions | SvelteFlowProps |
Event handlers
General Events
| Name | Type | Default |
|---|---|---|
oninit | SvelteFlowProps | |
onflowerror | SvelteFlowProps | |
ondelete | SvelteFlowProps | |
onbeforedelete | SvelteFlowProps |
Node Events
Edge Events
Selection Events
Pane Events
| Name | Type | Default |
|---|---|---|
onpaneclick | SvelteFlowProps | |
onpanecontextmenu | SvelteFlowProps | |
onmovestart | SvelteFlowProps | |
onmove | SvelteFlowProps | |
onmoveend | SvelteFlowProps |
Connection Events
Connection line props
| Name | Type | Default |
|---|---|---|
connectionRadius | SvelteFlowProps | |
connectionLineComponent | SvelteFlowProps | |
connectionLineType | SvelteFlowProps | |
connectionLineStyle | SvelteFlowProps | |
connectionLineContainerStyle | SvelteFlowProps |
Interaction props
Keyboard props
| Name | Type | Default |
|---|---|---|
deleteKey | SvelteFlowProps | |
selectionKey | SvelteFlowProps | |
multiSelectionKey | SvelteFlowProps | |
zoomActivationKey | SvelteFlowProps | |
panActivationKey | SvelteFlowProps | |
disableKeyboardA11y | SvelteFlowProps |
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.
| Name | Type | Default |
|---|---|---|
noPanClass | SvelteFlowProps | |
noDragClass | SvelteFlowProps | |
noWheelClass | SvelteFlowProps |
Notes
- The props of this component get exported as
SvelteFlowProps
Last updated on