Menubar
A desktop-style application menu bar — menus, submenus, checkable items and keyboard shortcuts — with zero visual opinion.
Application menubar
The WAI-ARIA menubar pattern: the bar is a single tab stop, ← / → move between menus (and switch the
open one), ↓ / Enter / Space open a menu, ↑ / ↓, Home / End and typeahead move inside it, → / ← open
and close submenus, and Escape closes. Once a menu is open, hovering another trigger switches to it.
Checkbox (menuitemcheckbox) and radio (menuitemradio) items keep the menu
open and show their state through BitBhMenuItemIndicator; BitBhMenuLabel names its
BitBhMenuGroup. The shortcuts are just text.
Checkbox and radio items driving the UI
Checkable items are just bound state. @bind-Checked on BitBhMenuCheckboxItem and
@bind-Value on BitBhMenuRadioGroup drive the editor below — toggle line numbers, word
wrap and the status bar, change the zoom or the theme. The menu stays open while you toggle so you can
see each change; set CloseOnSelect="true" on an item to close it instead.
Nested submenus
Nest BitBhMenuSub (a BitBhMenuSubTrigger plus a BitBhMenuSubContent) to any
depth. Hovering opens a submenu after OpenDelay, and a CloseDelay grace period lets
the pointer travel diagonally into it. → / Enter / Space open a submenu and focus its first item, ← / Escape
close it and return to the trigger; on an item without a submenu, → moves on to the next menu of the bar.
Submenu triggers expose aria-haspopup, aria-expanded and data-state.
Disabled menus and items
A disabled BitBhMenu can't be opened, but ← / → still reach its trigger (it stays
focusable and is announced as disabled); disabled items stay visible (with
data-disabled and aria-disabled) but arrow keys and typeahead pass them by.
Loop="false" stops the arrow keys at the first and last menu instead of wrapping. Items can
also render as links with As="a" — Enter follows the link.
Open on hover
Site navigation in a menubar: OpenOnHover on each BitBhMenu opens it when the
pointer rests on its trigger (after HoverOpenDelay, 100 ms by default) and closes it once the
pointer has left the trigger and the menu (after HoverCloseDelay, 300 ms) - the grace period
that lets the pointer cross the gap to the menu, diagonally too, submenus included. Once one is open,
hovering the next trigger switches at once. A hover never takes the focus: the first key press (↓, ↑,
Enter, Space - on the trigger, or with nothing focused) moves it into the menu, a click on the trigger
keeps the menu open, and Escape closes it from anywhere. Touch and pen taps are plain clicks.