Skip to Content
Svelte Flow 2 is out! Read the announcement →

NodeProps

When you implement a custom node it is wrapped in a component that enables basic functionality like drag, select and remove. A custom node gets the following props:

NameTypeDefault
idstring

Unique id of a node.

dataRecord<string, unknown>

Arbitrary data passed to a node.

widthnumber
heightnumber
sourcePositionPosition

Only relevant for default, source, target nodeType. Controls source position.

targetPositionPosition

Only relevant for default, source, target nodeType. Controls target position.

dragHandlestring

A class name that can be applied to elements inside the node that allows those elements to act as drag handles, letting the user drag the node by clicking and dragging on those elements.

parentIdstring

Parent node id, used for creating sub-flows.

typestring | undefined

Type of node defined in nodeTypes

draggingboolean

Whether or not the node is currently being dragged.

zIndexnumber
selectableboolean
deletableboolean
selectedboolean
draggableboolean

Whether or not the node is able to be dragged.

isConnectableboolean

Whether a node is connectable or not.

positionAbsoluteXnumber

Position absolute x value.

positionAbsoluteYnumber

Position absolute y value.

Notes

  • If you have controls (like a slider or an input) or other elements inside your custom node that should not drag the node you can add the class nodrag to those elements. This prevents the default drag behavior as well as the default node selection behavior when elements with this class are clicked.

    CustomNode.svelte
    <div> <input class="nodrag" type="range" min={0} max={100} /> </div>
  • If you have scroll containers inside your custom node you can add the class nowheel to disable the default canvas pan behavior when scrolling inside your custom nodes.

    CustomNode.svelte
    <div class="nowheel" style:overflow="auto"> <p>Scrollable content...</p> </div>
  • When creating your own custom nodes, you will also need to remember to style them! Custom nodes have no default styles unlike the built-in nodes so you can use any styling method you like.