Split pane
Two panes and a divider to drag or move with the arrows. Size controlled or not.
import { SplitPane } from "@forgeron/ui";List, 240px
Detail. Drag the divider, or focus it and use the arrows.
import { SplitPane } from "@forgeron/ui";
import { useState } from "react";
const pane = { padding: 16, color: "var(--ink-muted)", font: "13px var(--font-sans)" } as const;
export default function Sidebar() {
const [size, setSize] = useState(240);
return (
<div style={{ width: "min(100%, 560px)", height: 220 }}>
<SplitPane
label="Resize the list"
size={size}
onChange={setSize}
first={<div style={pane}>List, {size}px</div>}
second={<div style={pane}>Detail. Drag the divider, or focus it and use the arrows.</div>}
/>
</div>
);
}Editor
Console
import { SplitPane } from "@forgeron/ui";
const pane = { padding: 16, color: "var(--ink-muted)", font: "13px var(--font-sans)" } as const;
export default function Vertical() {
return (
<div style={{ width: "min(100%, 560px)", height: 260 }}>
<SplitPane
direction="vertical"
label="Resize the editor"
defaultSize={120}
min={80}
minSecond={80}
first={<div style={pane}>Editor</div>}
second={<div style={pane}>Console</div>}
/>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Names the divider: “Resize the sidebar”. |
first / second | ReactNode | — | The two panes. |
direction | "horizontal" | "vertical" | "horizontal" | Side by side, or one above the other. |
size / defaultSize | number | 320 | The first pane, in px. |
onChange | (size: number) => void | — | While dragging or pressing keys. |
onChangeEnd | (size: number) => void | — | Drag ended or key pressed: save it. |
min / minSecond / max | number | 160 / 160 / – | Limits in px. |
keyStep | number | 16 | An arrow moves by this; Shift ×4. Home and End go to the limits; double click resets. |
className | string | — | Extra classes. |