# Resizable

Resize panels side by side or one above the other by dragging the handle between them or with the keyboard.

A list beside the message it opens

[Complete TSX file](/examples/resizable/default.tsx)

```tsx
"use client";

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/siteplane/components/resizable";

const threads = [
  { name: "Maya Chen", subject: "Q3 roadmap review" },
  { name: "Leo Park", subject: "Invoice for October" },
  { name: "Ana Ruiz", subject: "Onboarding checklist" },
  { name: "Sam Okafor", subject: "Design sync notes" },
];

export default function Example() {
  return (
    <div className="h-64 w-full max-w-xl overflow-hidden rounded-lg border-(length:--sp-rw-border-default) border-(--sp-rw-surface-edge)">
      <ResizablePanelGroup>
        <ResizablePanel defaultSize="40%" minSize="25%">
          <ul className="grid gap-3 p-4">
            {threads.map((thread) => (
              <li className="grid gap-0.5" key={thread.name}>
                <span className="truncate font-medium text-sm">
                  {thread.name}
                </span>
                <span className="truncate text-muted-foreground text-xs">
                  {thread.subject}
                </span>
              </li>
            ))}
          </ul>
        </ResizablePanel>
        <ResizableHandle />
        <ResizablePanel defaultSize="60%" minSize="40%">
          <article className="grid gap-2 p-4">
            <h3 className="font-medium text-sm">Q3 roadmap review</h3>
            <p className="text-muted-foreground text-sm">
              The review moves to Thursday at 10:00. Bring the three goals for
              your team and the open questions from last week.
            </p>
          </article>
        </ResizablePanel>
      </ResizablePanelGroup>
    </div>
  );
}
```

## Installation

Complete [one-time setup](/docs/installation/) first.

```bash
pnpm dlx shadcn@4.18.0 add @siteplane/resizable
```

With npm: `npx shadcn@4.18.0 add @siteplane/resizable`. [Registry JSON](/registry/resizable.json) lists source files and dependencies.

For this page’s examples, also install:

```bash
pnpm dlx shadcn@4.18.0 add @siteplane/button
```

## Usage

```tsx
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/siteplane/components/resizable";

<div className="h-64">
  <ResizablePanelGroup>
    <ResizablePanel defaultSize="40%">Inbox</ResizablePanel>
    <ResizableHandle />
    <ResizablePanel defaultSize="60%">Message</ResizablePanel>
  </ResizablePanelGroup>
</div>;
```

The group fills its container, so give the container a height. Put a `ResizableHandle` between every two panels.

## Vertical

`orientation="vertical"` stacks the panels one above the other, and the handle between them is a horizontal line.

A view above its console

[Complete TSX file](/examples/resizable/vertical.tsx)

```tsx
"use client";

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/siteplane/components/resizable";

export default function Example() {
  return (
    <div className="h-64 w-full max-w-xl overflow-hidden rounded-lg border-(length:--sp-rw-border-default) border-(--sp-rw-surface-edge)">
      <ResizablePanelGroup orientation="vertical">
        <ResizablePanel defaultSize="65%" minSize="30%">
          <div className="grid gap-2 p-4">
            <h3 className="font-medium text-sm">Release notes</h3>
            <p className="text-muted-foreground text-sm">
              Teams can now share dashboards with guests. Guests see the
              dashboard and its comments, and nothing else in the workspace.
            </p>
          </div>
        </ResizablePanel>
        <ResizableHandle />
        <ResizablePanel defaultSize="35%" minSize="20%">
          <div className="grid gap-1 p-4 font-mono text-muted-foreground text-xs">
            <span>Build started</span>
            <span>Checked 128 files</span>
            <span>Build finished in 4.2 s</span>
          </div>
        </ResizablePanel>
      </ResizablePanelGroup>
    </div>
  );
}
```

## Collapsible

A `collapsible` panel collapses when it is dragged past its `minSize`, to its `collapsedSize` (0 by default), and opens again when it is dragged out. With the handle focused, Enter collapses the panel before it and brings it back at its last size. A double click on a handle resets the panel before it to its `defaultSize`, or the panel after it when only that one has a `defaultSize`. A panel at 0 px takes its content out of the Tab order and the accessibility tree until it opens again.

A project list that collapses

[Complete TSX file](/examples/resizable/collapsible.tsx)

```tsx
"use client";

import { Button } from "@/siteplane/components/button";
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/siteplane/components/resizable";

const projects = ["Website", "Mobile app", "Billing", "Data platform"];

export default function Example() {
  return (
    <div className="h-64 w-full max-w-xl overflow-hidden rounded-lg border-(length:--sp-rw-border-default) border-(--sp-rw-surface-edge)">
      <ResizablePanelGroup>
        <ResizablePanel
          collapsible
          defaultSize={200}
          maxSize="50%"
          minSize={160}
        >
          <nav aria-label="Projects" className="grid gap-1 p-2">
            {projects.map((project) => (
              <Button
                align="start"
                key={project}
                render={<a href={`#${project}`} />}
                variant="ghost"
                width="full"
              >
                {project}
              </Button>
            ))}
          </nav>
        </ResizablePanel>
        <ResizableHandle />
        <ResizablePanel minSize="50%">
          <div className="grid gap-2 p-4">
            <h3 className="font-medium text-sm">Website</h3>
            <p className="text-muted-foreground text-sm">
              Twelve open tasks, three of them due this week.
            </p>
          </div>
        </ResizablePanel>
      </ResizablePanelGroup>
    </div>
  );
}
```

## Sizes

A number sets a size in pixels, `defaultSize={200}`, and a string without a unit a percentage of the group, `defaultSize="30%"` or `defaultSize="30"`. `rem`, `em`, `vh` and `vw` work as strings too. A panel without `defaultSize` shares the room that the others leave. `minSize` and `maxSize` keep a panel between two sizes as the group or the pointer changes it.

## Handle

The handle is a line at rest, the hairline that divides two panels of one surface. Under the pointer and while it drags, a soft 3 px band in the muted fill takes its place. Its grab area reaches 8 px across the line under a mouse and 20 px under a finger, and the cursor shows the direction it moves in. With the keyboard focus, the kit's focus ring stands inside the handle, so it reads as one bar along the edge; a press or a drag never shows it. A resizable [SidebarRail](/docs/components/sidebar/#icon-collapse-and-resize-rail) is the same handle on the edge of a sidebar.

## Keyboard

Tab moves to each handle, a separator whose value is the size of the panel before it as a percentage of the group.

| Key                      | Action                                                       |
| ------------------------ | ------------------------------------------------------------ |
| ArrowLeft and ArrowRight | Move a handle between panels side by side by 5% of the group |
| ArrowUp and ArrowDown    | Move a handle between panels one above the other by 5%       |
| Home and End             | Move the handle to the smallest and the largest size         |
| Enter                    | Collapse or restore a collapsible panel before the handle    |
| F6 and Shift+F6          | Move the focus to the next or the previous handle            |

## API reference

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| ResizablePanelGroup.orientation | horizontal \| vertical | horizontal | horizontal sets the panels side by side, vertical one above the other. |
| ResizablePanelGroup.onLayoutChanged | (layout, meta) => void | unset | Called with the size of every panel, in percent by its id, once a drag ends or a key moves a handle. Save the layout from here. |
| ResizablePanelGroup.defaultLayout | Record<string, number> | unset | The sizes in percent by panel id that the group starts with, such as a saved layout. |
| ResizablePanelGroup.resizeTargetMinimumSize | { coarse: number; fine: number } | { coarse: 20, fine: 8 } | The grab area of a handle in px, under a finger and under a mouse or a pen. |
| ResizablePanel.defaultSize | number \| string | unset | The size it starts with: a number in px, a string without a unit in percent of the group. |
| ResizablePanel.minSize / maxSize | number \| string | 0% / 100% | The smallest and the largest size a drag or a key gives the panel. |
| ResizablePanel.collapsible | boolean | false | Collapses to collapsedSize past its minSize, and with Enter on the handle after it. |
| ResizablePanel.collapsedSize | number \| string | 0% | The size of the collapsed panel. |
| ResizablePanel.id | string | generated | Names the panel in a layout and in the aria-controls of its handle. Give it one when you save the layout. |
| ResizablePanel.className / style | string / CSSProperties | unset | Reach the panel's content box, which fills the panel and scrolls content taller or wider than it. |
| ResizableHandle.aria-label | string | Resize panels | The name of the handle, the resizable.handle message by default. Name it after the panel before it, such as Resize inbox, or pass aria-labelledby. |
| ResizableHandle.disabled | boolean | false | Takes the handle out of the Tab order and stops its drag and its keys. |
| ResizableHandle.disableDoubleClick | boolean | false | Leaves the double click without a reset. |

The parts are the `Group`, `Panel` and `Separator` of [react-resizable-panels](https://react-resizable-panels.vercel.app/), and their other props, refs and the imperative APIs of `usePanelRef` and `useGroupRef` follow it. `ResizablePanelGroup` carries `data-orientation`, and a handle carries `data-separator`, `inactive`, `hover`, `active` while it drags, `focus` or `disabled`.

[Read the installed source](/source/resizable).

## Usage notes

react-resizable-panels sets the page's cursor while the pointer is in a grab area or drags a handle. In a right-to-left page the drag and the arrow keys of a horizontal group still follow the left-to-right direction. For the navigation of an application, use [Sidebar](/docs/components/sidebar/) with a resizable `SidebarRail`.
