Resizable
Panels that share one area and that the user resizes by dragging a handle or with the arrow keys.
direction
<ResizablePanelGroup direction="horizontal" />Drag the handle, or focus it and use the arrow keys.
When to use
- Master-detail views where people need more room for one side now and the other later, such as a document tree next to a viewer.
- Workspaces where the user compares two things side by side: the petition and the contestação.
- Panels whose useful width depends on the monitor, which fits our range of older and varied screens.
When not to use
- A fixed split. Use a grid or flex layout with set widths. A handle people never need is clutter.
- Content that hides and shows on demand. Use
Collapsible,SheetorDrawer. - A line between two blocks. Use Separator.
- Small screens. Panels need space. Stack the content instead.
Anatomy
| Part | Role |
|---|---|
ResizablePanelGroup |
Lays out the panels in a direction and fills its parent (h-full w-full). |
ResizablePanel |
One panel. Sizes are percentages of the group. |
ResizableHandle |
The divider between two panels. Add withHandle to show a grip. |
Always place a handle between two panels, and give the group a parent with an explicit height. Without a height the group has nothing to fill.
Examples
Horizontal
Panels side by side, with the grip so the handle is easy to find.
Vertical
Size limits
Set minSize and maxSize on every panel so neither can disappear. A collapsible panel snaps closed when dragged under its minimum.
Three panels
Handles without a grip keep a quiet look when the layout has several panels.
Content
- Name each panel with a short heading: “Documentos”, “Visualização”.
- Pick default sizes that work before the user touches anything. Most people never resize.
- Put the content people need first in the larger panel.
Do and don’t
Accessibility
- Built on
react-resizable-panels. The handle hasrole="separator"witharia-valuenow,aria-valueminandaria-valuemax, and it is focusable. - Keyboard: arrow keys resize by a step,
HomeandEndgo to the limits, andEntercollapses or expands acollapsiblepanel. - The handle has no accessible name by default. Pass
aria-label(“Redimensionar painel de documentos”) through its props. - The handle shows a focus ring on
focus-visible. - The panels keep their reading order, so assistive technology reads them first to last.
- Changing the layout does not announce anything. Do not use panel size to carry information.
Code
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@repo/ui/resizable";
<div className="h-[32rem] overflow-hidden rounded-lg border border-primary">
<ResizablePanelGroup direction="horizontal">
<ResizablePanel defaultSize={35} minSize={20} maxSize={55}>
<DocumentTree />
</ResizablePanel>
<ResizableHandle aria-label="Redimensionar documentos" withHandle />
<ResizablePanel defaultSize={65} minSize={30}>
<DocumentViewer />
</ResizablePanel>
</ResizablePanelGroup>
</div>;
Props
ResizablePanelGroup| Prop | Type | Default | Description |
|---|---|---|---|
autoSaveId | string | — | Saves the layout in localStorage under this id and restores it on the next visit |
direction | "horizontal" | "vertical" | — | `horizontal` places panels side by side, `vertical` stacks them |
onLayout | (sizes: number[]) => void | — | Called with the panel sizes (percentages) after each change |
ResizablePanel| Prop | Type | Default | Description |
|---|---|---|---|
defaultSize | number | — | Initial size as a percentage of the group. |
minSize | number | 10 | Smallest size, in percent. |
maxSize | number | 100 | Largest size, in percent. |
collapsible | boolean | false | Lets the panel snap closed when dragged below `minSize`. |
collapsedSize | number | 0 | Size in percent when collapsed. |
onResize | (size: number, prevSize: number | undefined) => void | — | Called when the panel size changes. |
id / order | string / number | — | Set both when panels render conditionally, so the group can match saved layouts. |
ResizableHandle| Prop | Type | Default | Description |
|---|---|---|---|
withHandle | boolean | false | Shows a grip icon on the divider. |
disabled | boolean | false | Blocks dragging and the keyboard. |
onDragging | (isDragging: boolean) => void | — | Called when dragging starts and stops. |
Known issues
| Issue | Effect |
|---|---|
The handle line is 1px wide, with a 4px hit area (after:w-1). |
Below the 24px minimum. The handle is hard to grab with a mouse, and harder for people with motor limits. |
The focus ring uses ring-focus, and the preset has no focus ring color (only stroke-focus). |
The ring falls back to Tailwind’s default translucent blue, not the focus token. |
| The handle has no accessible name and the grip icon has no label. | Screen readers announce an unnamed separator unless the app passes aria-label. |
ResizablePanelGroup is h-full w-full. |
A parent without a height gives a group of zero height and nothing is visible. |