docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class OverflowToolbar

    A horizontal strip of controls that collapses whatever does not fit into a trailing caret, whose menu holds the overflow.

    Inheritance
    object
    CallbackEventHandler
    Focusable
    VisualElement
    BaseVisualElement
    OverflowToolbar
    Implements
    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder
    Inherited Members
    BaseVisualElement.contextPrefix
    BaseVisualElement.densityOverride
    BaseVisualElement.themeOverride
    BaseVisualElement.langOverride
    BaseVisualElement.layoutDirectionOverride
    BaseVisualElement.preferredTooltipPlacementOverride
    BaseVisualElement.tooltipDelayMsOverride
    BaseVisualElement.GetLayoutDirectionUssClassName(Dir)
    VisualElement.disabledUssClassName
    VisualElement.SetActivePseudoState(bool)
    VisualElement.SetCheckedPseudoState(bool)
    VisualElement.Focus()
    VisualElement.SendEvent(EventBase)
    VisualElement.SetEnabledFromHierarchy(bool)
    VisualElement.SetEnabled(bool)
    VisualElement.MarkDirtyRepaint()
    VisualElement.IsMarkedForRepaint()
    VisualElement.ContainsPoint(Vector2)
    VisualElement.Overlaps(Rect)
    VisualElement.DoMeasure(float, VisualElement.MeasureMode, float, VisualElement.MeasureMode)
    VisualElement.ToString()
    VisualElement.GetClasses()
    VisualElement.ClearClassList()
    VisualElement.AddToClassList(string)
    VisualElement.RemoveFromClassList(string)
    VisualElement.ToggleInClassList(string)
    VisualElement.EnableInClassList(string, bool)
    VisualElement.ClassListContains(string)
    VisualElement.FindAncestorUserData()
    VisualElement.SetBinding(BindingId, Binding)
    VisualElement.GetBinding(BindingId)
    VisualElement.TryGetBinding(BindingId, out Binding)
    VisualElement.GetBindingInfos()
    VisualElement.GetBindingInfos(List<BindingInfo>)
    VisualElement.HasBinding(BindingId)
    VisualElement.ClearBinding(BindingId)
    VisualElement.ClearBindings()
    VisualElement.GetHierarchicalDataSourceContext()
    VisualElement.GetDataSourceContext(BindingId)
    VisualElement.TryGetDataSourceContext(BindingId, out DataSourceContext)
    VisualElement.TryGetLastBindingToUIResult(in BindingId, out BindingResult)
    VisualElement.TryGetLastBindingToSourceResult(in BindingId, out BindingResult)
    VisualElement.Add(VisualElement)
    VisualElement.Insert(int, VisualElement)
    VisualElement.Remove(VisualElement)
    VisualElement.RemoveAt(int)
    VisualElement.Clear()
    VisualElement.ElementAt(int)
    VisualElement.IndexOf(VisualElement)
    VisualElement.Children()
    VisualElement.Sort(Comparison<VisualElement>)
    VisualElement.BringToFront()
    VisualElement.SendToBack()
    VisualElement.PlaceBehind(VisualElement)
    VisualElement.PlaceInFront(VisualElement)
    VisualElement.RemoveFromHierarchy()
    VisualElement.GetFirstOfType<T>()
    VisualElement.GetFirstAncestorOfType<T>()
    VisualElement.Contains(VisualElement)
    VisualElement.FindCommonAncestor(VisualElement)
    VisualElement.viewDataKey
    VisualElement.userData
    VisualElement.canGrabFocus
    VisualElement.focusController
    VisualElement.disablePlayModeTint
    VisualElement.usageHints
    VisualElement.transform
    VisualElement.scaledPixelsPerPoint
    VisualElement.layout
    VisualElement.contentRect
    VisualElement.paddingRect
    VisualElement.worldBound
    VisualElement.localBound
    VisualElement.worldTransform
    VisualElement.hasActivePseudoState
    VisualElement.hasInactivePseudoState
    VisualElement.hasHoverPseudoState
    VisualElement.hasCheckedPseudoState
    VisualElement.hasEnabledPseudoState
    VisualElement.hasDisabledPseudoState
    VisualElement.hasFocusPseudoState
    VisualElement.hasRootPseudoState
    VisualElement.pickingMode
    VisualElement.name
    VisualElement.enabledInHierarchy
    VisualElement.enabledSelf
    VisualElement.languageDirection
    VisualElement.visible
    VisualElement.generateVisualContent
    VisualElement.dataSource
    VisualElement.dataSourcePath
    VisualElement.dataSourceType
    VisualElement.experimental
    VisualElement.hierarchy
    VisualElement.cacheAsBitmap
    VisualElement.parent
    VisualElement.panel
    VisualElement.visualTreeAssetSource
    VisualElement.this[int]
    VisualElement.childCount
    VisualElement.schedule
    VisualElement.style
    VisualElement.resolvedStyle
    VisualElement.customStyle
    VisualElement.styleSheets
    VisualElement.tooltip
    Focusable.Blur()
    Focusable.focusable
    Focusable.tabIndex
    Focusable.delegatesFocus
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallbackOnce<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, TrickleDown)
    CallbackEventHandler.RegisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.RegisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TUserArgsType, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType>(EventCallback<TEventType>, CallbackOptions)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, TrickleDown)
    CallbackEventHandler.UnregisterCallback<TEventType, TUserArgsType>(EventCallback<TEventType, TUserArgsType>, CallbackOptions)
    CallbackEventHandler.UnregisterAllRemovableCallbacks()
    CallbackEventHandler.HasTrickleDownHandlers()
    CallbackEventHandler.HasBubbleUpHandlers()
    CallbackEventHandler.ExecuteDefaultActionAtTarget(EventBase)
    CallbackEventHandler.HandleEventBubbleUp(EventBase)
    CallbackEventHandler.HandleEventTrickleDown(EventBase)
    CallbackEventHandler.ExecuteDefaultAction(EventBase)
    CallbackEventHandler.NotifyPropertyChanged(in BindingId)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    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
    VisualElement.contentContainer

    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>

    Implements

    IEventHandler
    IResolvedStyle
    ITransform
    ITransitionAnimations
    IExperimentalFeatures
    IVisualElementScheduler
    IContextOverrideElement
    IAdditionalDataHolder

    Extension Methods

    VisualElementExtensions.FindNavController(VisualElement)
    RegisterUpdateCallbackExtensions.RegisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    RegisterUpdateCallbackExtensions.UnregisterUpdateCallback(VisualElement, EventCallback<UpdateEvent>)
    VisualElementExtensions.EnableDynamicTransform(VisualElement, bool)
    VisualElementExtensions.EnablePicking(VisualElement, bool)
    VisualElementExtensions.GetChildren<T>(VisualElement, bool)
    VisualElementExtensions.GetContextProvider<T>(VisualElement)
    VisualElementExtensions.GetContextProvider<T>(VisualElement, string)
    VisualElementExtensions.GetContext<T>(VisualElement)
    VisualElementExtensions.GetContext<T>(VisualElement, string)
    VisualElementExtensions.GetExclusiveRootElement(VisualElement)
    VisualElementExtensions.GetLastAncestorOfType<T>(VisualElement)
    VisualElementExtensions.GetPreferredTooltipPlacement(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement)
    VisualElementExtensions.GetSelfContext<T>(VisualElement, string)
    VisualElementExtensions.GetTooltipContent(VisualElement)
    VisualElementExtensions.GetTooltipTemplate(VisualElement)
    VisualElementExtensions.HasAncestorOfType<T>(VisualElement, bool)
    VisualElementExtensions.HasAncestorsOfType<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement)
    VisualElementExtensions.IsContextProvider<T>(VisualElement, string)
    VisualElementExtensions.IsInvisible(VisualElement)
    VisualElementExtensions.IsOnScreen(VisualElement)
    VisualElementExtensions.ProvideContext<T>(VisualElement, string, T)
    VisualElementExtensions.ProvideContext<T>(VisualElement, T)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.RegisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.SetPreferredTooltipPlacement(VisualElement, OptionalEnum<PopoverPlacement>)
    VisualElementExtensions.SetTooltipContent(VisualElement, VisualElementExtensions.TooltipContentCallback)
    VisualElementExtensions.SetTooltipTemplate(VisualElement, VisualElement)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, string, EventCallback<ContextChangedEvent<T>>)
    VisualElementExtensions.UnregisterContextChangedCallback<T>(VisualElement, EventCallback<ContextChangedEvent<T>>)
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)