NavigationMenu
Horizontal or vertical destination list with current-page semantics.
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 { NavigationMenu } from "@tavojs/ui/navigation-menu";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/navigation-menu.
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.
NavigationMenu example
tsximport { NavigationMenu } from "@tavojs/ui/navigation-menu";
export function NavigationMenuExample1() {
return (
<>
<NavigationMenu items={[{ label: "Overview", href: "/", current: true }, { 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 NavigationMenu. |
aria-label | string | — | Accessible label for navigation landmarks when needed. Applies to NavigationMenu. |
children | Child | — | Navigation content or custom item structure. Applies to NavigationMenu. |
Complete TypeScript API
Import from @tavojs/ui/navigation-menu. Published exports: NavigationMenu, NavigationMenuItem, NavigationMenuProps.
NavigationMenuProps
| Property | Type | Required | Description |
|---|---|---|---|
children | Child | No | Navigation content or custom item structure. Applies to NavigationMenu. |
className | string | No | Optional class hook applied to the public root element owned by the component. |
sx | Sx | No | Inherited sx attribute accepted by NavigationMenu. |
id | string | No | Inherited id attribute accepted by NavigationMenu. |
role | string | No | Inherited role attribute accepted by NavigationMenu. |
style | Record<string, unknown> | No | Inherited style attribute accepted by NavigationMenu. |
title | string | No | Inherited title attribute accepted by NavigationMenu. |
tabIndex | number | No | Inherited tabIndex attribute accepted by NavigationMenu. |
hidden | boolean | No | Inherited hidden attribute accepted by NavigationMenu. |
disabled | boolean | No | Inherited disabled attribute accepted by NavigationMenu. |
onClick | TavoEventHandler<MouseEvent> | No | Inherited onClick attribute accepted by NavigationMenu. |
onChange | TavoEventHandler<Event> | No | Inherited onChange attribute accepted by NavigationMenu. |
onInput | TavoEventHandler<Event> | No | Inherited onInput attribute accepted by NavigationMenu. |
onKeyDown | TavoEventHandler<KeyboardEvent> | No | Inherited onKeyDown attribute accepted by NavigationMenu. |
onFocus | TavoEventHandler<FocusEvent> | No | Inherited onFocus attribute accepted by NavigationMenu. |
onBlur | TavoEventHandler<FocusEvent> | No | Inherited onBlur attribute accepted by NavigationMenu. |
items | NavigationMenuItem[] | No | Navigation items when supported by the component. Applies to NavigationMenu. |
orientation | "horizontal" | "vertical" | No | Inherited orientation attribute accepted by NavigationMenu. |
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
Limitations
Use DropdownMenu for contextual commands, Tabs for switching panels without navigation, and ToggleGroup for choosing a value.
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/navigation-menu |
| Explicit CSS import | @tavojs/ui/css/navigation-menu |
| Preview | Interactive preview available on this page |