Dojo NG is being built in the open, one section at a time — follow along on Heptapod.

API REFERENCE · LAYOUT

<dj-split-panel>

Two resizable panes with a draggable divider between them.

Put the panes in the start and end slots. position is the start pane's share of the space, as a percent from 0 to 100. The host needs a size, because the panes fill it: for a horizontal split, give it a height.

Try it in the playground

@dojo-ng/split-panel · v0.1.1

npm install @dojo-ng/split-panel

import "@dojo-ng/split-panel";

Layout

  • orientation="horizontal" (the default) puts the panes side by side with a vertical divider. vertical stacks them with a horizontal divider.
  • The panes always divide in the ratio position : (100 − position).
  • Minimum pane sizes come from CSS, not from properties: set --dj-split-panel-min-start and --dj-split-panel-min-end in any length unit, and dragging stops at that size.
  • The order follows the writing direction, so in a right-to-left page the start pane is on the right with no extra work.
  • The divider bar is drawn by the component. Put custom grip content in the optional divider slot.
  • For three panes, nest a second dj-split-panel inside a slot of the first.

Resizing

  • Drag the divider with a mouse, a trackpad, or touch.
  • Or focus the divider and use the keyboard, so resizing never requires dragging (WCAG 2.5.7): the arrow keys move it by 1 (Shift: by 10), Home moves it to 0, and End to 100. A horizontal split uses Left and Right in the reading direction; a vertical split uses Up and Down.
  • dj-reposition fires when the split settles: once when a drag ends, and once per key press.

Accessibility

  • The divider has role="separator", with aria-valuenow, aria-valuemin, and aria-valuemax tracking position.
  • Its aria-orientation is the divider's own direction, so a horizontal split has a vertical separator.

Properties

PropertyAttributeTypeDefault
orientationLayout axis. horizontal = panes side by side (vertical divider); vertical = stacked. orientation reflected "horizontal""vertical" "horizontal"
positionThe start pane's share of the host, as a percent (0–100). position reflected number 50
disabledWhen set, the divider is inert (no drag, no keyboard, not a tab stop). disabled reflected boolean false

Events

EventDescription
dj-repositiondetail { position }

Slots

startdividerend

CSS parts

Style these with dj-split-panel::part(name).

startenddivider

CSS custom properties

PropertyDefaultDescription
--dj-split-panel-min-start0Minimum size of the start pane (any length).
--dj-split-panel-min-end0Minimum size of the end pane (any length).
--dj-split-panel-divider-width4pxThickness of the divider bar.
--dj-split-panel-divider-colorvar(--dj-color-border)Divider bar color.