Resizable
Resizable React panels built on shadcn/ui and react-resizable-panels v4: drag or keyboard-resize split views with a handle that turns mint while you drag it, plus an IDE-style layout block with a collapsible sidebar that tweens into an icon rail.
- Drop-in shadcn API
- react-resizable-panels v4
- Keyboard resizing
- Collapsible panels
- Clear drag state
1import { Hero } from "@/components/hero"23export default function Page() {4 return <Hero title="Ship at dusk" />5}
➜ npm run dev
▲ Next.js ready on http://localhost:3000
✓ Compiled in 412ms"use client";
import { FileCode2, FileJson, FileText, Folder, GitBranch, Search, Settings, Terminal } from "lucide-react";
import { ResizableLayout, ResizableLayoutToggle } from "@/components/dusk/resizable/resizable-layout";
import { cn } from "@/lib/utils";
const files = [
{ name: "app", icon: Folder, depth: 0 },
{ name: "page.tsx", icon: FileCode2, depth: 1, active: true },
{ name: "layout.tsx", icon: FileCode2, depth: 1 },
{ name: "package.json", icon: FileJson, depth: 0 },
{ name: "README.md", icon: FileText, depth: 0 },
];
const rail = [
{ label: "Explorer", icon: Folder },
{ label: "Search", icon: Search },
{ label: "Source control", icon: GitBranch },
{ label: "Settings", icon: Settings },
];
const code = [
["import", " { Hero } ", "from", ' "@/components/hero"'],
[""],
["export default function", " Page() {"],
[" return", " <Hero title=", '"Ship at dusk"', " />"],
["}"],
];
function Sidebar({ collapsed }: { collapsed: boolean }) {
return (
<div className="flex h-full flex-col">
<div className={cn("flex h-11 shrink-0 items-center gap-2 border-b px-2.5", collapsed && "justify-center px-0")}>
<ResizableLayoutToggle />
{!collapsed && <span className="truncate text-xs font-medium text-muted-foreground">Explorer</span>}
</div>
{collapsed ? (
<nav aria-label="Activity bar" className="flex flex-col items-center gap-1 py-2">
{rail.map(({ label, icon: Icon }) => (
<button
key={label}
type="button"
aria-label={label}
title={label}
className="inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"
>
<Icon className="size-4" aria-hidden />
</button>
))}
</nav>
) : (
<ul className="flex flex-col gap-0.5 p-2 text-sm">
{files.map(({ name, icon: Icon, depth, active }) => (
<li key={name}>
<button
type="button"
aria-current={active ? "page" : undefined}
style={{ paddingLeft: 8 + depth * 14 }}
className={cn(
"flex w-full items-center gap-2 truncate rounded-md py-1 pr-2 text-left outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50",
active ? "bg-accent text-foreground" : "text-foreground/80 hover:bg-accent hover:text-foreground"
)}
>
<Icon className="size-4 shrink-0 opacity-80" aria-hidden />
<span className="truncate">{name}</span>
</button>
</li>
))}
</ul>
)}
</div>
);
}
export default function ResizableLayoutDemo() {
return (
<div className="h-[420px] w-full max-w-3xl">
<ResizableLayout
sidebarLabel="Explorer"
sidebar={({ collapsed }) => <Sidebar collapsed={collapsed} />}
bottom={
<div className="flex h-full flex-col">
<div className="flex h-8 shrink-0 items-center gap-2 border-b px-3 text-xs text-muted-foreground">
<Terminal className="size-3.5" aria-hidden /> Terminal
</div>
<pre className="flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed text-muted-foreground">
<span className="text-primary">➜</span> npm run dev{"\n"}
{" "}▲ Next.js ready on http://localhost:3000{"\n"}
{" "}✓ Compiled in 412ms
</pre>
</div>
}
>
<div className="flex h-full flex-col">
<div className="flex h-11 shrink-0 items-center border-b px-3 text-xs">
<span className="rounded-md border border-b-0 bg-white/[0.03] px-3 py-1.5 text-foreground">page.tsx</span>
</div>
<pre className="flex-1 overflow-auto p-4 font-mono text-[0.8rem] leading-6">
{code.map((line, i) => (
<div key={i} className="flex gap-4">
<span className="w-4 shrink-0 text-right text-muted-foreground/50 select-none">{i + 1}</span>
<span>
{line.map((token, j) => (
<span
key={j}
className={j % 2 === 0 ? (token.startsWith(" ") ? "text-foreground/80" : "text-primary") : token.includes('"') ? "text-chart-4" : "text-foreground/80"}
>
{token}
</span>
))}
</span>
</div>
))}
</pre>
</div>
</ResizableLayout>
</div>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/resizable.json1. Install the dependencies.
npm install react-resizable-panels2. Copy the source into
components/ui/resizable.tsx.resizable.tsx "use client" import * as React from "react" import * as ResizablePrimitive from "react-resizable-panels" import { cn } from "@/lib/utils" /** * DuskUI Resizable — the shadcn/ui Resizable, on react-resizable-panels v4. * * Same parts and data-slot attributes as shadcn (ResizablePanelGroup, * ResizablePanel, ResizableHandle with `withHandle`), plus: * - The handle line brightens on hover and turns mint while you drag it or * while it has keyboard focus. * - The optional grip pill gets a mint border while focused or dragged. * - `orientation` (v4) is the prop; the older shadcn `direction` prop is * still accepted as an alias. * - Under `prefers-reduced-motion` colors change without easing. * Sizes follow v4 rules: numbers are pixels, strings without a unit are * percentages (`defaultSize="25"`), and "px" / "%" / "rem" / "vh" work too. * The library handles pointer and keyboard resizing (arrow keys, Home, End) * and the separator's WAI-ARIA attributes. */ function ResizablePanelGroup({ className, orientation, direction, ...props }: React.ComponentProps<typeof ResizablePrimitive.Group> & { /** @deprecated v2 name, kept for shadcn compatibility. Use `orientation`. */ direction?: "horizontal" | "vertical" }) { const resolved = orientation ?? direction ?? "horizontal" return ( <ResizablePrimitive.Group data-slot="resizable-panel-group" data-orientation={resolved} orientation={resolved} className={cn("h-full w-full", className)} {...props} /> ) } /** One resizable region. Must be a direct child of a ResizablePanelGroup. */ function ResizablePanel({ ...props }: React.ComponentProps<typeof ResizablePrimitive.Panel>) { return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} /> } /** The draggable, focusable divider between two panels. */ function ResizableHandle({ withHandle, className, ...props }: React.ComponentProps<typeof ResizablePrimitive.Separator> & { /** Show a grip pill in the middle of the line. */ withHandle?: boolean }) { return ( <ResizablePrimitive.Separator data-slot="resizable-handle" className={cn( "group/handle relative z-10 flex w-px shrink-0 items-center justify-center bg-border outline-none", // A wider invisible hit area for the pointer (the library also enforces a minimum target). "after:absolute after:inset-y-0 after:left-1/2 after:w-2 after:-translate-x-1/2", "aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full", "aria-[orientation=horizontal]:after:inset-x-0 aria-[orientation=horizontal]:after:top-1/2 aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-2 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2", "transition-colors duration-150 ease-out motion-reduce:transition-none", "data-[separator=hover]:bg-white/25", "data-[separator=focus]:bg-primary data-[separator=active]:bg-primary", "data-[separator=disabled]:opacity-50", className )} {...props} > {withHandle && ( <div aria-hidden className={cn( "relative z-10 flex h-6 w-3 shrink-0 flex-col items-center justify-center gap-[3px] rounded-full border bg-background", "shadow-xs", "transition-[border-color,background-color] duration-150 ease-out motion-reduce:transition-none", "group-aria-[orientation=horizontal]/handle:h-3 group-aria-[orientation=horizontal]/handle:w-6 group-aria-[orientation=horizontal]/handle:flex-row", "group-data-[separator=hover]/handle:border-white/25", "group-data-[separator=focus]/handle:border-primary group-data-[separator=active]/handle:border-primary" )} > {[0, 1, 2].map((dot) => ( <span key={dot} className={cn( "size-[3px] rounded-full bg-muted-foreground/70" )} /> ))} </div> )} </ResizablePrimitive.Separator> ) } export { ResizablePanelGroup, ResizablePanel, ResizableHandle }
Adds components/ui/resizable.tsx for react-resizable-panels v4. In v4 numeric sizes are pixels and strings without a unit are percentages, so write defaultSize="25" for a quarter. The group prop is orientation; the v2 direction prop is still accepted.
Usage
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/components/ui/resizable"
export function SplitView() {
return (
<ResizablePanelGroup orientation="horizontal" className="rounded-xl border">
<ResizablePanel defaultSize="30" minSize={180}>Sidebar</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel>Content</ResizablePanel>
</ResizablePanelGroup>
)
}Examples
Default
A horizontal group with a nested vertical group. The line brightens on hover; while you drag (or while the handle has keyboard focus) it turns mint and the grip pill gets a mint border.
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable";
export default function ResizableBasicDemo() {
return (
<ResizablePanelGroup orientation="horizontal" className="max-h-64 max-w-lg rounded-xl border">
<ResizablePanel defaultSize="50" minSize="20">
<div className="flex h-64 items-center justify-center p-6">
<span className="text-sm font-medium">One</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="50" minSize="20">
<ResizablePanelGroup orientation="vertical">
<ResizablePanel defaultSize="40" minSize="20">
<div className="flex h-full items-center justify-center p-6">
<span className="text-sm font-medium">Two</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize="60" minSize="20">
<div className="flex h-full items-center justify-center p-6">
<span className="text-sm font-medium">Three</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>
);
}Vertical with live sizes
orientation="vertical" stacks panels. onLayoutChange reports a map of panel id to percentage on every move — use onLayoutChanged to persist only after the pointer is released.
Preview: 35%
"use client";
import * as React from "react";
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable";
export default function ResizableVerticalDemo() {
const [preview, setPreview] = React.useState(35);
return (
<div className="w-full max-w-md space-y-2">
<ResizablePanelGroup
orientation="vertical"
className="min-h-72 rounded-xl border"
onLayoutChange={(layout) => {
const size = layout.preview;
if (typeof size === "number") setPreview(Math.round(size));
}}
>
<ResizablePanel id="editor" defaultSize="65" minSize="25">
<div className="flex h-full flex-col gap-1.5 p-4 font-mono text-xs text-muted-foreground">
<span className="text-foreground">## Release notes</span>
<span>- Drag the divider, or focus it and press ↑ / ↓.</span>
<span>- Home and End jump to the limits.</span>
</div>
</ResizablePanel>
<ResizableHandle aria-label="Resize preview" />
<ResizablePanel id="preview" defaultSize="35" minSize="15">
<div className="flex h-full items-center justify-center bg-white/[0.02] p-4 text-sm text-muted-foreground">
Preview
</div>
</ResizablePanel>
</ResizablePanelGroup>
<p className="text-center text-xs text-muted-foreground tabular-nums">Preview: {preview}%</p>
</div>
);
}Blocks
Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.
Resizable Layout
An IDE-style shell: a collapsible sidebar, a main area and an optional bottom panel. Drag the sidebar below its minimum and it snaps into an icon rail; the toggle button (or useResizableLayout().toggle) collapses and expands it with a 320 ms tween that only runs for the toggle, so dragging stays one-to-one. Pass sidebar as a function to render a different layout when collapsed.
1import { Hero } from "@/components/hero"23export default function Page() {4 return <Hero title="Ship at dusk" />5}
➜ npm run dev
▲ Next.js ready on http://localhost:3000
✓ Compiled in 412ms"use client";
import { FileCode2, FileJson, FileText, Folder, GitBranch, Search, Settings, Terminal } from "lucide-react";
import { ResizableLayout, ResizableLayoutToggle } from "@/components/dusk/resizable/resizable-layout";
import { cn } from "@/lib/utils";
const files = [
{ name: "app", icon: Folder, depth: 0 },
{ name: "page.tsx", icon: FileCode2, depth: 1, active: true },
{ name: "layout.tsx", icon: FileCode2, depth: 1 },
{ name: "package.json", icon: FileJson, depth: 0 },
{ name: "README.md", icon: FileText, depth: 0 },
];
const rail = [
{ label: "Explorer", icon: Folder },
{ label: "Search", icon: Search },
{ label: "Source control", icon: GitBranch },
{ label: "Settings", icon: Settings },
];
const code = [
["import", " { Hero } ", "from", ' "@/components/hero"'],
[""],
["export default function", " Page() {"],
[" return", " <Hero title=", '"Ship at dusk"', " />"],
["}"],
];
function Sidebar({ collapsed }: { collapsed: boolean }) {
return (
<div className="flex h-full flex-col">
<div className={cn("flex h-11 shrink-0 items-center gap-2 border-b px-2.5", collapsed && "justify-center px-0")}>
<ResizableLayoutToggle />
{!collapsed && <span className="truncate text-xs font-medium text-muted-foreground">Explorer</span>}
</div>
{collapsed ? (
<nav aria-label="Activity bar" className="flex flex-col items-center gap-1 py-2">
{rail.map(({ label, icon: Icon }) => (
<button
key={label}
type="button"
aria-label={label}
title={label}
className="inline-flex size-8 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50"
>
<Icon className="size-4" aria-hidden />
</button>
))}
</nav>
) : (
<ul className="flex flex-col gap-0.5 p-2 text-sm">
{files.map(({ name, icon: Icon, depth, active }) => (
<li key={name}>
<button
type="button"
aria-current={active ? "page" : undefined}
style={{ paddingLeft: 8 + depth * 14 }}
className={cn(
"flex w-full items-center gap-2 truncate rounded-md py-1 pr-2 text-left outline-none transition-colors focus-visible:ring-[3px] focus-visible:ring-ring/50",
active ? "bg-accent text-foreground" : "text-foreground/80 hover:bg-accent hover:text-foreground"
)}
>
<Icon className="size-4 shrink-0 opacity-80" aria-hidden />
<span className="truncate">{name}</span>
</button>
</li>
))}
</ul>
)}
</div>
);
}
export default function ResizableLayoutDemo() {
return (
<div className="h-[420px] w-full max-w-3xl">
<ResizableLayout
sidebarLabel="Explorer"
sidebar={({ collapsed }) => <Sidebar collapsed={collapsed} />}
bottom={
<div className="flex h-full flex-col">
<div className="flex h-8 shrink-0 items-center gap-2 border-b px-3 text-xs text-muted-foreground">
<Terminal className="size-3.5" aria-hidden /> Terminal
</div>
<pre className="flex-1 overflow-auto p-3 font-mono text-xs leading-relaxed text-muted-foreground">
<span className="text-primary">➜</span> npm run dev{"\n"}
{" "}▲ Next.js ready on http://localhost:3000{"\n"}
{" "}✓ Compiled in 412ms
</pre>
</div>
}
>
<div className="flex h-full flex-col">
<div className="flex h-11 shrink-0 items-center border-b px-3 text-xs">
<span className="rounded-md border border-b-0 bg-white/[0.03] px-3 py-1.5 text-foreground">page.tsx</span>
</div>
<pre className="flex-1 overflow-auto p-4 font-mono text-[0.8rem] leading-6">
{code.map((line, i) => (
<div key={i} className="flex gap-4">
<span className="w-4 shrink-0 text-right text-muted-foreground/50 select-none">{i + 1}</span>
<span>
{line.map((token, j) => (
<span
key={j}
className={j % 2 === 0 ? (token.startsWith(" ") ? "text-foreground/80" : "text-primary") : token.includes('"') ? "text-chart-4" : "text-foreground/80"}
>
{token}
</span>
))}
</span>
</div>
))}
</pre>
</div>
</ResizableLayout>
</div>
);
}$ npx shadcn@latest add https://duskui.com/r/resizable-layout.json1. Install the dependencies.
npm install motion react-resizable-panels lucide-react2. Copy the source into
components/dusk/resizable/resizable-layout.tsx.resizable-layout.tsx "use client"; import * as React from "react"; import { usePanelRef } from "react-resizable-panels"; import { useReducedMotion } from "motion/react"; import { PanelLeftClose, PanelLeftOpen } from "lucide-react"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/components/ui/resizable"; import { cn } from "@/lib/utils"; /** How long the collapse / expand tween runs, in ms. */ const TWEEN_MS = 320; type ResizableLayoutContextValue = { collapsed: boolean; toggle: () => void; sidebarId: string; }; const ResizableLayoutContext = React.createContext<ResizableLayoutContextValue | null>(null); /** Read and toggle the sidebar from anywhere inside a ResizableLayout. */ export function useResizableLayout() { const context = React.useContext(ResizableLayoutContext); if (!context) throw new Error("useResizableLayout must be used inside <ResizableLayout>."); return context; } export interface ResizableLayoutProps extends Omit<React.ComponentProps<"div">, "children"> { /** Sidebar contents. A function receives `{ collapsed }` so it can render an icon rail. */ sidebar: React.ReactNode | ((state: { collapsed: boolean }) => React.ReactNode); /** The main area. */ children: React.ReactNode; /** Optional bottom panel under the main area (a terminal, logs…), resizable vertically. */ bottom?: React.ReactNode; /** Sidebar width on first render. Strings without a unit are percentages. */ sidebarDefaultSize?: number | string; /** Narrowest the open sidebar can be dragged before it snaps shut. */ sidebarMinSize?: number | string; sidebarMaxSize?: number | string; /** Width of the collapsed icon rail. `0` hides the sidebar completely. */ collapsedSize?: number | string; /** Bottom panel height on first render, as a percentage string. */ bottomDefaultSize?: number | string; defaultCollapsed?: boolean; onCollapsedChange?: (collapsed: boolean) => void; /** Accessible name of the sidebar region. */ sidebarLabel?: string; } /** * An IDE-style layout: a collapsible sidebar, a main area and an optional * bottom panel, all resizable by pointer or keyboard (focus a divider, then * use the arrow keys, Home or End). Dragging the sidebar below its minimum * snaps it into an icon rail; the toggle button (or `useResizableLayout`) * collapses and expands it with a smooth tween. Built on the DuskUI * Resizable (react-resizable-panels v4). Under reduced motion it snaps. */ export function ResizableLayout({ sidebar, children, bottom, sidebarDefaultSize = "24", sidebarMinSize = 180, sidebarMaxSize = "40", collapsedSize = 52, bottomDefaultSize = "32", defaultCollapsed = false, onCollapsedChange, sidebarLabel = "Sidebar", className, ...props }: ResizableLayoutProps) { const sidebarId = React.useId(); const reduceMotion = useReducedMotion(); const panelRef = usePanelRef(); const groupRef = React.useRef<HTMLDivElement>(null); const tweenTimer = React.useRef<number | undefined>(undefined); const [collapsed, setCollapsed] = React.useState(defaultCollapsed); React.useEffect(() => () => window.clearTimeout(tweenTimer.current), []); const collapsedRef = React.useRef(defaultCollapsed); const handleResize = React.useCallback( () => { const next = panelRef.current?.isCollapsed() ?? false; if (next === collapsedRef.current) return; collapsedRef.current = next; setCollapsed(next); onCollapsedChange?.(next); }, [panelRef, onCollapsedChange] ); const toggle = React.useCallback(() => { const panel = panelRef.current; const group = groupRef.current; if (!panel) return; // Panels animate flex-grow only while this attribute is set, so dragging stays 1:1. if (group && !reduceMotion) { group.dataset.tween = ""; window.clearTimeout(tweenTimer.current); tweenTimer.current = window.setTimeout(() => { delete group.dataset.tween; }, TWEEN_MS + 40); } if (panel.isCollapsed()) panel.expand(); else panel.collapse(); }, [panelRef, reduceMotion]); const context = React.useMemo(() => ({ collapsed, toggle, sidebarId }), [collapsed, toggle, sidebarId]); return ( <ResizableLayoutContext.Provider value={context}> <div className={cn( "h-full w-full overflow-hidden rounded-xl border bg-background", "shadow-sm", className )} {...props} > <ResizablePanelGroup orientation="horizontal" elementRef={groupRef} className={cn( "[&[data-tween]>[data-panel]]:transition-[flex-grow]", "[&[data-tween]>[data-panel]]:duration-[320ms]", "[&[data-tween]>[data-panel]]:ease-[cubic-bezier(0.32,0.72,0,1)]" )} > <ResizablePanel id={sidebarId} panelRef={panelRef} collapsible collapsedSize={collapsedSize} defaultSize={defaultCollapsed ? collapsedSize : sidebarDefaultSize} minSize={sidebarMinSize} maxSize={sidebarMaxSize} onResize={handleResize} role="region" aria-label={sidebarLabel} data-collapsed={collapsed || undefined} className="bg-white/[0.015]" > {typeof sidebar === "function" ? sidebar({ collapsed }) : sidebar} </ResizablePanel> <ResizableHandle withHandle aria-label={`Resize ${sidebarLabel.toLowerCase()}`} /> <ResizablePanel minSize="30"> {bottom ? ( <ResizablePanelGroup orientation="vertical"> <ResizablePanel minSize="25">{children}</ResizablePanel> <ResizableHandle aria-label="Resize bottom panel" /> <ResizablePanel defaultSize={bottomDefaultSize} minSize="12" collapsible collapsedSize={0}> {bottom} </ResizablePanel> </ResizablePanelGroup> ) : ( children )} </ResizablePanel> </ResizablePanelGroup> </div> </ResizableLayoutContext.Provider> ); } /** A button that collapses / expands the sidebar. Announces its state via aria-expanded. */ export function ResizableLayoutToggle({ className, onClick, ...props }: React.ComponentProps<"button">) { const { collapsed, toggle, sidebarId } = useResizableLayout(); const Icon = collapsed ? PanelLeftOpen : PanelLeftClose; return ( <button type="button" aria-expanded={!collapsed} aria-controls={sidebarId} aria-label={collapsed ? "Expand sidebar" : "Collapse sidebar"} onClick={(event) => { onClick?.(event); if (!event.defaultPrevented) toggle(); }} className={cn( "inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground outline-none", "transition-[color,background-color,box-shadow] duration-150 hover:bg-accent hover:text-foreground", "focus-visible:ring-[3px] focus-visible:ring-ring/50", className )} {...props} > <Icon className="size-4" aria-hidden /> </button> ); }
| Prop | Type | Default | Description |
|---|---|---|---|
| sidebar | ReactNode | ({ collapsed }) => ReactNode | — | Sidebar contents; the function form can render an icon rail. |
| children | ReactNode | — | The main area. |
| bottom | ReactNode | — | Optional bottom panel under the main area (collapsible by dragging). |
| sidebarDefaultSize | number | string | "24" | Initial sidebar size. Numbers are px, unitless strings are %. |
| sidebarMinSize / sidebarMaxSize | number | string | 180 / "40" | Limits while open; dragging below the minimum collapses it. |
| collapsedSize | number | string | 52 | Width of the collapsed rail. 0 hides the sidebar. |
| defaultCollapsed / onCollapsedChange | boolean / (collapsed) => void | false | Initial state and change callback. |
| sidebarLabel | string | "Sidebar" | Accessible name of the sidebar region and its resize handle. |
| ResizableLayoutToggle | button props | — | Toggle button with aria-expanded / aria-controls wired up. |
API Reference
Same parts as shadcn/ui: ResizablePanelGroup (v4 Group), ResizablePanel (Panel) and ResizableHandle (Separator), each forwarding the react-resizable-panels v4 props.
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | On ResizablePanelGroup. `direction` is accepted as an alias. |
| defaultLayout / onLayoutChange / onLayoutChanged | Record<string, number> | — | On ResizablePanelGroup: initial and reported layouts, keyed by panel id. |
| groupRef | Ref<GroupImperativeHandle> | — | On ResizablePanelGroup: getLayout() / setLayout(). |
| defaultSize / minSize / maxSize | number | string | — | On ResizablePanel. Numbers are px; "25" or "25%" are percentages; rem / vh work too. |
| collapsible / collapsedSize | boolean / number | string | false / "0%" | On ResizablePanel: snap shut below minSize. |
| panelRef | Ref<PanelImperativeHandle> | — | On ResizablePanel: collapse(), expand(), resize(), getSize(), isCollapsed(). |
| withHandle | boolean | false | On ResizableHandle: show the grip pill. |
| disabled | boolean | false | On the group, a panel or a handle. |
Accessibility
- Each ResizableHandle is a focusable role="separator" with aria-valuenow / min / max and aria-controls, maintained by react-resizable-panels.
- Arrow keys resize from the focused handle; Home and End jump to the limits. Focus shows the same mint line as dragging.
- Give handles an aria-label ("Resize sidebar") when there are several; the layout block labels its sidebar region and handle for you.
- The sidebar toggle exposes aria-expanded and aria-controls; under prefers-reduced-motion it snaps instead of tweening.