Menubar
A horizontal bar of menus sharing one roving focus.
This demo runs the real GPUI component on WebGPU, which this browser does not expose.
Try Chrome or Edge 113+, or Safari 26+. In Firefox, enable dom.webgpu.enabled.
You can also run it natively: cargo run -p showcase menubar
The demo failed to start in this browser.
You can run it natively instead: cargo run -p showcase menubar
Live examples are not supported on most mobile browsers yet — open this page on a desktop or tablet to run the demo.
Recent phones with WebGPU may manage it (downloads ~18 MB):
#Anatomy
Import the component's parts and compose them under its root:
use base_gpui::menubar::{
Menubar,
};
Menubar::new();
The anatomy is a structural overview. Parts with mutually exclusive modes may need separate instances; each part's section below documents its configuration.
#Menubar
Public renderable part of the Menubar component.
use base_gpui::menubar::Menubar;
Menubar::new()
.id("example-id")
.orientation(/* orientation: MenubarOrientation */)
.loop_focus(true)
.modal(true)
.disabled(true)
.aria_label("label")
.style_with_state(|/* callback arguments */| { /* handle change */ });
#Builders
| Builder | Signature & description |
|---|---|
.new | pub fn new() -> SelfCreates a Menubar with its default configuration. |
.id | pub fn id(mut self, id: impl Into<ElementId>) -> Self
Sets the stable GPUI element identity. Use a unique value when multiple instances can appear in the same view. |
.child | pub fn child(mut self, child: impl Into<MenubarChild>) -> Self
Adds one typed child to this part. |
.child_any | pub fn child_any(mut self, child: impl IntoElement) -> Self
Adds one arbitrary renderable child to this part. |
.orientation | pub fn orientation(mut self, orientation: MenubarOrientation) -> Self
Sets the component's horizontal or vertical orientation and corresponding keyboard behavior. |
.loop_focus | pub fn loop_focus(mut self, loop_focus: bool) -> Self
Controls whether keyboard focus wraps from the last enabled item to the first and vice versa. |
.modal | pub fn modal(mut self, modal: bool) -> Self
Controls whether the overlay behaves modally and blocks interaction outside it. |
.disabled | pub fn disabled(mut self, disabled: bool) -> Self
When true, prevents user interaction with this part. |
.aria_label | pub fn aria_label(mut self, label: impl Into<SharedString>) -> Self
Accessible label for the menubar row; Base UI leaves labeling to the consumer, so this stays optional. |
.style_with_state | pub fn style_with_state(mut self, style: impl Fn(MenubarStyleState, Div) -> Div + 'static,) -> Self
Styles the part from its current behavioral state while preserving separation between behavior and visual design. Menubar also supports the GPUI traits implemented in its source, such as standard styling or child composition. |
#Accessibility
Keyboard interaction and accessibility semantics are implemented by the component, independently of visual styling. Known limitations caused by missing GPUI accessibility primitives are documented in the module source and are not silently approximated.
#Stability
Base GPUI is pre-1.0. Builder names and state types may evolve as GPUI and this port mature.