Searching Puzzle Pieces

Type to search Puzzle Pieces.

Split Panel

A resizable pane group — horizontal or vertical, any number of panes. It is a compound family that wraps the @magic-spells/split-panel web component, so the flex geometry, the pointer and keyboard resizing, the min/max constraint folding, the snap points, the localStorage persistence and the separator ARIA all come from the component rather than from a hand-rolled copy in this file.

NavigationContent

Installation

Copy the family into your app:

puzzle add piece split-panel

It has one runtime dependency — the web component it wraps:

npm install @magic-spells/split-panel

Then merge its stylesheet into your app's style entry. It is required: the flex layout, the --split-panel-size share the group writes on every pane, and the divider's gutter, hit target and cursors all live there.

/* app/styles/styles.css */
@import "tailwindcss";
@import "@magic-spells/split-panel/css" layer(components); /* required */

The piece already bridges the sheet's divider colours to pieces.css tokens with an inline style on the group host (ROOT_STYLE in the copied file), so it matches the rest of the registry out of the box. Set the gap and divider line per instance through class:

<SplitPanel class="[--split-panel-gap:0.75rem] [--split-panel-divider-line:0.25rem]">
  …
</SplitPanel>

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import SplitPanel from '@/components/ui/SplitPanel';
<SplitPanel class="h-80" id="editor">
  <SplitPanel.Pane size={ 30 } min="180px">…sidebar…</SplitPanel.Pane>
  <SplitPanel.Divider/>
  <SplitPanel.Pane>…editor…</SplitPanel.Pane>
</SplitPanel>

The group fills its container, so give it — or a wrapper — an explicit height. Write a SplitPanel.Divider between every adjacent pair: the component would generate the missing ones, but a generated element sitting between keyed Puzzle children is invisible to the patcher and gets moved or dropped on the next reorder. The root warns in the console when the count does not add up.

Vertical

PreviewTimeline

Min / max constraints

180px min, 40% maxFills the rest

Three panes

FilesEditorInspector

Snap points

Drag me and let goSettles on 0 / 50 / 100

Nested groups

SidebarEditorConsole

Reporting sizes

Drag the dividerWatch the readout

live — · committed — (0 commits)

Locked divider

FixedAlso fixed

Reference

SplitPanel

direction'horizontal' (default) | 'vertical'.
snapBare true for 0 / 50 / 100 percent of travel, or a string or array of your own points. Settles on release.
disabledLocks every divider in the group.
idPersists committed sizes at split-panel:<id> in localStorage and restores them on load.
sizesOptional controlled percent shares, one per pane. Edge-triggered and applied with setSizes(). Do not drive it from @resize.
classMerged onto the split-panel-group host. Give it a height — the group fills its container.
@resize(sizes)Advisory; fires on every applied change during a gesture. Use it for a readout.
@resizeEnd(sizes)The commit hook — pointer release, a keyboard step, or a double-click reset.

SplitPanel.Pane

sizeAuthored share: 30, '30%', or '250px'. A seed, not a live binding — the group owns sizes after mount.
minMinimum extent: a number of px, '240px', or '25%'.
maxMaximum extent, same units. A pane with a max also gets --split-panel-visible (0 at min, 1 at max).
classRendered on split-panel. Must be a direct child of SplitPanel.

SplitPanel.Divider

disabledLocks this one divider. It keeps its gutter but hides the handle.
classRendered on split-divider. No children — the handle is drawn with pseudo-elements.

Keyboard

Arrow keys1% per press along the group’s axis; hold Shift for 10%.
Home / EndJump to the pair’s minimum or maximum.
EnterReset the pair to its authored ratio — the same as a double-click.

Leave sizes uncontrolled unless you have a reason not to. A drag emits @resize on every applied change, so routing each one through parent state and back is a full subtree re-render per frame that fights the live gesture. Treat @resize as advisory — readouts, not state — and commit on @resizeEnd.