NavigableTabView
NavigableTabView in UIToolbox is the native TabView with keyboard and gamepad support. Native tab headers cannot take focus, so only the mouse can change the tab. NavigableTabView takes focus as one element. The arrow keys and the gamepad directions along the headers then select the previous or next tab. Use it for tabs inside a window; window tabs are TabStrip.


<tb:NavigableTabView reorderable="true">
<ui:Tab label="Audio">...</ui:Tab>
<ui:Tab label="Video">...</ui:Tab>
<ui:Tab label="Network" enabled="false" />
<ui:Tab label="Log" closeable="true">...</ui:Tab>
</tb:NavigableTabView>
| Member | Description |
|---|---|
BumperSwitch (bumper-switch) |
The shoulder buttons of a gamepad (LB, RB) or the keys Q and E select the previous or next tab, as in the menus of a console game. Two glyph badges at the ends of the header strip show the buttons. Off by default. See "Shoulder buttons". |
SelectNext(step) |
Selects the next enabled tab in the direction of step (-1 or 1). After the last tab comes the first. Returns false when no other tab is enabled. |
SetTabEnabled(tab, enabled) |
Enables or disables a tab and its header. Use it in place of tab.SetEnabled, which leaves the header enabled. |
SetAttention(tab, on) |
Makes the header of a tab flash until the user selects the tab. The selected tab does not flash. |
HasAttention(tab) |
True while the header flashes. |
SetBadge(tab, text, tone) |
Shows a Badge after the label of the header, such as a count of new messages. An empty text removes it. The badge stays when the user selects the tab. Returns the badge. |
Everything of TabView |
selectedTabIndex, activeTabChanged, reorderable, tabReordered, tabClosed, GetTab, GetTabHeader. |
- Tab reaches the tab view once. The next Tab goes into the selected tab, not to the next header.
- Left and Right change the tab. With the native
unity-tab-view__verticalclass (TabView.verticalUssClassName), Up and Down change it. - The other directions still move focus. A direction from a control inside a tab is for that control and does not change the tab.
- A disabled tab (
enabled="false") is skipped. Its header is faded and in italics, and takes no click. - A click on a header selects the tab and gives the tab view focus, so the arrow keys go on from there.
Shoulder buttons
<tb:NavigableTabView bumper-switch="true">
<ui:Tab label="Weapons">...</ui:Tab>
<ui:Tab label="Armor">...</ui:Tab>
<ui:Tab label="Items">...</ui:Tab>
</tb:NavigableTabView>
With BumperSwitch the tab view shows two GamepadGlyph badges, one at each end of the header strip. They show LB and RB in the look of the gamepad that the player used last, and Q and E after a key or a mouse button. Pair the tab view with a PromptBar that shows the same buttons.
- Q and E change the tab with both input backends. LB and RB need the Input System package and work on every gamepad.
- In a Workspace, LB and RB switch the windows. The tab actions of the workspace change the tab there, LT and RT by default, and the badges show those buttons.
- The buttons work while the focus is in the tab view, in a header or in a control of a tab. A dialog or another tab view with the focus keeps its own buttons.
- A text field keeps Q and E: they are text there. A key that a control of the tab stops does not change the tab. A KeyBindingField that waits for a key or a button keeps them too, because the press is the binding.
- After the last tab comes the first, and a disabled tab is skipped, as for the arrow keys.
- A click or a touch on a badge gives the tab view the focus and changes the tab.
- Without the Input System package, call
SelectNext(-1)andSelectNext(1)from the code that reads the buttons of your game. The badges still show. - The header strip gets room for the badges on both sides (above and under the headers of a vertical tab view). The size of the room is
--tb-tab-bumper-space.
Attention and badges
var mail = tabs.GetTab(2);
// the header flashes until the user selects the tab
tabs.SetAttention(mail);
// a red "5" after the label
tabs.SetBadge(mail, "5", BadgeTone.Error);
tabs.SetBadge(mail, ""); // removes the badge
For a tab with a color of its own, add a class to tab.tabHeader and style it. The flash color is --tb-tab-attention-color (default --tb-color-warning).
Styling
| Class | Element |
|---|---|
tb-tab-view |
The tab view. It also has the native unity-tab-view classes, so the workspace TabView rules apply. |
tb-attention, tb-attention--on |
A header while it flashes; the second class goes on and off. |
tb-tab-view__badge |
The badge of a header. |
tb-tab-view--bumpers |
The tab view while BumperSwitch is on. |
tb-tab-view__header--bumpers |
The header strip while BumperSwitch is on. Its padding is the room for the two badges. |
tb-tab-view__bumper |
One of the two shoulder glyphs: a GamepadGlyph. font-size is its size (18 px) and color is its color (--tb-color-text-muted, --tb-color-text under the pointer). |
--tb-tab-bumper-space |
A custom property on the tab view: the room for a badge at the end of the header strip (32px). |
unity-tab__header:disabled |
The header of a disabled tab: opacity: 0.45 and an italic --tb-color-text-disabled label. |
tb-tab-view:focus … unity-tab__header:checked |
The checked header while the tab view has focus: --tb-color-accent with an --tb-color-accent-text label. The selectors go child by child, so a TabView inside a tab keeps its look. |
The NavigableTabViewDemo scene shows the tabs of a settings page, a character menu that the shoulder buttons page through and that skips a locked tab, mail with a badge and a guild tab that flashes, whisper chats that close and move, and the underline, pills and vertical looks.