SplitPane

Two panes with a draggable divider. The grip swells while held, arrow keys nudge, Home and End jump to the limits, and a double click springs back. Layout.

Open playground

Editor

Drag the grip, or focus it and use the arrow keys.

Preview

Double click the grip to reset.

About

SplitPane is a React component in the Layout category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { SplitPane } from "@ashutoshswamy/smoui" and set first, defaultSize, min among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { SplitPane } from "@ashutoshswamy/smoui";

<SplitPane
  className="h-96"
  defaultSize={0.4}
  min={0.2}
  max={0.8}
  first={<Editor />}
  second={<Preview />}
/>

Props 5

first / second

The two panes. Each scrolls on its own.

ReactNode
defaultSize

Share the first pane starts with, 0 to 1.

numberdefault 0.5
min / max

Limits for the first pane's share.

numberdefault 0.2 / 0.8
direction

Vertical splits need a real height on className.

"horizontal""vertical"default "horizontal"
label

Accessible name for the divider.

stringdefault "Resize panes"