React Resizable Panels
Resizable panels for React split a layout into regions with draggable, keyboard-resizable handles, size limits and nested groups. Use Resizable panels for workspaces where people choose how much room each area gets: a file tree beside an editor, a list beside a detail pane, a console under a canvas.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/resizable.jsonFiles 50%
Editor 50%
ResizablePanelResizableHandleResizablePanelGroupdefaultResizableLabels- +2 more
Editor, preview and console
Drag a handle, or focus it and use the arrow keys. The middle pane holds a vertical group; every panel respects its minimum size.
Explorer
- App.tsx
- Deploy.tsx
- theme.css
- package.json
1import { Button, Progress } from "@sheenui/theme";23export function Deploy() {4 return (5 <Button variant="glass">Deploy</Button>6 <Progress value={72} label="Build" />7 );8}
- ✓ compiled in 142 ms
- ready on http://localhost:5173
- ⚠ Deploy.tsx: unused import Progress
Preview
import { Button } from "@/components/sheenui/button/button";
import { Progress } from "@/components/sheenui/progress/progress";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/sheenui/resizable/resizable";
// Package build (after the first npm release, or a packed tarball): import { Button, Progress, ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@sheenui/theme";
// This example also uses button, progress: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/progress.json
export function Example() {
return (
<ResizablePanelGroup className="glass-1 h-[22rem] w-full rounded-sheen-xl text-xs">
<ResizablePanel defaultSize={22} minSize={14}>
<p className="p-3 font-semibold">Explorer</p>
<ul className="m-0 list-none p-1.5">
<li className="rounded-sheen-sm bg-sheen-hover px-2 py-1.5">App.tsx</li>
<li className="px-2 py-1.5">Deploy.tsx</li>
<li className="px-2 py-1.5">theme.css</li>
</ul>
</ResizablePanel>
<ResizableHandle withGrip />
<ResizablePanel defaultSize={50}>
<ResizablePanelGroup orientation="vertical">
<ResizablePanel defaultSize={62} minSize={25}>
<pre className="m-0 p-3 leading-5">{"export function Deploy() {\n return <Button>Deploy</Button>;\n}"}</pre>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel minSize={15}>
<ul className="m-0 list-none p-3 leading-5">
<li>✓ compiled in 142 ms</li>
<li>ready on http://localhost:5173</li>
</ul>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
<ResizableHandle withGrip />
<ResizablePanel minSize={18}>
<div className="m-3 flex flex-col gap-4 rounded-sheen-lg bg-sheen-hover p-4">
<Progress value={72} label="Build" />
<Button variant="glass" size="sm" className="self-start">Deploy</Button>
</div>
</ResizablePanel>
</ResizablePanelGroup>
);
}Files to copy
4 folders · 5 files · 4 packages
- From
theme/src/ components/resizable/hooks/{use-direction.ts, use-latest.ts}lib/{cn.ts, form.ts, math.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/resizable.jsonRegistry item: resizable. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/button/components/progress/components/spinner/hooks/{use-magnetic.ts, use-media-query.ts, use-preferences.ts}motion/{gate.ts, tokens.ts}lib/state-light.tsx
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/progress.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Controlled and remembered
Pass layout and onLayoutChange to own the sizes, for example to save them in localStorage and restore them on the next visit. The sizes are percentages that add up to 100.
Sidebar: 30%
Content: 70%
import { useEffect, useState } from "react";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/sheenui/resizable/resizable";
// Package build (after the first npm release, or a packed tarball): import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@sheenui/theme";
const KEY = "my-app:layout";
export function Example() {
const [layout, setLayout] = useState<number[]>(() => {
try {
const saved = localStorage.getItem(KEY);
return saved ? (JSON.parse(saved) as number[]) : [30, 70];
} catch {
return [30, 70];
}
});
useEffect(() => {
try {
localStorage.setItem(KEY, JSON.stringify(layout));
} catch {
/* private mode: the layout just resets next visit */
}
}, [layout]);
return (
<ResizablePanelGroup layout={layout} onLayoutChange={setLayout} className="h-48 rounded-sheen-lg border border-sheen-border">
<ResizablePanel minSize={15} maxSize={60}>
<p className="p-4 text-sm">Sidebar: {Math.round(layout[0] ?? 0)}%</p>
</ResizablePanel>
<ResizableHandle withGrip />
<ResizablePanel>
<p className="p-4 text-sm">Content: {Math.round(layout[1] ?? 0)}%</p>
</ResizablePanel>
</ResizablePanelGroup>
);
}ResizablePanelGroup props
ResizableLabels keys and English defaults (3)
ResizablePanel props
ResizableHandle props
All exports on this page
ResizableHandle— The draggable divider between two panels of a ResizablePanelGroup.ResizablePanel— One panel of a ResizablePanelGroup.ResizablePanelGroup— Panels with draggable, keyboard-resizable handles between them: a file tree next to an editor, a list next to a detail pane, a console under a canvas.defaultResizableLabels— The English ResizableLabels used when labels is omitted; a partial labels prop is merged over it.
Keyboard
Accessibility
- Each handle is a role="separator" (the ARIA window splitter pattern) with aria-orientation, aria-valuenow (percent of the panel before it), aria-valuemin, aria-valuemax and aria-controls, named by labels.resize.
- Every drag has a keyboard equivalent; the grab area is 44px on touch screens and works with mouse, touch and pen.
- Panels never shrink below minSize or grow past maxSize, so content is not lost. In right-to-left pages the arrow keys and the drag follow the reading direction.
- Resizing follows the pointer directly; there is no animation, so reduced motion changes nothing.
When to use the resizable panels
- Use Resizable for an IDE-style workspace, an email client or a log viewer, where people drag a handle (or press the arrow keys) to choose how much room each area gets.
- Put ResizablePanel children in a ResizablePanelGroup with a ResizableHandle between each pair. Set minSize and maxSize so a panel never collapses past usefulness.
- Own the sizes with layout and onLayoutChange when you want to save them in localStorage or a user setting and restore them later.
- Skip it for a fixed two-column layout. CSS grid is lighter when nobody needs to resize.
- Pair it with ScrollArea inside each panel, with a vertical group nested in a horizontal one for editor layouts, and with Drawer for the phone version.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .