Skip to Content
React Flow 13 is here! Read the announcement →

NodeProps<T>

Source on GitHub 

When you implement a custom node it is wrapped in a component that enables basic functionality like selection and dragging.

Usage

import { useState } from 'react'; import { NodeProps, Node } from '@xyflow/react'; export type CounterNode = Node< { initialCount?: number; }, 'counter' >; export default function CounterNode(props: NodeProps<CounterNode>) { const [count, setCount] = useState(props.data?.initialCount ?? 0); return ( <div> <p>Count: {count}</p> <button className="nodrag" onClick={() => setCount(count + 1)}> Increment </button> </div> ); }

Remember to register your custom node by adding it to the nodeTypes prop of your <ReactFlow /> component.

import { ReactFlow } from '@xyflow/react'; import CounterNode from './CounterNode'; const nodeTypes = { counterNode: CounterNode, }; export default function App() { return <ReactFlow nodeTypes={nodeTypes} ... /> }

You can read more in our custom node guide.

Fields

Your custom node receives 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.