suiss/ui · Component
Resizable
Panels separated by draggable handles that let users resize sections of a layout.
Resizable is an open-source component from suiss/ui for React. The @esuiss/ui CLI copies its source into your project, so you own the code.
Resizable wraps react-resizable-panels. ResizablePanelGroup lays out its children in a row or column, alternating ResizablePanel and ResizableHandle. Drag a handle, or focus it and use the keyboard, to change the size of the panels on either side. Groups can be nested to build multi-pane layouts such as an editor with a sidebar and a terminal.
The cards variant renders each panel as a rounded card with a pill-shaped grip between them. Use Resizable for user-adjustable layouts; use Sidebar for a standard collapsible app navigation.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies and add the
cnhelper:
- Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Composition
Use the following composition to build a ResizablePanelGroup:
Examples
With handle
A sidebar and content split with a minimum sidebar size. Set withHandle on ResizableHandle to show a visible grip.
Vertical
Set orientation="vertical" on the group to stack the panels. Resize them with the up and down arrow keys.
Nested
A vertical group nested inside a horizontal group to create three panes.
Cards
Set variant="cards" to render each panel as a rounded card with a pill-shaped grip. Both panels are collapsible and report their share of the space.
Cards vertical
The cards variant in a vertical orientation.
Accessibility
- Each handle has the
separatorrole witharia-valuenowandaria-orientation, and is focusable with Tab. - Arrow keys resize the adjacent panels; Home and End move the handle to its minimum and maximum.
- A panel that collapses to zero width or height becomes
inert, so its content leaves the tab order.
API Reference
ResizablePanelGroup
The container that arranges panels and handles and tracks the layout.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "cards" | "default" |
Also accepts the props of GroupProps from react-resizable-panels.
Set orientation to horizontal (default) or vertical. variant is default for flat panels with thin dividers, or cards for rounded panels with pill grips. Use onLayoutChange to read the current sizes, keyed by each panel's id. Large layout jumps, such as collapsing or expanding a panel, animate unless the user prefers reduced motion.
ResizablePanel
One resizable section of the layout.
Also accepts the props of PanelProps from react-resizable-panels.
Size panels with defaultSize, minSize and maxSize, for example "30%". Make a panel collapsible with a collapsedSize to let it collapse when dragged past its minimum. Collapsed panels expose data-empty.
ResizableHandle
The draggable divider between two panels.
| Prop | Type | Default |
|---|---|---|
withHandle | boolean | - |
Also accepts the props of SeparatorProps from react-resizable-panels.
withHandle shows a visible grip on the divider. A handle next to a collapsed panel gets data-collapsed set to start or end, and its grip appears on hover.
Each part sets a data-slot, such as resizable-panel-group, for styling. The group also exposes data-variant.