StealThis .dev

Resizable Panels

Draggable split panels — horizontal and vertical resize, with min/max constraints, collapse/expand, and a multi-panel layout.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Resizable Panels

Draggable split-panel layouts with horizontal and vertical orientations, min/max size constraints, and double-click collapse. Three demos show common IDE-style and dashboard layouts.

Variants

  • Horizontal two-panel — left sidebar | main content
  • Vertical two-panel — top pane | bottom pane
  • Three-panel — left | center | right

How it works

  1. Panels use display: flex with flex-basis as the sizing unit
  2. mousedown / touchstart on a resize handle begins tracking pointer position
  3. mousemove / touchmove updates the adjacent panels’ flex-basis values in real time
  4. A minimum size of 80px is enforced on each panel; the max is the container width minus the opposing minimum
  5. mouseup / touchend ends the drag and fires a resize event on the container

Collapse / expand

Double-clicking a handle collapses the left (or top) panel to 0px and saves the previous size. A second double-click restores it. Collapsed panels show a thin strip that remains draggable.