Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Resizable

Panels side by side or stacked that the user resizes by dragging the line between them or with the keyboard.

Rendered by React 19.3.1

resizable.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/resizable.json

It also adds utils. The app needs its setup first: Installation.

Usage

Put ResizablePanels in a ResizablePanelGroup with a ResizableHandle between each pair. orientation is horizontal (the default) or vertical. A panel's defaultSize, minSize and maxSize take percent ("25%") or pixels ("200px"), and a collapsible panel collapses when it is dragged small enough. Give each panel a value, its key in the group's size map, and an aria-label: the handle takes its name from the panel it resizes. withHandle draws a grip on the line. The keys, the collapse rules, the sizes in the group's value and the ARIA values come from the headless Splitter.

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

Examples

Default

A sidebar and a main panel, with the second split in two.

Its preview and code are at the top of the page.

The props follow the headless Splitter, so they differ from shadcn's in these places:

- The group's sizes are value, defaultValue and onValueChange(value, eventDetails), keyed by each panel's value, where shadcn has defaultLayout and onLayoutChange(layout) keyed by id. onValueCommitted is onLayoutChanged, and actionsRef replaces groupRef and panelRef. A panel has no onResize; read its size from the group's value. - A number in defaultSize, minSize or maxSize is a percent; strings such as "25%" and "200px" work as in shadcn. collapsedThreshold is collapseThreshold and groupResizeBehavior is resizeBehavior. - The group is a flex container on its axis and, in a vertical group, turns to a column through data-orientation. - There is no disableDoubleClick: a double click on a handle collapses or restores its panel. There is no resizePreviewMode, resizeTargetMinimumSize or disableCursor. - The handle's hit area grows to 24px under a coarse pointer, and each handle is named by its panel's aria-label.

API reference

Resizable wraps no headless component of its own: its parts are elements with classes, and their props are the element's.