Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Resizable for Astro

Astro panels with pointer and keyboard size controls.

API Reference
Panel ADrag the handle to resize.
Panel BArrow keys resize the focused handle.

Installation

bunx --bun shadcn@latest add @gnostic/resizable

Usage

---
import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
---
<ResizablePanelGroup class="h-48 w-full rounded-lg border">
  <ResizablePanel defaultSize={50} minSize={20}>
    <div class="flex h-full items-center justify-center p-6">One</div>
  </ResizablePanel>
  <ResizableHandle />
  <ResizablePanel defaultSize={50} minSize={20}>
    <div class="flex h-full items-center justify-center p-6">Two</div>
  </ResizablePanel>
</ResizablePanelGroup>

Composition

Place one ResizableHandle between each pair of panels. Sizes are percentages of the group. Give the group a height.

ResizablePanelGroup
├── ResizablePanel
├── ResizableHandle
└── ResizablePanel

Examples

Vertical

Set direction="vertical" to stack the panels. The handle moves up and down.

Panel ADrag the handle to resize.
Panel BUp and down arrow keys resize this group.

Custom handle

Add a custom handle by passing a direct child to ResizableHandle.

Panel ADrag the custom handle to resize.
Panel BArrow keys resize the focused panel.

Nested groups

A panel can contain another group. Use withHandle to show a grip on the separator.

One
Two
Three

Collapsible panel

Set collapsible on a panel to let it collapse past minSize. Focus the handle and press Enter to collapse and expand that panel. Arrow keys resize by 10 percent. Home and End move to the limits.

Sidebar
ContentFocus the handle and press Enter to collapse the sidebar.

Snap points

Set snapPoints on a handle to give the panel before it a set of widths or heights. Each number is a percentage of the whole group. Release a drag to select the nearest size that both adjacent panels allow. A tie selects the smaller size. Use the arrow keys to move between stops. Home and End still move to the panel limits.

Files

Editor

Drag the divider or use the arrow keys to set the file list to 25%, 50%, or 75%.

API Reference

ResizablePanelGroup, ResizablePanel, and ResizableHandle accept native div attributes.

ResizablePanelProps

PropType
defaultSize?number

Initial size as a percentage of the group. Panels without a size share the remaining space.

Typenumber
minSize?number

Minimum size as a percentage.

Typenumber
Default0
maxSize?number

Maximum size as a percentage.

Typenumber
Default100
collapsible?boolean

Allow this panel to collapse past `minSize`. Press Enter on the preceding handle to collapse and expand it.

Typeboolean
Defaultfalse
collapsedSize?number

Size as a percentage when the panel is collapsed. This value must not exceed `minSize`.

Typenumber
Default0

ResizableProps

PropType
direction?ResizableDirection

Layout axis for the panels. `horizontal` places panels side by side. `vertical` stacks the panels.

TypeResizableDirection
Default"horizontal"
keyboardResizeBy?number

Percent added or removed for each arrow key press. Shift with an arrow key moves to the limit.

Typenumber
Default10

ResizableHandleProps

PropType
snapPoints?readonly number[]

Optional sizes for the panel before this handle, as percentages of the group. Release a drag to select the nearest available size. Arrow keys select the previous or next size. Both adjacent panels must allow that size.

Typereadonly number[]
withHandle?boolean

Show a grip in the center of the handle.

Typeboolean
Defaultfalse

Events

Dispatch these events on the resizable group root. The root emits the outbound events. The component does not store the layout.

Outbound events

Event Detail
resizable:change { layout: number[] }
resizable:dragging { dragging: boolean }

Inbound events

Event Detail
resizable:set { layout: number[] }

See the data-slot docs for keyboard behavior and the controller API.

Read the installed source for the component source.

When to use Resizable

Compose panels and resize handles inside a ResizablePanelGroup. Choose an orientation and useful size bounds so neither panel becomes unusable. Keep the panel content independent of its starting size.

Keyboard and behavior

The existing data-slot controller handles pointer and keyboard resizing. Give each handle a useful label and test its arrow-key behavior. A panel that contains a form must still expose all controls at its minimum size.

Theme and layout

The handle uses shared border and focus colors. Check content overflow after a resize and at narrow viewport widths. Some layouts are clearer when panels stack instead of remaining resizable on a phone.