Skip to content

Splitter

LayoutSince 0.13.0

Two or more resizable panes, side by side (horizontal) or stacked (vertical), following the WAI-ARIA APG window splitter pattern. Each separator is a focusable role="separator" whose value is the size of the pane before it; it moves by dragging, by the arrow keys, and to its limits with Home and End. Enter collapses and restores a collapsible pane, dragging a collapsible pane below half its minimum collapses it, and a double-click resets the sizes. Minimum and maximum sizes take pixels or percentages, and splitters nest. The component stores nothing: sizes are reported in aui-change for the application to persist and pass back as sizes.

  • APG window splitterFocusable separators with values, arrow keys, Home and End, and Enter to collapse.
  • Pixels or percentInitial, minimum, and maximum sizes in pixels or percentages, kept on resize.
  • Collapsible panesCollapse with Enter or by dragging past half the minimum; restore to the previous size.
  • Nested and RTLHorizontal and vertical splitters nest; horizontal ones mirror in right-to-left layouts.
  • You own persistenceaui-change reports the sizes; pass them back as sizes. Nothing is stored by the component.

Use it for

  • Master-detail layouts (a list beside its detail) where users want to choose the proportions.
  • Tool layouts with a sidebar, an editor, and a preview or console.
  • Comparing two documents side by side.

Use something else for

  • Fixed page layouts: use Layout (Grid, Flex) or Sidebar.
  • Small screens where panes cannot be usefully side by side: stack them or use Tabs.
  • Showing and hiding a single region: use Collapsible or Drawer.
Anatomy
<div class="aui-splitter aui-splitter--horizontal">
<div class="aui-splitter__pane" id="aui-splitter-1-pane-0">content</div>
<div class="aui-splitter__separator" role="separator" tabindex="0" aria-orientation="vertical"
aria-label="Folders" aria-controls="aui-splitter-1-pane-0" aria-valuenow="25" aria-valuemin="0" aria-valuemax="50"></div>
<div class="aui-splitter__pane" id="aui-splitter-1-pane-1">content</div>
</div>

Use the bar above each frame to switch theme, density, direction, and locale.

The part of the Workspace layout showcase that uses Splitter. Change its options, use it with the keyboard, and watch the event log; the link in the frame opens the full showcase. The bar above the frame switches theme, density, direction, and locale.

Showcase source
// Workspace layout showcase: a splitter with a virtual list of 10,000 employees in the
// sidebar and the selected person's details beside it. Empty states appear when nothing is
// selected and when the department filter matches nobody.
import { EmptyState } from '@absoluteui/components/empty-state';
import { Splitter, type SplitterChangeDetail } from '@absoluteui/components/splitter';
import { VirtualList, type VirtualListChangeDetail, type VirtualListRangeChangeDetail } from '@absoluteui/components/virtual-list';
import { action, choice, createShowcase, section, status, toggle } from './kit.js';
const sc = createShowcase({
title: 'Workspace layout',
description: 'Resize or collapse the sidebar, scroll and select among 10,000 employees with the mouse or keyboard (arrows, Home, End, type-ahead), and filter to see the empty states.',
});
interface Employee {
id: string;
name: string;
title: string;
department: string;
location: string;
}
const FIRST = ['Ada', 'Grace', 'Alan', 'Katherine', 'Edsger', 'Barbara', 'Donald', 'Margaret', 'Tim', 'Radia', 'Linus', 'Frances'];
const LAST = ['Lovelace', 'Hopper', 'Turing', 'Johnson', 'Dijkstra', 'Liskov', 'Knuth', 'Hamilton', 'Berners-Lee', 'Perlman', 'Torvalds', 'Allen'];
const DEPARTMENTS = ['Engineering', 'Finance', 'Marketing', 'People', 'Sales'];
const TITLES = ['Analyst', 'Engineer', 'Manager', 'Specialist', 'Lead'];
const LOCATIONS = ['Berlin', 'Chennai', 'London', 'New York', 'Sydney'];
const pick = (list: readonly string[], i: number): string => list[i % list.length] ?? '';
const EMPLOYEES: Employee[] = Array.from({ length: 10_000 }, (_, i) => ({
id: `E${String(i + 1).padStart(5, '0')}`,
name: `${pick(LAST, Math.floor(i / FIRST.length))}, ${pick(FIRST, i)}`,
title: pick(TITLES, i * 7),
department: pick(DEPARTMENTS, i * 3),
location: pick(LOCATIONS, i * 11),
})).sort((a, b) => a.name.localeCompare(b.name) || a.id.localeCompare(b.id));
function row(e: Employee): Node {
const el = document.createElement('div');
el.className = 'sc-person';
const name = document.createElement('span');
name.className = 'sc-person__name';
name.textContent = e.name;
const meta = document.createElement('span');
meta.className = 'sc-person__meta';
meta.textContent = `${e.title}, ${e.department}`;
el.append(name, meta);
return el;
}
const area = section(sc, 'Employees', ['splitter', 'virtual-list', 'empty-state']);
const range = status(area);
const workspace = document.createElement('div');
workspace.className = 'sc-workspace';
area.append(workspace);
// The list's own empty content: shown when the filter matches nobody.
const noMatchHost = document.createElement('div');
const noMatch = EmptyState.create(noMatchHost, {
title: 'No employees in this department',
description: 'Choose another department or show everyone.',
icon: 'search',
size: 'sm',
headingLevel: null,
live: true,
primaryAction: { label: 'Show all departments' },
});
const listHost = document.createElement('div');
listHost.className = 'sc-workspace__list';
let visible = EMPLOYEES;
const list = VirtualList.create<Employee>(listHost, {
label: 'Employees',
items: visible,
height: null,
selection: 'single',
itemKey: (e) => e.id,
itemText: (e) => e.name,
itemHeight: 56,
empty: noMatchHost,
renderItem: row,
});
const detail = document.createElement('div');
detail.className = 'sc-workspace__detail';
const emptyHost = document.createElement('div');
const nothingSelected = EmptyState.create(emptyHost, {
title: 'No employee selected',
description: 'Select someone in the list to see their details.',
icon: 'search',
headingLevel: 3,
});
const card = document.createElement('section');
card.className = 'sc-workspace__card';
card.hidden = true;
detail.append(emptyHost, card);
const splitter = Splitter.create(workspace, {
panes: [
{ content: listHost, label: 'Employees', size: '38%', min: 200, max: '70%', collapsible: true },
{ content: detail, label: 'Details', min: 240 },
],
});
sc.listen(splitter.host, ['aui-change'], 'splitter');
const byId = new Map(EMPLOYEES.map((e) => [e.id, e]));
function showDetails(keys: readonly string[]): void {
const people = keys.map((k) => byId.get(k)).filter((e): e is Employee => e !== undefined);
emptyHost.hidden = people.length > 0;
card.hidden = people.length === 0;
if (people.length === 0) return;
const [first] = people;
if (people.length > 1 || !first) {
const h = document.createElement('h3');
h.textContent = `${String(people.length)} employees selected`;
const p = document.createElement('p');
p.textContent = people.slice(0, 5).map((e) => e.name).join('; ') + (people.length > 5 ? '; ...' : '');
card.replaceChildren(h, p);
return;
}
const h = document.createElement('h3');
h.textContent = first.name;
const dl = document.createElement('dl');
for (const [term, value] of [['Employee ID', first.id], ['Title', first.title], ['Department', first.department], ['Location', first.location]] as const) {
const dt = document.createElement('dt');
dt.textContent = term;
const dd = document.createElement('dd');
dd.textContent = value;
dl.append(dt, dd);
}
card.replaceChildren(h, dl);
}
list.host.addEventListener('aui-change', (e) => {
const d = (e as CustomEvent<VirtualListChangeDetail>).detail;
showDetails(d.value);
sc.log('list aui-change', d);
});
const showRange = (start: number, end: number): void => {
range.textContent = visible.length === 0 ? 'No employees shown.' : `Showing ${String(start + 1)} to ${String(end)} of ${visible.length.toLocaleString('en-US')} employees.`;
};
showRange(list.range.start, list.range.end);
list.host.addEventListener('aui-range-change', (e) => {
const d = (e as CustomEvent<VirtualListRangeChangeDetail>).detail;
showRange(d.start, d.end);
});
splitter.host.addEventListener('aui-change', (e) => {
// Change events of the components inside the panes bubble through the splitter too.
if (e.target !== splitter.host) return;
const d = (e as CustomEvent<SplitterChangeDetail>).detail;
range.dataset.sizes = d.sizes.join(',');
});
const filterBy = (value: string): void => {
visible = value === 'all' ? EMPLOYEES : EMPLOYEES.filter((e) => e.department === value);
list.update({ items: visible });
list.scrollToIndex(0, 'start');
showRange(list.range.start, list.range.end);
};
const departmentChoice = choice(
sc,
'Department',
[
{ value: 'all', label: 'All departments' },
...DEPARTMENTS.map((d) => ({ value: d, label: d })),
{ value: 'Legal', label: 'Legal (no one)' },
],
'all',
filterBy,
['virtual-list', 'empty-state'],
);
noMatchHost.addEventListener('aui-action', () => {
departmentChoice.setValue('all');
filterBy('all');
sc.log('empty-state aui-action', { action: 'primary' });
});
toggle(sc, 'Multiple selection', false, (multiple) => {
list.update({ selection: multiple ? 'multiple' : 'single', value: [] });
showDetails([]);
}, ['virtual-list']);
toggle(sc, 'Selection follows focus', false, (selectionFollowsFocus) => {
list.update({ selectionFollowsFocus });
}, ['virtual-list']);
choice(
sc,
'Layout',
[
{ value: 'horizontal', label: 'Side by side' },
{ value: 'vertical', label: 'Stacked' },
],
'horizontal',
(orientation) => {
splitter.update({ orientation });
},
['splitter'],
);
action(sc, 'Collapse or restore sidebar', () => {
if (splitter.collapsed[0]) splitter.expand(0);
else splitter.collapse(0);
}, ['splitter']);
action(sc, 'Jump to the middle', () => {
list.scrollToIndex(Math.floor(visible.length / 2), 'center');
}, ['virtual-list']);
action(sc, 'Clear selection', () => {
list.setValue([]);
showDetails([]);
}, ['virtual-list']);
toggle(sc, 'Compact empty states', false, (compact) => {
nothingSelected.update({ size: compact ? 'sm' : 'md' });
noMatch.update({ size: compact ? 'sm' : 'md' });
}, ['empty-state']);
import { Splitter } from '@absoluteui/components/splitter';
const pane = (text: string): HTMLElement => {
const el = document.createElement('section');
el.textContent = text;
return el;
};
const right = document.createElement('div');
Splitter.create(right, { orientation: 'vertical', panes: [{ content: pane('Editor'), label: 'Editor', min: 120 }, { content: pane('Console'), label: 'Console', size: '30%', collapsible: true }] });
const host = document.createElement('div');
host.style.setProperty('block-size', '30rem');
document.body.append(host);
Splitter.create(host, { panes: [{ content: pane('Files'), label: 'Files', size: 220, min: 160 }, { content: right, label: 'Workspace' }] });
import { Splitter, type SplitterChangeDetail } from '@absoluteui/components/splitter';
const sidebar = document.createElement('nav');
sidebar.textContent = 'Folders';
const content = document.createElement('main');
content.textContent = 'Messages';
const host = document.createElement('div');
host.style.setProperty('block-size', '24rem');
document.body.append(host);
const saved = sessionStorage.getItem('mail-split');
const parsed: unknown = saved ? JSON.parse(saved) : null;
const sizes = Array.isArray(parsed) && parsed.every((n) => typeof n === 'number') ? parsed : null;
Splitter.create(host, {
sizes,
panes: [
{ content: sidebar, label: 'Folders', size: '25%', min: 160, max: '50%', collapsible: true },
{ content, label: 'Messages', min: 240 },
],
});
host.addEventListener('aui-change', (event) => {
sessionStorage.setItem('mail-split', JSON.stringify((event as CustomEvent<SplitterChangeDetail>).detail.sizes));
});
Terminal window
npm install @absoluteui/components @absoluteui/core @absoluteui/theme

Registry setup, the theme stylesheet, and the Content Security Policy are covered in Installation.

import { Splitter } from '@absoluteui/components/splitter';
import '@absoluteui/components/splitter/style.css';
import { Splitter } from '@absoluteui/components/splitter';
import '@absoluteui/components/splitter/style.css';
const host = document.querySelector<HTMLElement>('#compare');
const left = document.querySelector<HTMLElement>('#before');
const right = document.querySelector<HTMLElement>('#after');
if (host && left && right) Splitter.create(host, { panes: [{ content: left, label: 'Before', min: '20%' }, { content: right, label: 'After', min: '20%' }] });
More usage
import { Splitter, type SplitterChangeDetail } from '@absoluteui/components/splitter';
const host = document.querySelector<HTMLElement>('#workspace');
const list = document.querySelector<HTMLElement>('#list');
const detail = document.querySelector<HTMLElement>('#detail');
if (host && list && detail) {
Splitter.create(host, { panes: [{ content: list, label: 'Employees', size: '30%', min: 200, collapsible: true }, { content: detail, label: 'Details', min: 320 }] });
host.addEventListener('aui-change', (event) => {
host.dataset.sizes = (event as CustomEvent<SplitterChangeDetail>).detail.sizes.join(',');
});
}

Using Angular? See Splitter for Angular.

Splitter.create(host: HTMLElement, options: SplitterOptions): Splitter

Global configuration key: splitter (see Configuration).

Option Type Default Description
panes readonly SplitterPane[] Two to ten panes: { content: Node, label, size?, min?, max?, collapsible?, collapsed? }; lengths in px (number or ‘240px’) or ‘%’. Required.
orientation 'horizontal' | 'vertical' "horizontal" horizontal: panes side by side (vertical separators); vertical: stacked panes.
sizes readonly number[] | null "null" Restored sizes in percent per pane (from aui-change); overrides the panes’ size.
step number "16" Pixels a separator moves per arrow key press. Globally configurable.
locale string "en-US" Locale of the collapsed-state text. Globally configurable. Inherited from common configuration.
Property Type Description
host HTMLElement The host element.
sizes number[] Every pane’s size in percent of the space between separators.
collapsed boolean[] Which panes are collapsed.
paneElements readonly HTMLElement[] The pane elements, in order.
options Readonly<SplitterOptions> Current options.
Method Description
collapse(index: number): void Collapse a collapsible pane (no event).
expand(index: number): void Restore a collapsed pane (no event).
reset(): void Back to the initial sizes and collapsed states (no event).
update(options: Partial<SplitterOptions>): void Merge and apply options.
destroy(): void Remove the panes, separators, observers, and listeners.
Event Detail Bubbles Cancelable Description
aui-change SplitterChangeDetail Yes No The user resized, collapsed, expanded, or reset: { sizes, collapsed, index, reason }; persist sizes and pass them back as sizes.
Area Description
panes Each pane’s content (a Node, which may be another splitter’s host).

All rules live in the aui.components cascade layer, so application styles override them without specificity battles.

Class Purpose
aui-splitter Host.
aui-splitter--horizontal | --vertical Orientation.
aui-splitter--dragging A separator is being dragged.
aui-splitter__pane | __pane--collapsed A pane and a collapsed pane (hidden).
aui-splitter__separator | __separator--collapsed A separator (role=separator) and one next to a collapsed pane.

Tokens this stylesheet reads (verified in CI). Override them in a theme or with the Theme Designer.

--aui-color-border | --aui-color-border-strong | --aui-color-focus-ring | --aui-focus-ring-offset | --aui-focus-ring-width | --aui-radius-pill | --aui-space-3

TypeScript definitions
type SplitterOrientation = 'horizontal' | 'vertical';
type SplitterLength = number | string;
type SplitterChangeReason = 'drag' | 'keyboard' | 'collapse' | 'expand' | 'reset';
interface SplitterConfig { step: number }
interface SplitterPane {
content: Node;
label: string;
size?: SplitterLength;
min?: SplitterLength;
max?: SplitterLength;
collapsible?: boolean;
collapsed?: boolean;
}
interface SplitterOptions extends Partial<SplitterConfig> {
panes: readonly SplitterPane[];
orientation?: SplitterOrientation;
sizes?: readonly number[] | null;
locale?: string;
}
interface SplitterChangeDetail { sizes: number[]; collapsed: boolean[]; index: number; reason: SplitterChangeReason }

Pattern: WAI-ARIA APG Window Splitter (variable): each separator is a focusable role=separator whose value is the size of the pane before it in percent; arrow keys move it, Home and End go to the limits, Enter collapses and restores.

Checked on every docs build: the showcase passes axe (WCAG 2.2 A and AA rules) in the default, dark, and high-contrast themes and right to left; the playground loads without errors and passes axe before and after every on/off option is switched, with no Content Security Policy violations.

Key Context Action
Tab Splitter Each separator is a tab stop between the panes’ content.
Left / Right Arrow Separator (horizontal splitter) Move by step pixels (mirrored in RTL).
Up / Down Arrow Separator (vertical splitter) Move by step pixels.
Home / End Separator Smallest or largest allowed size of the pane before it.
Enter Separator Collapse the collapsible pane next to it, or restore it.
Element Role
separator separator (focusable)
pane none (generic container)
Attribute Element Value
aria-valuenow separator size of the pane before it, 0 to 100
aria-valuemin / aria-valuemax separator limits from min, max, and the neighbor’s limits (min 0 when collapsible)
aria-valuetext separator ‘{label}, collapsed’ while the pane before it is collapsed
aria-orientation separator vertical for horizontal splitters, horizontal for vertical ones
aria-controls separator id of the pane before it
aria-label separator the label of the pane before it (the primary pane)

Separators are focusable (tabindex 0); dragging focuses the separator, so keyboard and pointer share one current separator. Collapsing never moves focus.

Criterion Level Note
1.3.1 Info and Relationships A
1.4.11 Non-text Contrast AA
2.1.1 Keyboard A
2.4.3 Focus Order A
2.4.7 Focus Visible AA
2.5.7 Dragging Movements AA
4.1.2 Name, Role, Value A

Automated test results: Accessibility and compliance.

  • Every drag can be done with the keyboard (WCAG 2.5.7 dragging movements).
  • The grip is a shape cue besides the line color; its color meets 3:1 against the surface.
  • Manual screen-reader verification (NVDA, JAWS, VoiceOver) is pending.
Import cost Minified gzip brotli CSS brotli
@absoluteui/components/splitter 17.8 kB 6.8 kB 6.1 kB 0.6 kB

Measured at build time, including every AbsoluteUI module the component pulls in. No third-party runtime dependencies.

Budget (enforced in CI) Limit
Splitter.create with 3 panes < 2 ms average in headless Chromium
Drag frame one custom property per pane; no layout reads besides the host size

Tested scale: Up to 10 panes per splitter and three levels of nesting.

A drag frame sets one custom property per pane and reads only the host and separator sizes; panes are laid out by flexbox.

Measured run times: Performance.

States

Horizontal or vertical; dragging; a pane at its minimum or maximum; a pane collapsed; nested.

State transitions
From Trigger To
sizes drag, arrow keys, Home, End new sizes; aui-change (drag on release, keyboard per key)
expanded Enter, or dragging a collapsible pane below half its minimum collapsed; aui-change (collapse, or drag)
collapsed Enter, or dragging the separator expanded; aui-change
any double-click a separator initial sizes; aui-change (reset)
dragging Escape sizes before the drag (no event)
Accessibility notes
  • Every drag has a keyboard equivalent (WCAG 2.5.7).
  • The grip is a shape cue besides the line color; the grip color meets 3:1 against the surface.
  • The separator is 12px thick by default; its target spans the whole length of the panes.
  • The e2e axe run covers three themes; manual screen-reader verification is pending.
Responsive behavior

Sizes are fractions of the available space, so proportions hold when the container resizes; pixel minimums and maximums are enforced again after a resize. Until the user changes the sizes, pixel size values are recomputed on resize.

Right-to-left

Horizontal splitters mirror: the first pane is on the right, Left Arrow grows it, and dragging follows the pointer.

Theming

Three themes through the role tokens; forced colors use CanvasText and ButtonText for the line and grip.

Global configuration
configureAbsoluteUI({ components: { splitter: { step: 24 } } });
Component configuration

Instance step and locale override configuration.

Icons

None (the grip is drawn with CSS).

Security

Pane content is inserted as given (the application owns it). No HTML parsing.

Data handling

No persistence, network access, or telemetry. Persist aui-change sizes in the application (for example in user preferences) and pass them back as sizes.

Supported data scale

Up to 10 panes per splitter and three levels of nesting.

Edge cases
  • A separator moves only its two neighbors; other panes keep their size.
  • When the container is too small for every minimum, the panes shrink proportionally and the minimums apply again when it grows.
  • sizes are normalized to 100; zero for a collapsible pane plus collapsed: true restores it collapsed.
  • With update({ panes }) and the same pane count, sizes are kept; a different count recomputes them.
Errors
Code Category Cause
SPLITTER_OPTIONS configuration Fewer than 2 or more than 10 panes, a pane without a Node or label, an invalid length, collapsed without collapsible, an unknown orientation, or sizes that do not match the panes.
CFG_INVALID_VALUE / CFG_UNKNOWN_OPTION configuration Invalid or unknown configuration.

Invalid options throw before the host is modified; an invalid update() leaves the previous state intact.

Known limitations
  • A separator moves only its two neighboring panes.
  • Pixel sizes in panes[].size apply to the first layout; afterwards sizes are percentages.
  • Manual screen-reader verification is pending.
Unsupported scenarios
  • Storing sizes inside the component: persist them in the application.
  • Overlapping or floating panes.