Class Button
Button UI element.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class Button : ExVisualElement, IEventHandler, IVisualElementScheduler, IExperimentalFeatures, ITransitionAnimations, ITransform, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, ISizeableElement, IPressable
Constructors
Button()
Default constructor.
Declaration
public Button()
Button(Action)
Constructs a button with an Action that is triggered when the button is clicked.
Declaration
public Button(Action clickEvent)
Parameters
Type | Name | Description |
---|---|---|
Action | clickEvent | The action triggered when the button is clicked. |
Remarks
By default, a single left mouse click triggers the Action. To change the activator, modify clickable.
Fields
iconOnlyUssClassName
The Button icon only variant styling class.
Declaration
public const string iconOnlyUssClassName = "appui-button--icon-only"
Field Value
Type | Description |
---|---|
string |
leadingContainerUssClassName
The Button leading container styling class.
Declaration
public const string leadingContainerUssClassName = "appui-button__leadingcontainer"
Field Value
Type | Description |
---|---|
string |
leadingIconUssClassName
The Button leading icon styling class.
Declaration
public const string leadingIconUssClassName = "appui-button__leadingicon"
Field Value
Type | Description |
---|---|
string |
quietUssClassName
The Button quiet mode styling class.
Declaration
public const string quietUssClassName = "appui-button--quiet"
Field Value
Type | Description |
---|---|
string |
sizeUssClassName
The Button size styling class.
Declaration
public const string sizeUssClassName = "appui-button--size-"
Field Value
Type | Description |
---|---|
string |
subtitleUssClassName
The Button subtitle styling class.
Declaration
public const string subtitleUssClassName = "appui-button__subtitle"
Field Value
Type | Description |
---|---|
string |
titleContainerUssClassName
The Button title container styling class.
Declaration
public const string titleContainerUssClassName = "appui-button__titlecontainer"
Field Value
Type | Description |
---|---|
string |
titleUssClassName
The Button title styling class.
Declaration
public const string titleUssClassName = "appui-button__title"
Field Value
Type | Description |
---|---|
string |
trailingContainerUssClassName
The Button trailing container styling class.
Declaration
public const string trailingContainerUssClassName = "appui-button__trailingcontainer"
Field Value
Type | Description |
---|---|
string |
trailingIconUssClassName
The Button trailing icon styling class.
Declaration
public const string trailingIconUssClassName = "appui-button__trailingicon"
Field Value
Type | Description |
---|---|
string |
ussClassName
The Button main styling class.
Declaration
public const string ussClassName = "appui-button"
Field Value
Type | Description |
---|---|
string |
variantUssClassName
The Button variant styling class.
Declaration
public const string variantUssClassName = "appui-button--"
Field Value
Type | Description |
---|---|
string |
Properties
clickable
Clickable Manipulator for this Button.
Declaration
public Pressable clickable { get; }
Property Value
Type | Description |
---|---|
Pressable |
contentContainer
The content container of this element.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
leadingIcon
The Button leading icon.
Declaration
public string leadingIcon { get; set; }
Property Value
Type | Description |
---|---|
string |
quiet
The quiet state of the Button.
Declaration
public bool quiet { get; set; }
Property Value
Type | Description |
---|---|
bool |
size
The Button size.
Declaration
public Size size { get; set; }
Property Value
Type | Description |
---|---|
Size |
subtitle
The subtitle of the Button.
Declaration
public string subtitle { get; set; }
Property Value
Type | Description |
---|---|
string |
title
The title of the Button.
Declaration
public string title { get; set; }
Property Value
Type | Description |
---|---|
string |
trailingIcon
The Button trailing icon.
Declaration
public string trailingIcon { get; set; }
Property Value
Type | Description |
---|---|
string |
variant
The button variant.
Declaration
public ButtonVariant variant { get; set; }
Property Value
Type | Description |
---|---|
ButtonVariant |
Methods
GetSizeUssClassName(Size)
Declaration
public static string GetSizeUssClassName(Size enumValue)
Parameters
Type | Name | Description |
---|---|---|
Size | enumValue |
Returns
Type | Description |
---|---|
string |
GetVariantUssClassName(ButtonVariant)
Declaration
public static string GetVariantUssClassName(ButtonVariant enumValue)
Parameters
Type | Name | Description |
---|---|---|
ButtonVariant | enumValue |
Returns
Type | Description |
---|---|
string |
Events
clicked
Event triggered when the Button has been clicked.
Declaration
public event Action clicked
Event Type
Type | Description |
---|---|
Action |