Const
A split-pane container with a draggable splitter, supporting both horizontal and vertical layouts.
The pane can be either:
position
min
max
defaultPosition
Layout behavior:
mode="horizontal"
mode="vertical"
Ref API:
ref.current
getMode()
setMode(mode)
"horizontal"
"vertical"
getPosition()
setPosition(position)
Events:
onSizeChange(position)
Rendering:
children
Split direction: "horizontal" or "vertical". Defaults to "horizontal".
Controlled splitter position. Normalized value within [min, max]. If provided, the component uses this value instead of internal state.
[min, max]
Initial splitter position for uncontrolled usage. Defaults to 0.5.
0.5
Minimum allowed position. Defaults to 0.1.
0.1
Maximum allowed position. Defaults to 0.9.
0.9
Thickness of the draggable splitter in pixels. Defaults to 8.
8
Callback invoked when the position changes. Receives the new normalized position.
Optional root container styles.
Optional root container CSS class.
Optional styles applied to the left pane (or top pane in vertical mode).
Optional styles applied to the right pane (or bottom pane in vertical mode).
Optional styles applied to the splitter element.
React children to be rendered into the two pane containers.
const ref = useRef<ResizablePaneHandle>(null);<ResizablePane ref={ref} mode="horizontal" defaultPosition={0.5} min={0.1} max={0.9} onSizeChange={(pos) => console.log(pos)}> <div /> <div /></ResizablePane> Copy
const ref = useRef<ResizablePaneHandle>(null);<ResizablePane ref={ref} mode="horizontal" defaultPosition={0.5} min={0.1} max={0.9} onSizeChange={(pos) => console.log(pos)}> <div /> <div /></ResizablePane>
A split-pane container with a draggable splitter, supporting both horizontal and vertical layouts.
The pane can be either:
positionprop (number betweenminandmax), ordefaultPosition(used as the initial position).Layout behavior:
mode="horizontal": thepositioncontrols the width of the left pane.mode="vertical": thepositioncontrols the height of the top pane.Ref API:
ref.current:getMode()to get the current modesetMode(mode)to switch between"horizontal"and"vertical"getPosition()to get the current splitter positionsetPosition(position)to update the splitter positionEvents:
onSizeChange(position)whenever the pane size/position changes (e.g., via dragging).Rendering:
childreninto two separate containers (no portals).