Splitter

Two panes with a divider the user drags or moves with the arrow keys.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrSplitter } from 'ngwr/splitter';

@Component({ imports: [WrSplitter] })
export class MyComponent {}

Horizontal

Give the splitter a height; bind [(position)], a percentage from 0 to 100.

<wr-splitter [(position)]="pos" style="height: 20rem">
  <div wrSplitterStart>Files</div>
  <div wrSplitterEnd>Editor</div>
</wr-splitter>
Files
Editor

Vertical

wrSplitterStart is the top pane; position is measured from the top.

<wr-splitter [(position)]="pos" orientation="vertical" style="height: 20rem">
  <div wrSplitterStart>Preview</div>
  <div wrSplitterEnd>Logs</div>
</wr-splitter>
Preview
Logs

API

NameDescriptionTypeDefault
positionPosition of the divider as a percentage (0–100). Two-way bindable.number50
orientationDivider direction: - 'horizontal' — vertical divider, drags L/R (panes side by side). - 'vertical' — horizontal divider, drags U/D (panes stacked).'horizontal' | 'vertical''horizontal'
minPositionMinimum allowed position.number0
maxPositionMaximum allowed position.number100
disabledDisable dragging.booleanfalse
dividerLabelAccessible name of the divider. A focusable role="separator" is an interactive widget, so it needs one — without it a screen reader reaching the divider announces nothing but "separator" and its number. Falls back to splitter.divider.string | nullnull

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/splitter's own element.

VariableDefaultDeclared on
--wr-splitter-divider-bgvar(--wr-border-base).wr-splitter
--wr-splitter-font-familyvar(--wr-font-family-base).wr-splitter
--wr-splitter-handle-bordervar(--wr-border-base).wr-splitter
--wr-splitter-handle-radiusvar(--wr-control-radius-sm).wr-splitter

See also