Elastic Split Workspace
A multi-column drag-to-split panel workspace whose dividers have spring feedback; panels collapse to a thin strip in one click and the neighbouring panels reflow elastically.
This is a WebberUI Pro component
Free during the launch campaign: sign up or sign in, then hit “Copy install command” in the preview above and it installs straight away — no payment, no credit card. The command below returns 401 while you are signed out.
npx shadcn@latest add "https://webberui.com/r/elastic-split-workspace.json?t=<install token>"Playground
Tune the props live — the code snippet updates as you go, so you can dial in the look you want before copying it.
<ElasticSplitWorkspace />
Installation
npx shadcn@latest add "https://webberui.com/r/elastic-split-workspace.json?t=<install token>"Or, once registries are configured in components.json, install it as @webberui/elastic-split-workspace.
Usage
Declare each column with SplitPanel; the workspace inserts a draggable divider between adjacent panels automatically:
import {
ElasticSplitWorkspace,
SplitPanel,
} from "@/components/ui/elastic-split-workspace";
<ElasticSplitWorkspace className="h-[320px]">
<SplitPanel id="nav" title="Navigation" defaultSize={22} minSize={14} collapsible>
{/* sidebar content */}
</SplitPanel>
<SplitPanel id="main" title="Main" defaultSize={56}>
{/* main content */}
</SplitPanel>
<SplitPanel id="aside" title="Properties" defaultSize={22} collapsible>
{/* inspector content */}
</SplitPanel>
</ElasticSplitWorkspace>;- Drag a divider to adjust the ratio of the adjacent panels; dragging past the minimum meets rubber-band resistance and springs back on release.
- A
collapsiblepanel gets a collapse button in its title row; once collapsed it becomes a clickable thin strip to expand, and the neighbouring panels reflow immediately with an elastic width animation. - Pass
direction="vertical"to split into rows (top and bottom) instead.
Props
ElasticSplitWorkspace
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | The set of panels; children must be SplitPanel elements |
direction | "horizontal" | "vertical" | "horizontal" | Split direction: horizontal columns or vertical rows |
onPanelCollapse | (id: string, collapsed: boolean) => void | — | Fires when a panel collapses or expands |
aria-label | string | "分割工作區" | Accessible label for the workspace |
className | string | — | Appended to the frame's className |
SplitPanel
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | — | Unique identifier for the panel |
defaultSize | number | 1 | Initial ratio (a relative weight; panels divide the remaining space in proportion) |
minSize | number | 10 | Minimum size (as a percentage of the workspace, 0–100) |
collapsible | boolean | false | Whether it can collapse to a thin strip in one click |
collapsedSize | number | 48 | Pixel width (horizontal) or height (vertical) of the collapsed strip |
defaultCollapsed | boolean | false | Whether it starts collapsed |
title | ReactNode | — | Title, shown in the panel header and on the collapsed strip |
icon | ReactNode | — | Small icon next to the title |
className | string | — | Appended to the panel container's className |
How it works
- Spring physics: panel widths track the pointer instantly while dragging a divider; past a panel's
minSizeboundary a rubber-band damping applies, and on release a spring brings it back to a legal boundary. - Elastic reflow: panels transition
flex-growandflex-basiswith springs, so when one panel collapses to a strip the adjacent expanded panels continuously take up the released space, producing a live reflow. - Ratios are preserved: expanding a panel after collapsing it returns to the ratio it had before, rather than resetting.
- Measurement: dragging measures the actual pixel sizes of the two adjacent panels and converts them into weights, so only that pair is adjusted and the other panels are untouched.
Accessibility
- Each divider is a
role="separator"witharia-orientationandaria-valuenow / valuemin / valuemax, focusable withTab. - With a divider focused,
←→resize step by step in the horizontal direction and↑↓in the vertical. - The collapse / expand buttons are native
<button>s witharia-labeland full keyboard support. - The panels on either side of a collapsed strip are clickable buttons — the whole strip expands it.
- With "reduce motion" enabled, the spring transitions become instant changes; functionality and structure are entirely unchanged.
Miller Column Browser
A Finder-style Miller-column hierarchy browser: every level you descend springs a new column in from the right, the whole row pans smoothly once it overflows, and breadcrumbs highlight the current path in step.
Zen Mode Shell
A focus-mode shell: one click and the sidebar, top bar, and auxiliary panel fade out and slide away in timeline order while the main content eases back to center and scales up; exiting reverses the choreography and restores the whole shell.