Class OverflowToolbar
A horizontal strip of controls that collapses whatever does not fit into a trailing caret, whose menu holds the overflow.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class OverflowToolbar : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
Add any elements to an OverflowToolbar and it re-flows them on every resize: leading items win, trailing items collapse first, and an item is never split — it is either inline or in the menu. The caret appears only when something has actually collapsed. It lives OUTSIDE the measured strip and never shrinks, while the strip does, so the width the arithmetic measures against has the caret already subtracted from it. That is stronger than the registry's explicit reserve-then-drop pass: there is no window in which the bar can be one item too wide.
The web component observes the container with a ResizeObserver; the UI Toolkit equivalent is
GeometryChangedEvent on the bar, which is what drives Reflow() here.
Only the bar is observed, never the items — watching the items would feed collapse back into
measurement and oscillate.
Each item's natural outer width (its layout width plus its margins) is cached while it is inline. An item that has never been measured forces a fully expanded pass so it can be measured before the next collapse, exactly as the registry does. The bar therefore assumes stable items whose inline width does not depend on whether they are collapsed.
Collapsed items stay children of the bar with display: none, so their order is never lost.
Opening the caret moves that trailing run into a Menu shown through
MenuBuilder — the same popup every other App UI menu uses — and dismissing it moves
them straight back and re-flows.
Examples
A tool strip in UXML. Shrink the bar and the trailing buttons move into the caret menu.
<appui:OverflowToolbar style="width: 240px;">
<appui:ActionButton icon="pen" />
<appui:ActionButton icon="copy" />
<appui:ActionButton icon="delete" />
<appui:ActionButton icon="magnifying-glass" />
</appui:OverflowToolbar>
Built in C#.
var bar = new OverflowToolbar { overflowLabel = "More tools" };
foreach (var tool in tools)
bar.Add(new ActionButton { icon = tool.icon, clickable = { clicked = () => tool.Activate() } });
Debug.Log($" of tools fit inline");
Constructors
OverflowToolbar()
Default constructor.
Declaration
public OverflowToolbar()
Fields
caretUssClassName
The styling class of the trailing overflow caret.
Declaration
public const string caretUssClassName = "appui-overflow-toolbar__caret"
Field Value
| Type | Description |
|---|---|
| string |
containerUssClassName
The styling class of the container the inline items live in.
Declaration
public const string containerUssClassName = "appui-overflow-toolbar__container"
Field Value
| Type | Description |
|---|---|
| string |
itemUssClassName
The styling class applied to every item added to the bar.
Declaration
public const string itemUssClassName = "appui-overflow-toolbar__item"
Field Value
| Type | Description |
|---|---|
| string |
Remarks
The bar tags its children rather than styling them through a universal child selector, so an item keeps its inline sizing when it is re-parented into the overflow menu and back.
menuUssClassName
The styling class applied to the Menu holding the collapsed items.
Declaration
public const string menuUssClassName = "appui-overflow-toolbar__menu"
Field Value
| Type | Description |
|---|---|
| string |
overflowingUssClassName
The styling class applied while at least one item has collapsed.
Declaration
public const string overflowingUssClassName = "appui-overflow-toolbar--overflowing"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The OverflowToolbar main styling class.
Declaration
public const string ussClassName = "appui-overflow-toolbar"
Field Value
| Type | Description |
|---|---|
| string |
Properties
contentContainer
Logical container where child elements are added. If a child is added to this element, the child is added to this element's content container instead.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
itemCount
The total number of items in the bar, inline and collapsed.
Declaration
public int itemCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
menuOpen
Whether the overflow menu is currently open.
Declaration
public bool menuOpen { get; }
Property Value
| Type | Description |
|---|---|
| bool |
overflowIcon
The name of the icon drawn in the overflow caret. Defaults to caret-down.
Declaration
[Tooltip("The name of the icon drawn in the overflow caret.")]
[CreateProperty]
[UxmlAttribute]
public string overflowIcon { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
overflowLabel
The accessible label and tooltip of the overflow caret.
Declaration
[Tooltip("The accessible label and tooltip of the overflow caret.")]
[CreateProperty]
[UxmlAttribute]
public string overflowLabel { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
overflowing
Whether at least one item has collapsed into the caret menu.
Declaration
public bool overflowing { get; }
Property Value
| Type | Description |
|---|---|
| bool |
visibleItemCount
The number of items currently shown inline. itemCount when nothing has collapsed.
Declaration
public int visibleItemCount { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
CloseOverflowMenu()
Closes the overflow menu if it is open, returning the collapsed items to the bar.
Declaration
public void CloseOverflowMenu()
OpenOverflowMenu()
Opens the overflow menu, moving the collapsed items into it.
Declaration
public void OpenOverflowMenu()
Remarks
Does nothing when nothing has collapsed or the menu is already open. The menu is a plain Menu shown through MenuBuilder, anchored to the caret.
Reflow()
Recomputes how many items fit inline and collapses the rest.
Declaration
public void Reflow()
Remarks
This runs automatically whenever the bar resizes or is attached. Call it directly only after mutating the items outside a layout pass. It is a no-op while the overflow menu is open, because the collapsed items are then parented to the menu and cannot be measured.
Events
visibleItemCountChanged
Raised after a re-flow that changed how many items are inline.
Declaration
public event Action<int> visibleItemCountChanged
Event Type
| Type | Description |
|---|---|
| Action<int> |