Resizable Panels
ProNewTwo 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
| Prop | Type | Default |
|---|---|---|
| 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" |
| defaultSize | numberThe first panel's share of the space, in percent. | 50 |
| min | numberThe smallest and largest share the first panel can take, in percent. | 20 |
| max | number | 80 |
| onSizeChange | (size: number) => voidRuns when a drag ends or a key changes the size. | — |
| label | stringAccessible name of the divider. | "Resize panels" |
| className | string | — |
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.