Menubar
Horizontal application menu bar with link and button items.
Preview
A live, theme-aware example rendered with the published component.
Import
Import from the focused entry point below, or use the same named export from @tavojs/ui. Both are public APIs; measure the built application when comparing their bundle cost.
tsximport { Menubar } from "@tavojs/ui/menubar";The component import loads compiled component CSS. Enable tavoUi() for your project theme variables, or import @tavojs/ui/theme.css once for the package default theme. The equivalent CSS-safe component alias is @tavojs/ui/css/menubar.
When to use
Use it when
Choose something else when
Examples
These examples include imports and local state where interaction requires it. Render the exported component in a page after completing UI installation. Demo state stays in the mounted component; connect file handling, persistence, and data loading to your application as needed.
Menubar example
tsximport { Menubar } from "@tavojs/ui/menubar";
export function MenubarExample1() {
return (
<>
<Menubar items={[{ label: "Documentation", href: "/docs" }, { label: "Settings", href: "/settings" }]} />
</>
);
}Common props and defaults
A curated starting point. The complete TypeScript API below includes additional props and compound member contracts.
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | Optional class hook applied to the public root element owned by the component. |
items | Array | — | Navigation items when supported by the component. Applies to Menubar. |
aria-label | string | — | Accessible label for navigation landmarks when needed. Applies to Menubar. |
children | Child | — | Navigation content or custom item structure. Applies to Menubar. |
Complete TypeScript API
Import from @tavojs/ui/menubar. Published exports: Menubar, MenubarItem, MenubarItemProps, MenubarProps, MenubarRoot.
MenubarProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Navigation content or custom item structure. Applies to Menubar. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Menubar. |
id | string | No | Inherited id attribute accepted by Menubar. |
role | string | No | Inherited role attribute accepted by Menubar. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Menubar. |
title | string | No | Inherited title attribute accepted by Menubar. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Menubar. |
hidden | boolean | No | Inherited hidden attribute accepted by Menubar. |
disabled | boolean | No | Inherited disabled attribute accepted by Menubar. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Menubar. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Menubar. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Menubar. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Menubar. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Menubar. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Menubar. |
MenubarItemProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Navigation content or custom item structure. Applies to Menubar. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by Menubar. |
id | string | No | Inherited id attribute accepted by Menubar. |
role | string | No | Inherited role attribute accepted by Menubar. |
style | Record<string, unknown> | No | Inherited style attribute accepted by Menubar. |
title | string | No | Inherited title attribute accepted by Menubar. |
tabIndex | number | No | Inherited tabIndex attribute accepted by Menubar. |
hidden | boolean | No | Inherited hidden attribute accepted by Menubar. |
disabled | boolean | No | Inherited disabled attribute accepted by Menubar. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by Menubar. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by Menubar. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by Menubar. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by Menubar. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by Menubar. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by Menubar. |
href | string | No | Inherited href attribute accepted by Menubar. |
current | boolean | No | Inherited current attribute accepted by Menubar. |
State ownership and DOM target
| Concern | Contract |
|---|---|
| State | No component state contract is exposed; the application owns the rendered content and surrounding behavior. |
| DOM target | Public passthrough props target the component root. Treat nested elements and private class names as implementation details. |
Anatomy and related components
Public compound members: Root, Item
Limitations
Avoid Menubar when for arbitrary button groups that do not navigate.
Use only the documented props, entry points, and compound members. Internal DOM nesting and CSS class names can change without becoming part of the public component contract.
Accessibility
Navigation components should expose current-page state and landmark labels when context is not obvious.
Use aria-current for active destinations where supported.
Add aria-label when multiple nav landmarks exist.
Keep link text descriptive.
Component status
| Contract | Current value |
|---|---|
| Maturity | stable |
| Category | navigation |
| Component import | @tavojs/ui/menubar |
| Explicit CSS import | @tavojs/ui/css/menubar |
| Preview | Interactive preview available on this page |