Menubar
A horizontal bar of menus, like a desktop application's menu bar.
Menubar holds a row of menus. In v0.4 it can be composed from parts: MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem and MenubarSeparator.
Installation
bash
shellui add menubar
This also installs the parts.
Usage
Composed from parts
Each MenubarMenu pairs a MenubarTrigger with a MenubarContent. A MenubarItem inside the content runs OnClick and closes the menu. A MenubarItem placed directly in the bar is a plain button.
With Title
A MenubarItem with a Title is a dropdown by itself: the title is the trigger and the child content is the menu. This is the 0.3 API, and it still works.
API Reference
Menubar
| Parameter | Type | Default | Description |
|---|---|---|---|
ChildContent |
RenderFragment? |
null |
Menus and items |
Class |
string? |
null |
Additional CSS classes |
MenubarItem
| Parameter | Type | Default | Description |
|---|---|---|---|
Title |
string |
"" |
Set for the dropdown form; leave empty for a clickable item |
OnClick |
EventCallback<MouseEventArgs> |
- | Fires when a clickable item is chosen |
Disabled |
bool |
false |
Disables a clickable item |
ChildContent |
RenderFragment? |
null |
The item label, or the dropdown's content when Title is set |
Class |
string? |
null |
Additional CSS classes |
Parts
| Component | Purpose |
|---|---|
MenubarMenu |
One menu; holds a trigger and its content |
MenubarTrigger |
The button in the bar that opens the menu |
MenubarContent |
The panel shown while the menu is open |
MenubarSeparator |
A divider between items |
Each part takes ChildContent and Class. ClassName on Menubar and MenubarItem still works but is deprecated; use Class.
Accessibility
- Triggers and items are native buttons, reachable with Tab and activated with Enter or Space
data-stateon the trigger isopenorclosed- Clicking outside an open menu closes it