Class SidebarItem
A single row of a Sidebar: an optional leading icon, a label and an optional trailing shortcut hint.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class SidebarItem : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder, IPressable
Remarks
An item carrying a value joins the enclosing Sidebar's single-selection group — activating it sets selectedId and the item paints itself active. An item with no value is a plain action button: it still raises clicked but never changes the selection, which is what the footer entries want.
active can also be set directly to force the state, for a nav whose current route is owned by something other than the Sidebar. A forced value on a valued item is overwritten the next time the selection is refreshed.
Examples
var item = new SidebarItem { value = "assets", label = "Assets", icon = "folder", shortcut = "Ctrl+1" };
item.clicked += () => Debug.Log("Assets clicked");
Constructors
SidebarItem()
Default constructor.
Declaration
public SidebarItem()
Fields
iconUssClassName
The styling class of the item's leading icon.
Declaration
public const string iconUssClassName = "appui-sidebar__item-icon"
Field Value
| Type | Description |
|---|---|
| string |
labelUssClassName
The styling class of the item's label.
Declaration
public const string labelUssClassName = "appui-sidebar__item-label"
Field Value
| Type | Description |
|---|---|
| string |
shortcutUssClassName
The styling class of the item's trailing shortcut hint.
Declaration
public const string shortcutUssClassName = "appui-sidebar__item-shortcut"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The SidebarItem main styling class.
Declaration
public const string ussClassName = "appui-sidebar__item"
Field Value
| Type | Description |
|---|---|
| string |
Properties
active
Whether the item paints itself as the current one.
Declaration
[Tooltip("Whether the item paints itself as the current one.")]
[CreateProperty]
[UxmlAttribute]
public bool active { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
For an item with a value the enclosing Sidebar owns this and overwrites it on every selection refresh. For an item without a value it is yours to set.
clickable
Clickable Manipulator for this SidebarItem.
Declaration
[CreateProperty]
public Pressable clickable { get; set; }
Property Value
| Type | Description |
|---|---|
| Pressable |
icon
The name of the leading icon, or null for no icon.
Declaration
[Tooltip("The name of the leading icon.")]
[CreateProperty]
[UxmlAttribute]
public string icon { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
label
The item's text. Accepts a localization key.
Declaration
[Tooltip("The item's text.")]
[CreateProperty]
[UxmlAttribute]
public string label { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
shortcut
The trailing hint, typically a keyboard shortcut. null hides the element entirely.
Declaration
[Tooltip("The trailing shortcut hint.")]
[CreateProperty]
[UxmlAttribute]
public string shortcut { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
value
The identity of this item within its Sidebar's selection group.
Declaration
[Tooltip("The selection value of this item. Leave empty for a plain action item.")]
[CreateProperty]
[UxmlAttribute]
public string value { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
null (the default) makes the item a plain action button that never changes the selection.
Events
clicked
Raised when the item is activated, by click or by submit key.
Declaration
public event Action clicked
Event Type
| Type | Description |
|---|---|
| Action |