WarUI documentation

Tab group nodes with active tab state

experimental

A tab group holds an ordered list of panes and records which pane is active. Order and active tab are part of the model.

Live example

Expected behavior

Activating or reordering tabs updates activePaneId and the panes array immediately. Moving the last tab out of a group either removes the group or leaves an empty group, depending on the toggle. Arrow keys move between tabs and Ctrl+Shift+PageUp/PageDown reorder the focused tab.

Source

import { createDockModel } from '@warlockcode/warui-core';

const model = createDockModel({
  root: {
    type: 'split',
    id: 'root',
    children: [
      { type: 'tabs', id: 'group-a', activePaneId: 'main.ts',
        panes: [
          { id: 'main.ts', kind: 'document', title: 'main.ts' },
          { id: 'styles.css', kind: 'document', title: 'styles.css' },
        ] },
      { type: 'tabs', id: 'group-b', panes: [] },
    ],
  },
}, { allowEmptyGroups: true });

model.on('layoutChange', (event) => console.log(event.reason));

model.activatePane('styles.css');
// Final position in the target group; emits one 'move' event.
model.movePane('main.ts', 'group-b', 0);

API reference

DOCK-A01-F03 API
KindNameTypeDescription
Node typetype: 'tabs'—Leaf container holding panes.
PropertypanesDockPane[]Ordered panes. Duplicate ids inside a group are removed with a warning.
PropertyactivePaneIdstring | nullAlways a pane of the same group, or null when empty. An invalid value activates the first pane with a warning.
MethodactivatePane(paneId: string) => voidActivates a pane and emits layoutChange with reason 'activate'. No-op if already active.
MethodmovePane(paneId: string, targetGroupId: string, index: number) => voidMoves a pane, keeping its id, and emits a single layoutChange with reason 'move'. Moving to the same position is a no-op. The previously active pane's neighbour becomes active in the source group.
OptionallowEmptyGroupsbooleanWhen false, a group whose last pane moved out is removed. Default true.