Component

Resizable Layout

A flex container of panes separated by draggable dividers, using pointer events for mouse and touch. Built on the headless @refraction-ui/resizable-layout core.

Horizontal

Drag the divider to resize. Each pane is addressed by its index, and the divider sits between two panes.

Sidebar (40%)
Content (60%)

Installation

$pnpm add @refraction-ui/react-resizable-layout

Usage

tsx
import {
  ResizableLayout,
  ResizablePane,
  ResizableDivider,
} from '@refraction-ui/react'

export function MyComponent() {
  return (
    <ResizableLayout defaultSizes={[40, 60]} minSizes={[20, 20]} className="h-56">
      <ResizablePane index={0}>Sidebar</ResizablePane>
      <ResizableDivider index={0} className="w-1.5 cursor-col-resize bg-border" />
      <ResizablePane index={1}>Content</ResizablePane>
    </ResizableLayout>
  )
}

Vertical

Set orientation="vertical" to stack panes and drag vertically.

Editor
Terminal

Multiple panes & persistence

Add more panes and dividers, and pass persistKey to remember sizes across reloads via localStorage.

One
Two
Three

ResizableLayout props

PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Whether panes are arranged in a row or a column.
defaultSizesnumber[][50, 50]Initial size of each pane, as a percentage. Length must match the pane count.
minSizesnumber[]--Minimum percentage each pane may shrink to while dragging.
maxSizesnumber[]--Maximum percentage each pane may grow to while dragging.
persistKeystring--localStorage key to persist sizes across reloads.
onSizesChange(sizes: number[]) => void--Called with the new size array whenever a divider is dragged.
classNamestring--Additional CSS classes for the container.

ResizablePane props

PropTypeDefaultDescription
indexnumber--Zero-based position of the pane in the layout. Required.
classNamestring--Additional CSS classes for the pane.

ResizableDivider props

PropTypeDefaultDescription
indexnumber--Index of the divider, sitting between pane[index] and pane[index + 1]. Required.
classNamestring--Additional CSS classes for the draggable handle.