Resizable

Accessible panel groups with pointer and keyboard resizing.

Installation

npx shadcn@latest add @fulldev/resizable

Usage

---
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
---

<ResizablePanelGroup class="h-48">
  <ResizablePanel defaultSize={40}>Sidebar</ResizablePanel>
  <ResizableHandle aria-label="Resize panels" />
  <ResizablePanel defaultSize={60}>Content</ResizablePanel>
</ResizablePanelGroup>

A group needs one handle between each pair of panels. Give every handle an accessible label. Drag a handle with a pointer, or focus it and use the arrow keys.

Examples

Vertical

Use direction="vertical" for rows. The handle responds to the up and down arrow keys.

Collapsible

Focus the handle and press Enter to collapse or restore the first panel. Dragging through the minimum size also collapses it.

Nested

Each group owns only its direct panels and handles, so a panel can safely contain another resizable group.

Keyboard Controls

KeyAction
Arrow keysResize by keyboardResizeBy in the group direction.
Shift + arrowResize to the available limit.
Home / EndMinimize or maximize the panel before the handle.
EnterCollapse or restore the collapsible panel before the handle.
F6 / Shift + F6Focus the next or previous handle in the group.

API Reference

ResizablePanelGroup

Resizable is an alias for ResizablePanelGroup.

PropTypeDefaultDescription
direction"horizontal" | "vertical""horizontal"Sets the layout and resize axis.
keyboardResizeBynumber10Percentage moved by an arrow keypress.

ResizablePanel

All sizes are percentages between 0 and 100.

PropTypeDefaultDescription
defaultSizenumbereven splitInitial panel size.
minSizenumber0Minimum expanded size.
maxSizenumber100Maximum size.
collapsiblebooleanfalseAllows the panel to use its collapsed size.
collapsedSizenumber0Size used while collapsed.

ResizableHandle

PropTypeDefaultDescription
withHandlebooleanfalseShows a visible grip on the separator.
disabledbooleanfalseBlocks keyboard resizing on this handle.

The root emits resizable:change with { layout: number[] } and resizable:dragging with { dragging: boolean }. Dispatch resizable:set with { layout: number[] } to set a layout from client code.

See the GitHub source code for the component source. See the data-slot docs for constraints, controller methods, and event details.