Skip to content
Nana UI

Split Panel

Two adjacent panels separated by a draggable divider that the user can reposition. Beyond a basic split, this panel supports collapsing, magnetic auto-collapse while dragging, position persistence, animated transitions, and a rich drag lifecycle.

Start
End
Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/split-panel";
<nana-split-panel style="height:200px;width:100%">
<div slot="start" style="padding:1rem">Start</div>
<div slot="end" style="padding:1rem">End</div>
</nana-split-panel>

Add collapsible to let a panel snap closed past a threshold.

Start
End
PropertyTypeDefaultDescription
positionnumber50The current position of the divider from the primary panel’s edge as a percentage 0–100. Defaults to 50% of the container’s initial size.
positionInPixelsnumber | undefinedThe current position of the divider from the primary panel’s edge in pixels.
verticalbooleanfalseDraws the split panel in a vertical orientation with the start and end panels stacked.
disabledbooleanfalseDisables resizing. Note that the position may still change as a result of resizing the host element when a primary panel is set.
primarySplitPanelPrimary | undefinedIf no primary panel is designated, both panels resize proportionally when the host is resized. If a primary panel is designated, it maintains its size and the other panel grows or shrinks as needed.
snapstring | SplitPanelSnapFunction | undefinedSnap positions in pixels, percentages, or repeat() expressions (e.g. "100px 50%" or "repeat(50%) 10px"), or a function that returns a pixel position to snap to.
snapThresholdnumber12How close the divider must be to a snap point until snapping occurs, in pixels.
collapsiblebooleanfalseAllows the primary panel to be collapsed (double-click the divider, or press Enter / Space).
collapsedbooleanfalseWhether the primary panel is currently collapsed. Reflects and can be set declaratively.
collapseThresholdnumber0When greater than 0 and collapsible, dragging the primary panel smaller than this many pixels magnetically collapses it; dragging back out past the threshold re-expands it.
storageKeystring''When set, the position and collapsed state persist to localStorage under this key and are restored on load.
EventTypeDescription
nameCustomEvent
nana-repositionCustomEventEmitted whenever the divider’s position changes (detail.position).
nana-reposition-startCustomEventEmitted when the user starts dragging the divider.
nana-reposition-endCustomEventEmitted when the user stops dragging the divider.
nana-collapseCustomEventEmitted when a panel collapses.
nana-expandCustomEventEmitted when a panel expands.
SlotDescription
startContent to place in the start panel.
endContent to place in the end panel.
dividerThe divider. Useful for slotting in a custom icon that renders as a handle.
VariableDefaultDescription
--divider-width4pxThe width of the visible divider.
--divider-hit-area12pxThe invisible region around the divider where dragging can occur.
--min0%The minimum allowed size of the primary panel.
--max100%The maximum allowed size of the primary panel.
--transition-duration200msDuration of animated collapse / expand / reset.
PartDescription
panelBoth the start and end panels
startThe start panel
endThe end panel
dividerThe divider that separates the start and end panels
  • Keyboard accessible
  • Screen-reader labels
  • Focus-visible states
  • ARIA roles and states
  • WCAG 2.2 AA contrast
Explore Split Panel interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook