Resizable
Resizable panels with draggable handles for flexible layouts.
Installation
npm i @radix-ui/react-resizableUsage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
export function ResizableDemo() {
return (
<ResizablePanelGroup
direction="horizontal"
className="min-h-[200px] max-w-md rounded-lg border"
>
<ResizablePanel defaultSize={50}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Panel One</span>
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={50}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Panel Two</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
)
}Examples
Vertical Layout
Multiple Panels
Props
| Component | Props | Description |
|---|---|---|
| ResizablePanelGroup | ResizablePrimitive.PanelGroupProps direction?: "horizontal" | "vertical" onLayout?: (sizes: number[]) => void | The container for resizable panels that controls orientation. |
| ResizablePanel | ResizablePrimitive.PanelProps defaultSize: number minSize?: number maxSize?: number | An individual panel that can be resized. |
| ResizableHandle | ResizablePrimitive.PanelResizeHandleProps withHandle?: boolean | The draggable handle between panels used for resizing. |