The Resizable component allows you to create accessible panel groups with keyboard support. It consists of three main parts:
ResizablePanelGroup: The container for the panels. Use the direction prop to specify if the layout is horizontal or vertical.ResizablePanel: An individual panel within the group. Use the defaultSize prop (percentage) to set its initial width or height.ResizableHandle: The interactive element between panels that allows users to resize them.
Import these components from your local UI directory.
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from '@/components/ui/resizable'
export default function ResizableExample() {
return (
<ResizablePanelGroup
direction="horizontal"
className="rounded-base max-w-md border-2 border-border text-main-foreground shadow-shadow"
>
<ResizablePanel defaultSize={50}>
<div className="flex h-[200px] items-center justify-center bg-main p-6">
<span className="font-base">One</span>
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={50}>
<ResizablePanelGroup direction="vertical">
<ResizablePanel defaultSize={25}>
<div className="flex h-full items-center justify-center bg-main p-6">
<span className="font-base">Two</span>
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={75}>
<div className="flex h-full items-center justify-center bg-main p-6">
<span className="font-base">Three</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>
)
}