Skip to Content

Node

Source on GitHub

The Node type represents everything React Flow needs to know about a given node. Many of these properties can be manipulated both by React Flow or by you, but some such as width and height should be considered read-only.

export type Node< NodeData extends Record<string, unknown> = Record<string, unknown>, NodeType extends string = string, > = { id: string; position: XYPosition; data: NodeData; type?: NodeType; sourcePosition?: Position; targetPosition?: Position; hidden?: boolean; selected?: boolean; dragging?: boolean; draggable?: boolean; selectable?: boolean; connectable?: boolean; resizing?: boolean; deletable?: boolean; dragHandle?: string; width?: number | null; height?: number | null; parentId?: string; zIndex?: number; extent?: 'parent' | CoordinateExtent; expandParent?: boolean; ariaLabel?: string; focusable?: boolean; style?: React.CSSProperties; className?: string; origin?: NodeOrigin; handles?: NodeHandle[]; measured?: { width?: number; height?: number; }; };

Fields

NameTypeDefault
idstring

Unique id of a node

positionXYPosition

Position of a node on the pane

dataNodeData

Arbitrary data passed to a node

typeNodeType

Type of node defined in nodeTypes

sourcePositionPosition

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

targetPositionPosition

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

hiddenboolean
selectedboolean
draggingboolean

True, if node is being dragged

draggableboolean
selectableboolean
connectableboolean
deletableboolean
dragHandlestring
widthnumber
heightnumber
initialWidthnumber
initialHeightnumber
parentIdstring

Parent node id, used for creating sub-flows

zIndexnumber
extent"parent" | CoordinateExtent

Boundary a node can be moved in

expandParentboolean
ariaLabelstring
originNodeOrigin

Origin of the node relative to it’s position

handlesNodeHandle[]
measured{ width?: number; height?: number; }

Default node types

You can create any of React Flow’s default nodes by setting the type property to one of the following values:

  • "default"
  • "input"
  • "output"
  • "group"

If you don’t set the type property at all, React Flow will fallback to the "default" node with both an input and output port.

These default nodes are available even if you set the nodeTypes prop to something else, unless you override any of these keys directly.

Notes

  • You shouldn’t try to set the width or height of a node directly. It is calculated internally by React Flow and used when rendering the node in the viewport. To control a node’s size you should use the style or className props to apply CSS styles instead.
Last updated on