Getting Started
Components66
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Code Block
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Form
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toast
- Toggle
- Toggle Group
- Tooltip
- Trace
One
Two
Three
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
export function ResizableDemo() {
return (
<ResizablePanelGroup
orientation="horizontal"
className="max-w-sm rounded-xl border"
>
<ResizablePanel defaultSize="50%">
<div className="flex h-[200px] items-center justify-center p-6">
<span className="font-medium">One</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="50%">
<ResizablePanelGroup orientation="vertical">
<ResizablePanel defaultSize="25%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Two</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="75%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Three</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>
)
}About#
The Resizable component is built on top of react-resizable-panels by bvaughn. The handle is the engraved Separator; withHandle adds a raised grip.
Installation#
pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/resizable.json
Usage#
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"<ResizablePanelGroup orientation="horizontal">
<ResizablePanel>One</ResizablePanel>
<ResizableHandle />
<ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>Examples#
Vertical#
Use the orientation prop to set the orientation of the panel group.
Header
Content
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
export function ResizableVertical() {
return (
<ResizablePanelGroup
orientation="vertical"
className="min-h-[200px] max-w-sm rounded-xl border"
>
<ResizablePanel defaultSize="25%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Header</span>
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize="75%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Content</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
)
}Handle#
Use the withHandle prop on ResizableHandle to show a visible grip.
Sidebar
Content
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
export function ResizableHandleDemo() {
return (
<ResizablePanelGroup
orientation="horizontal"
className="min-h-[200px] max-w-sm rounded-xl border"
>
<ResizablePanel defaultSize="25%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Sidebar</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="75%">
<div className="flex h-full items-center justify-center p-6">
<span className="font-medium">Content</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
)
}API Reference#
See the react-resizable-panels documentation. This uses v4: Group / Separator, the orientation prop and string sizes such as defaultSize="50%".
| Part | Props / notes |
|---|---|
ResizablePanelGroup | Every Group prop (orientation, onLayoutChange, …). |
ResizablePanel | Every Panel prop (defaultSize, minSize, maxSize, collapsible, …). |
ResizableHandle | Every Separator prop, plus withHandle. Arrow keys resize when it is focused. |