Resizable
Panels that people resize by dragging a handle. The handle is a 1px line with an optional 12 × 16px grip and a 44px hit area.
Installation
npx shadcn@latest add @sevenone/resizableUsage
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"Examples
Default
One
Two
Three
<ResizablePanelGroup orientation="horizontal" className="max-w-md rounded-lg border">
<ResizablePanel defaultSize="50%">
<div className="flex h-[200px] items-center justify-center p-6">One</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize="50%">
<ResizablePanelGroup orientation="vertical">
<ResizablePanel defaultSize="25%">
<div className="flex h-full items-center justify-center p-6">Two</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize="75%">
<div className="flex h-full items-center justify-center p-6">Three</div>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>With a grip
withHandle shows the grip, so people can see where to drag.
Sidebar
Content
<ResizablePanelGroup orientation="horizontal" className="min-h-[200px] max-w-md rounded-lg border">
<ResizablePanel defaultSize="25%">
<div className="flex h-full items-center justify-center p-6">Sidebar</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="75%">
<div className="flex h-full items-center justify-center p-6">Content</div>
</ResizablePanel>
</ResizablePanelGroup>Accessibility
- Each handle is a focusable separator: arrow keys resize the panels, and screen readers read the size.
- The handle has a 44px hit area, so keep at least 24px of padding inside the panels next to it.
- A double-click resets the panels to their default size, so dragging is not the only way to change them.
- When a size matters, also offer a button or a menu that sets it.