Resizable Split
Two panes side by side with a draggable, keyboard-accessible divider, a minimum width per pane, and a divider drawn from theme tokens.
npx visor add resizable-splitResizableSplit puts two panes side by side with a divider between them. Drag the divider, or focus it and use the arrow keys. The start pane takes the width; the end pane takes the rest. Neither pane goes below its minimum, and when the window shrinks the start pane gives way first.
Editor and preview
Remembering the width
size is the start pane's width in px. Keep it in state, persist it from onSizeChange, and pass it back, so the split opens where the person left it on that device.
const [width, setWidth] = useState(() => Number(localStorage.getItem('editor-width')) || 560);
<ResizableSplit
size={width}
onSizeChange={(w) => {
setWidth(w);
localStorage.setItem('editor-width', String(w));
}}
minStart={360}
minEnd={320}
dividerLabel="Resize editor and preview"
>
<EditorForms />
<iframe src={previewUrl} title="Preview" />
</ResizableSplit>Uncontrolled, defaultSize sets the first width; without either, the panes start equal.
Keys
The divider is a focusable role="separator". aria-valuenow is the start pane's width in px, between aria-valuemin (minStart) and aria-valuemax (the widest it can be while the end pane keeps minEnd).
| Key | Does |
|---|---|
| ← → | One step (step, 16px) |
| Shift + arrows | Four steps |
| Home | The start pane at its minimum |
| End | The end pane at its minimum |
Iframes
A drag captures the pointer on the divider and turns off pointer events on both panes until it ends, so an iframe in either pane (a live preview, even cross-origin) cannot swallow the moves.
Colour
A theme draws the divider's line through the resizable-split component tokens: divider-color at rest (falls back to --border-default), divider-hover-color under the pointer (--border-strong) and divider-active-color while dragging (--interactive-primary-bg). Every part carries a data-slot (resizable-split, -start, -divider, -end), and the root carries data-dragging during a drag.
Installation
npx visor add resizable-splitAPI Reference
ResizableSplitProps
| Prop | Type | Default | Description |
|---|---|---|---|
children* | [ReactNode, ReactNode] | — | The two panes: start (left), then end (right). |
size | number | — | The start pane's width in px. Controlled. |
defaultSize | number | — | The start pane's first width in px when uncontrolled. Without it the panes start equal. |
onSizeChange | (size: number) => void | — | The start pane's new width in px, while dragging and on every key step. Persist it here. |
minStart | number | 0 | The start pane's minimum width in px. |
minEnd | number | 0 | The end pane's minimum width in px. |
step | number | 16 | px per arrow key press. Shift + arrows step four times this. |
dividerLabel | string | "Resize panes" | The divider's accessible name. |
The component also accepts all standard HTML attributes for the root element.