Class MudMenu
- Namespace
- MudBlazor
- Assembly
- MudBlazor.dll
An interactive menu that displays a list of options.
public class MudMenu : MudComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IMudStateHasChanged, IActivatable, IDisposable
- Inheritance
-
MudMenu
- Implements
- Inherited Members
- Extension Methods
Constructors
MudMenu()
public MudMenu()
Properties
ActivationEvent
The action which opens the menu, when ActivatorContent is set.
[Parameter]
[Category("Behavior")]
public MouseEvent ActivationEvent { get; set; }
Property Value
Remarks
Defaults to LeftClick.
ActivatorClassname
The CSS class for the activator element (button or custom content).
protected string ActivatorClassname { get; }
Property Value
ActivatorContent
Overrides the default button with a custom component.
[Parameter]
[Category("Behavior")]
public RenderFragment? ActivatorContent { get; set; }
Property Value
Remarks
Can be a MudButton, MudIconButton, or any other component.
AnchorOrigin
The origin point for the menu's anchor. If set, overrides Nested Menus, and PositionatCursor Anchor points.
[Category("Behavior")]
[Parameter]
public Origin? AnchorOrigin { get; set; }
Property Value
Remarks
Defaults to null
.
AriaLabel
The aria-label
for the menu button when ActivatorContent is not set.
[Parameter]
[Category("Behavior")]
public string? AriaLabel { get; set; }
Property Value
Remarks
Defaults to null
.
ChildContent
The MudMenuItem components within this menu.
[Parameter]
[Category("Popup behavior")]
public RenderFragment? ChildContent { get; set; }
Property Value
Classname
The CSS class for the root menu container.
protected string Classname { get; }
Property Value
Color
The color of this menu's button when Icon is not set.
[Parameter]
[Category("Appearance")]
public Color Color { get; set; }
Property Value
Remarks
Defaults to Default.
Dense
Applies compact vertical padding to all menu items.
[Parameter]
[Category("Popup appearance")]
public bool Dense { get; set; }
Property Value
Remarks
Defaults to false
.
Disabled
Prevents the user from interacting with this menu.
[Parameter]
[Category("Behavior")]
public bool Disabled { get; set; }
Property Value
Remarks
Defaults to false
.
DropShadow
Displays a drop shadow under the activator button.
[Parameter]
[Category("Appearance")]
public bool DropShadow { get; set; }
Property Value
Remarks
Defaults to true
.
DropdownSettings
The behavior of the dropdown popover menu
[Category("Behavior")]
[Parameter]
public DropdownSettings DropdownSettings { get; set; }
Property Value
Remarks
Defaults to Fixed false Defaults to OverflowBehaviorFlipOnOpen
EndIcon
The icon displayed after the text.
[Parameter]
[Category("Behavior")]
public string? EndIcon { get; set; }
Property Value
Remarks
Defaults to null
.
FullWidth
Expands this menu to the same width as its parent.
[Parameter]
[Category("Popup appearance")]
public bool FullWidth { get; set; }
Property Value
Remarks
Defaults to false
.
Icon
The icon displayed for this menu.
[Parameter]
[Category("Behavior")]
public string? Icon { get; set; }
Property Value
Remarks
When set, this menu will display a MudIconButton.
IconColor
The color of the icon when Icon is set.
[Parameter]
[Category("Appearance")]
public Color IconColor { get; set; }
Property Value
Remarks
Defaults to Inherit.
Label
The text shown for this menu.
[Parameter]
[Category("Behavior")]
public string? Label { get; set; }
Property Value
ListClass
The CSS classes applied to items in this menu.
[Parameter]
[Category("Popup appearance")]
public string? ListClass { get; set; }
Property Value
Remarks
Multiple classes must be separated by spaces.
ListClassname
The CSS class for the list containing menu items.
protected string ListClassname { get; }
Property Value
LockScroll
Prevents the page from scrolling while this menu is open.
[Parameter]
[Category("Popup appearance")]
public bool LockScroll { get; set; }
Property Value
Remarks
Defaults to false
.
MaxHeight
Sets the maximum allowed height for this menu, when open.
[Parameter]
[Category("Popup appearance")]
public int? MaxHeight { get; set; }
Property Value
- int?
Remarks
Defaults to null
.
Open
Whether this menu is open and the menu items are visible.
[Parameter]
[Category("Popup behavior")]
public bool Open { get; set; }
Property Value
Remarks
When this property changes, OpenChanged occurs.
OpenChanged
Occurs when Open has changed.
[Parameter]
public EventCallback<bool> OpenChanged { get; set; }
Property Value
ParentMenu
[CascadingParameter]
protected MudMenu? ParentMenu { get; set; }
Property Value
PopoverClass
The CSS classes applied to the popover for this menu.
[Parameter]
[Category("Popup appearance")]
public string? PopoverClass { get; set; }
Property Value
Remarks
Multiple classes must be separated by spaces.
PopoverClassname
The CSS class for the menu's popover container.
protected string PopoverClassname { get; }
Property Value
PositionAtCursor
Opens this menu at the cursor's location instead of the button's location.
[Parameter]
[Category("Popup behavior")]
public bool PositionAtCursor { get; set; }
Property Value
Remarks
Defaults to false
. Typically used for larger-sized activators.
RelativeWidth
Determines the width of the Popover dropdown in relation the parent container.
[Parameter]
[Category("Appearance")]
public DropdownWidth RelativeWidth { get; set; }
Property Value
Remarks
Defaults to Ignore.
When Relative, restricts the max-width of the component to the width of the parent container
When Adaptive, restricts the min-width of the component to the width of the parent container
Ripple
Shows a ripple animation when the user clicks the activator button.
[Parameter]
[Category("Appearance")]
public bool Ripple { get; set; }
Property Value
Remarks
Defaults to true
.
Size
The size of this menu's button when Icon is not set.
[Parameter]
[Category("Appearance")]
public Size Size { get; set; }
Property Value
StartIcon
The icon displayed before the text.
[Parameter]
[Category("Behavior")]
public string? StartIcon { get; set; }
Property Value
Remarks
Defaults to null
.
Stylename
Inline styles for positioning the menu at the cursor's location.
protected string Stylename { get; }
Property Value
TransformOrigin
Sets the direction the menu will open from the anchor.
[Parameter]
[Category("Popup appearance")]
public Origin TransformOrigin { get; set; }
Property Value
Remarks
Defaults to TopLeft.
Variant
The display variant to use.
[Parameter]
[Category("Appearance")]
public Variant Variant { get; set; }
Property Value
Remarks
Defaults to Text.
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
CloseAllMenusAsync()
Closes all menus in the hierarchy, starting from the top-most parent.
public Task CloseAllMenusAsync()
Returns
CloseMenuAsync()
Closes this menu and any descendants if it's a nested menu.
public Task CloseMenuAsync()
Returns
Dispose()
Releases resources used by the component.
public void Dispose()
Dispose(bool)
Disposes managed and unmanaged resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
boolIndicates if managed resources should be disposed.
GetActivatorHidden()
protected bool GetActivatorHidden()
Returns
GetAnchorOrigin()
protected Origin GetAnchorOrigin()
Returns
HasPointerOver(MudMenu)
protected bool HasPointerOver(MudMenu menu)
Parameters
menu
MudMenu
Returns
OnInitialized()
protected override void OnInitialized()
OnOpenChanged(ParameterChangedEventArgs<bool>)
protected Task OnOpenChanged(ParameterChangedEventArgs<bool> args)
Parameters
Returns
OpenMenuAsync(EventArgs, bool)
Opens the menu or updates its state if it's already open.
public Task OpenMenuAsync(EventArgs args, bool transient = false)
Parameters
args
EventArgsThe event arguments for the activation event; MouseEventArgs or TouchEventArgs.
When PositionAtCursor is
true
, the menu will be positioned at these coordinates.transient
boolIf
true
, the menu will close automatically when the pointer leaves its bounds.
Returns
Remarks
Parents are not automatically opened when a child is opened.
OpenSubMenuAsync(EventArgs)
Closes siblings before opening as a "mouse over" menu. This is called in place of OpenMenuAsync(EventArgs, bool) if the menu activator is implicitly rendered for the submenu.
protected Task OpenSubMenuAsync(EventArgs args)
Parameters
args
EventArgs
Returns
RegisterChild(MudMenu)
protected void RegisterChild(MudMenu child)
Parameters
child
MudMenu
ToggleMenuAsync(EventArgs)
Toggles the menu's open or closed state.
public Task ToggleMenuAsync(EventArgs args)
Parameters
args
EventArgsThe event arguments for the activation event; MouseEventArgs or TouchEventArgs.
When PositionAtCursor is
true
, the menu will be positioned at these coordinates.
Returns
UnregisterChild(MudMenu)
protected void UnregisterChild(MudMenu child)
Parameters
child
MudMenu