<NodeResizer />
The node resizer component can be used to add a resize functionality to your nodes. It renders draggable controls around the node to resize in all directions.
Since reactflow@11.7.0
the NodeResizer
component is part of the reactflow
package. If you are using a version < 11.7.0, you need to install it separately.
Getting Started
The reactflow
package exports two node resizer related components: NodeResizer
and NodeResizeControl
.
import { NodeResizer, NodeResizeControl } from 'reactflow';
Usage Example
The NodeResizer gets used in custom nodes. Beware that we are not passing width or height to a custom node. If you want to re-render your custom node on resize, you can access the node dimensions with the useStore function.
<NodeResizer />
Component
The NodeResizer component is a helper component that can be used inside a custom node to add resizing controls.
Prop Types
nodeId?
string
the id of the custom node where the <NodeResizer> is rendered
color?
string
isVisible?
boolean
true
keepAspectRatio?
boolean
false
minWidth?
number
10
maxWidth?
number
Number.MAX_SAFE_INTEGER
minHeight?
number
10
maxHeight?
number
Number.MAX_SAFE_INTEGER
handleStyle?
CSSProperties
handleClassName?
string
lineStyle?
CSSProperties
lineClassName?
string
shouldResize?
(event: ResizeDragEvent, params: ResizeParamsWithDirection) => boolean
onResizeStart?
(event: ResizeDragEvent, params: ResizeParams) => void
onResize?
(event: ResizeDragEvent, params: ResizeParamsWithDirection) => void
onResizeEnd?
(event: ResizeDragEvent, params: ResizeParams) => void
<NodeResizeControl />
Component
To create your own resizing UI, you can use the NodeResizeControl
component where you can pass children (such as icons).
Prop Types
nodeId
string
the id of the custom node where the <NodeResizer> is rendered
position?
'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
'bottom-right'
variant?
'handle' | 'line'
'handle'
keepAspectRatio?
boolean
false
minWidth?
number
10
maxWidth?
number
Number.MAX_SAFE_INTEGER
minHeight?
number
10
maxHeight?
number
Number.MAX_SAFE_INTEGER
color?
string
style?
CSSProperties
className?
string
children?
ReactNode
null
shouldResize?
(event: ResizeDragEvent, params: ResizeParamsWithDirection) => boolean
onResizeStart?
(event: ResizeDragEvent, params: ResizeParams) => void
onResize?
(event: ResizeDragEvent, params: ResizeParamsWithDirection) => void
onResizeEnd?
(event: ResizeDragEvent, params: ResizeParams) => void
Typescript
The node-resizer
package exports the prop type definitions for the components:
NodeResizerProps
ResizeControlProps