UI Toolbox logoUI Toolbox

Tab groups and dock zones

The user makes a tab group by dragging a window onto another window. From code, workspace.GroupAsTabs(windows) puts windows in one new tab group. The TabsDemo.unity example shows window tabs and tabs inside a window.

Video tutorial: Docking. All videos: Video tutorials.

Merge and the no-merge key

<tb:Workspace no-merge-modifier="Alt" />
workspace.NoMergeModifier = EventModifiers.Control;

Snap and the snap keys

During a drag or a resize, an edge of the window snaps to the edge of a window next to it and to the edges of the workspace. Three keys change a drag. Each key is a setting on the workspace, and None turns the key off.

Key Attribute Property Effect
Shift no-merge-modifier NoMergeModifier No merge and no drop into a tab group or a dock zone.
Alt no-snap-modifier NoSnapModifier No snap: the window follows the pointer. It stays in the workspace.
Ctrl align-snap-modifier AlignSnapModifier The window also snaps to the edge lines of windows that are far away, so two windows that do not touch can be in one line, horizontal or vertical.
<tb:Workspace no-snap-modifier="Control" align-snap-modifier="None" />
workspace.NoSnapModifier = EventModifiers.None;        // the snap is always on
workspace.AlignSnapModifier = EventModifiers.Shift;

Tab attention, badge and color

A window in a tab group can ask for the attention of the user. Its tab flashes, shows a badge, or has a look of its own.

var chat = workspace.GetWindow("chat");
chat.RequestAttention("3");                 // the tab flashes and shows the badge "3"
chat.TabBadgeTone = BadgeTone.Error;        // a red badge
chat.TabClass = "tab--boss";                // a USS class on the tab

chat.TabBadge = "";                         // removes the badge
Member of WindowDescriptor Description
NeedsAttention True makes the tab flash. The selection of the tab sets it to false.
RequestAttention(badge) Sets NeedsAttention. A text also sets TabBadge.
TabBadge A short text on the tab, such as a count. An empty text removes the badge.
TabBadgeTone The color of the badge: Neutral, Accent (default), Success, Warning or Error.
TabClass A USS class on the tab.
AttentionChanged Fired after one of these members changes.
.tab--boss {
    --tb-tab-attention-color: var(--tb-color-danger);
    border-top-color: var(--tb-color-danger);
}
Class Element
tb-tab A tab. tb-tab--active is the selected tab, tb-tab--pinned a pinned tab.
tb-attention A tab while it flashes. tb-attention--on goes on and off.
tb-tab-badge The badge. It is a Badge, so the tb-badge classes apply.

AttentionFlash.Set(element, true) in UIToolbox gives the same two classes to an element of your own, such as a button that waits for a click. AttentionFlash.IntervalMs is the time of each half of a flash (default 500).

Dock zones

A dock zone is a persistent tab group at an edge of the workspace. Declare it in UXML:

<tb:Workspace>
  <tb:DockZone position="left" size="250" />
  <tb:DockZone position="right" size="300" />
</tb:Workspace>
Attribute Default Meaning
position left A DockSide: left, right, top or bottom.
size 200 Width (left, right) or height (top, bottom) in pixels.
enabled true If false, no dock zone is created.

In UI Builder, a dock zone draws an empty dock at its edge. It creates the dock window only in Play mode.

A dock zone has the id Dock_{position}. It uses DockPanelTemplate.uxml. It cannot be moved, focused or resized, and it stays open when it is empty. The arrange and tile methods do not move it.