Examples
Side-by-side panels
Drag the separator or use arrow keys to resize the primary panel.
Projects
Choose a project from the list.
Project details
The detail pane grows with the remaining space.
Workspace panel splitter
import { Splitter } from "@phuctech/ui/components/splitter";
export function Example() {
return <Splitter label="Workspace panels" defaultValue={38} className="h-64 rounded-xl border border-border" primary={<div className="h-full min-w-0 bg-muted p-4"><h3 className="font-medium">Projects</h3><p className="mt-2 text-sm text-muted-foreground">Choose a project from the list.</p></div>} secondary={<div className="h-full min-w-0 p-4"><h3 className="font-medium">Project details</h3><p className="mt-2 text-sm text-muted-foreground">The detail pane grows with the remaining space.</p></div>} />;
}
Stacked panels
Vertical orientation places the separator between top and bottom panels.
Vertical editor splitter
import { Splitter } from "@phuctech/ui/components/splitter";
export function Example() {
return <Splitter label="Editor panels" orientation="vertical" defaultValue={60} className="h-80 rounded-xl border border-border" primary={<div className="min-h-0 bg-muted p-4">Editor</div>} secondary={<div className="min-h-0 p-4">Terminal</div>} />;
}
Collapse a panel
Double-click the handle to switch the primary panel between its minimum and maximum size.
Collapsible inspector splitter
import { Splitter } from "@phuctech/ui/components/splitter";
export function Example() {
return <Splitter label="Inspector panels" defaultValue={35} minSize={20} maxSize={80} collapsible className="h-64 rounded-xl border border-border" primary={<div className="h-full bg-muted p-4">Inspector</div>} secondary={<div className="h-full p-4">Canvas</div>} />;
}
Stack at narrow widths
A horizontal splitter stacks its panels when the component container is under 640px wide.
Responsive splitter that stacks in a narrow container
import { Splitter } from "@phuctech/ui/components/splitter";
export function Example() {
return <Splitter label="Responsive workspace panels" responsive defaultValue={45} className="h-64 rounded-xl border border-border" primary={<div className="h-full bg-muted p-4">Navigation panel</div>} secondary={<div className="h-full p-4">Content panel</div>} />;
}
Try the splitter
Inspect bounded panel sizes and the keyboard separator.
Splitter property playground
import { Splitter } from "@phuctech/ui/components/splitter";
export function Example() {
return <Splitter label="Content panels" defaultValue={50} minSize={25} maxSize={75} className="h-64 rounded-xl border border-border" primary={<div className="h-full bg-muted p-4">Navigation pane</div>} secondary={<div className="h-full p-4">Content pane</div>} />;
}
Usage
import { Splitter } from "@phuctech/ui/components/splitter";
<Splitter label="Workspace panels" primary={<Navigation />} secondary={<Editor />} />Interaction
Horizontal orientation places panels side by side; vertical orientation stacks them. Set responsive on a horizontal splitter to stack it when its container becomes narrower than 640px; a ResizeObserver tracks the container so nested layouts respond to their available space. The separator supports pointer dragging, orientation-specific arrow keys, Home/End for the configured bounds, and optional double-click collapse to the minimum/maximum. Values are percentages of the available primary axis; give the parent a measurable width or height. Keep headers and independent actions inside the panel content, and use each panel's own bounded scroll region for long content.
API
Accessibility
The handle is a labeled separator exposing its value bounds and current value. Arrow keys resize along the split axis, while Home/End reach the bounds. Pointer input is not the only interaction path.