View fulldotdev/ui on GitHub

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 direction="horizontal">
  <ResizablePanel>One</ResizablePanel>
  <ResizableHandle />
  <ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>

A group needs one handle between each pair of panels. Sizes are percentages, such as defaultSize={50}. Each group owns only its direct panels and handles, so a panel can contain another group.

Composition

ResizablePanelGroup
├── ResizablePanel
├── ResizableHandle
└── ResizablePanel

Vertical

Use direction="vertical" for vertical resizing.

Handle

Use the withHandle prop on ResizableHandle to show a visible handle.

RTL

Collapsible

Add collapsible and collapsedSize to a panel. Focus the handle and press Enter to collapse or restore the panel before it. Dragging through minSize also collapses it.

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

Source: src/components/ui/resizable

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 Data Slot docs for constraints and controller methods.