Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Resizable Panels

ProNew

Two panels with a divider you can drag, nestable in both directions. Dragging writes to a CSS variable, not to state.

Installation

pnpm dlx shadcn@latest add @viewport/resizable-panels

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
children*[React.ReactNode, React.ReactNode]

Exactly two panels: the one that is sized, then the one that takes the rest.

—
direction"horizontal" | "vertical"

`horizontal` puts the panels side by side; `vertical` stacks them.

"horizontal"
defaultSizenumber

The first panel's share of the space, in percent.

50
minnumber

The smallest and largest share the first panel can take, in percent.

20
maxnumber80
onSizeChange(size: number) => void

Runs when a drag ends or a key changes the size.

—
labelstring

Accessible name of the divider.

"Resize panels"
classNamestring—

Accessibility

  • The divider is a focusable separator with its current, smallest and largest values.
  • Arrow keys resize, Shift takes larger steps, Home and End go to the limits, Enter resets.
  • A 12px hit area around a 1px line.
  • Works in right-to-left layouts.