Class Drawer
A sliding panel that contains supplementary content.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class Drawer : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
The Drawer component is a panel that slides in from the left or right edge of the screen. It can contain supplementary content, navigation links, or other UI elements that complement the main content of your application.
Drawers are commonly used in responsive layouts to provide navigation options or additional tools while maximizing screen space for the main content.
By default, clicking outside an open temporary drawer or using the back button (where available) will close it.
- Temporary: Slides in front of the main content and can be dismissed by clicking outside or using the back button
- Permanent: Always visible and cannot be dismissed, suitable for larger screen sizes
Constructors
Drawer()
Default constructor.
Declaration
public Drawer()
Fields
backdropUssClassName
The Drawer backdrop styling class.
Declaration
public const string backdropUssClassName = "appui-drawer__backdrop"
Field Value
| Type | Description |
|---|---|
| string |
drawerContainerUssClassName
The Drawer container styling class.
Declaration
public const string drawerContainerUssClassName = "appui-drawer__drawer-container"
Field Value
| Type | Description |
|---|---|
| string |
drawerUssClassName
The Drawer element styling class.
Declaration
public const string drawerUssClassName = "appui-drawer__drawer"
Field Value
| Type | Description |
|---|---|
| string |
elevationUssClassName
The elevation styling class prefix.
Declaration
public const string elevationUssClassName = "appui-elevation-"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The Drawer main styling class.
Declaration
public const string ussClassName = "appui-drawer"
Field Value
| Type | Description |
|---|---|
| string |
variantUssClassName
The Drawer variant styling class.
Declaration
public const string variantUssClassName = "appui-drawer--"
Field Value
| Type | Description |
|---|---|
| string |
Properties
anchor
The anchor of the drawer. The drawer will be anchored to the left or right side of the screen.
Declaration
[CreateProperty]
[UxmlAttribute]
public DrawerAnchor anchor { get; set; }
Property Value
| Type | Description |
|---|---|
| DrawerAnchor |
backdropFinalOpacity
The opacity of the backdrop when the drawer is open.
Declaration
[CreateProperty]
[UxmlAttribute]
public float backdropFinalOpacity { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
backdropTransitionEnabled
Enable or disable the transition animation for the backdrop when opening or closing the drawer.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool backdropTransitionEnabled { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
contentContainer
The content container of the drawer.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
distance
The normalized distance of the drawer from the edge of the screen. 0 means the drawer is closed, 1 means the drawer is fully open.
Declaration
[CreateProperty(ReadOnly = true)]
public float distance { get; }
Property Value
| Type | Description |
|---|---|
| float |
elevation
The elevation level of the drawer.
Declaration
[CreateProperty]
[UxmlAttribute]
public float elevation { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
hideBackdrop
Show or hide the backdrop of this drawer.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool hideBackdrop { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
hysteresis
The distance threshold to interact with the drawer when swiping.
Declaration
[CreateProperty]
[UxmlAttribute]
public float hysteresis { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
isOpen
Check if the drawer is open.
Declaration
[CreateProperty]
public bool isOpen { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
swipeAreaWidth
The size of the swipe area to open the drawer.
Declaration
[CreateProperty]
[UxmlAttribute]
public float swipeAreaWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
swipeable
Ability to swipe the drawer to open it or close it.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool swipeable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
transitionDurationMs
The duration of the transition when opening or closing the drawer in milliseconds.
Declaration
[CreateProperty]
[UxmlAttribute]
public int transitionDurationMs { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
variant
The variant of the drawer. Permanent drawers are always open and cannot be closed. Temporary drawers can be opened and closed.
Declaration
[CreateProperty]
[UxmlAttribute]
public DrawerVariant variant { get; set; }
Property Value
| Type | Description |
|---|---|
| DrawerVariant |
Methods
Close()
Close the drawer.
Declaration
public void Close()
GetAnchorUssClassName(DrawerAnchor)
Declaration
public static string GetAnchorUssClassName(DrawerAnchor enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| DrawerAnchor | enumValue |
Returns
| Type | Description |
|---|---|
| string |
GetVariantUssClassName(DrawerVariant)
Declaration
public static string GetVariantUssClassName(DrawerVariant enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| DrawerVariant | enumValue |
Returns
| Type | Description |
|---|---|
| string |
Open()
Open the drawer.
Declaration
public void Open()
Toggle()
Toggle the drawer. If it is open, close it. If it is closed, open it.
Declaration
public void Toggle()
Events
closed
Event fired when the drawer is closed.
Declaration
public event Action<Drawer> closed
Event Type
| Type | Description |
|---|---|
| Action<Drawer> |
opened
Event fired when the drawer is opened.
Declaration
public event Action<Drawer> opened
Event Type
| Type | Description |
|---|---|
| Action<Drawer> |