Skip to main content

Navigation Menu

View as Markdown

A collection of links and menus for website navigation.

Features

Installation

typo3 ui:add navigation-menu

Read more about installing Components and Primitives.

Examples

Simple Dropdown

Render navigation items with inline dropdown content.

Use the navigation menu as a simple list of links, including a current page link.

With Viewport

Use withViewport="{true}" to render dropdown content inside a shared viewport. This pattern works well for richer header navigation with animated transitions and an indicator.

API Reference

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

navigationMenu.root

Provides shared navigation menu state and semantics. Renders a <nav> element.

NameDescriptionRequiredDefault
orientationEnum\Orientation
The orientation of the navigation menu.
No
Horizontal
defaultValuestring
The default value of the navigation menu. Use when you don't want to control the value of the menu.
No
''
openDelayinteger
The delay before the menu opens.
No
200
closeDelayinteger
The delay before the menu closes.
No
300
disableHoverTriggerboolean
Whether to disable the hover trigger.
No
-
disableClickTriggerboolean
Whether to disable the click trigger.
No
-
disablePointerLeaveCloseboolean
Whether to disable the pointer leave close.
No
-
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
controlledboolean
If true, the component is meant to be initialized manually inside another component
No
false
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partroot
data-orientationThe orientation of the navigation-menu

navigationMenu.list

Groups the top-level navigation items. Renders a <ul> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partlist
data-orientationThe orientation of the list

navigationMenu.item

Wraps a single navigation item and its related parts. Renders an <li> element.

NameDescriptionRequiredDefault
valuestring
The value of the item.
Yes
-
disabledboolean
Whether the item is disabled.
No
-
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partitem
data-valueThe value of the item
data-state"open" | "closed"
data-orientationThe orientation of the item
data-disabledPresent when disabled

navigationMenu.trigger

Opens and closes the related navigation content. Renders a <button> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-parttrigger
data-trigger-proxy-id
data-valueThe value of the item
data-state"open" | "closed"
data-disabledPresent when disabled

navigationMenu.triggerProxy

Provides a hidden focus proxy for shared viewport behavior. Renders a <span> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-parttrigger-proxy
data-trigger-proxy
data-trigger-id

navigationMenu.link

Renders a navigational link item. Renders an <a> element.

NameDescriptionRequiredDefault
valuestring
The value of the item this link belongs to. By default this is inherited from the parent navigationMenu.item.
No
-
currentboolean
Whether the link is the current page.
No
-
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partlink
data-valueThe value of the item
data-currentPresent when current

navigationMenu.indicatorTrack

Provides a track for the active-item indicator. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

navigationMenu.indicator

Displays the shared active-item indicator. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partindicator
data-state"open" | "closed"
data-orientationThe orientation of the indicator

navigationMenu.itemIndicator

Displays an indicator for an open item. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partitem-indicator
data-state"open" | "closed"
data-orientationThe orientation of the item
data-valueThe value of the item

navigationMenu.content

Contains the popup content for a navigation item. Renders a <div> element.

NameDescriptionRequiredDefault
valuestring
The value of the item this content belongs to.
No
-
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partcontent
data-state"open" | "closed"
data-orientationThe orientation of the content
data-valueThe value of the item

navigationMenu.viewportPositioner

Positions the shared viewport element. Renders a <div> element.

NameDescriptionRequiredDefault
alignEnum\NavigationMenuAlign
Placement of the viewport for CSS variables `--viewport-x` and `--viewport-y`.
No
Center
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partviewport-positioner
data-orientationThe orientation of the viewportpositioner
data-align

navigationMenu.viewport

Displays the shared viewport that can host item content. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partviewport
data-state"open" | "closed"
data-orientationThe orientation of the viewport
data-align

navigationMenu.viewportProxy

Provides a proxy element used to size and align the viewport. Renders a <span> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

navigationMenu.arrow

Displays a decorative arrow for the indicator or content. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopenavigation-menu
data-partarrow
data-orientationThe orientation of the arrow

Machine JavaScript API

NameTypeDescription
valuestring | nullThe current value of the menu
setValue(value: string) => voidSets the value of the menu
openbooleanWhether the menu is open
isViewportRenderedbooleanWhether the viewport is rendered
getViewportNode() => HTMLElement | nullGets the viewport node element
orientationOrientationThe orientation of the menu
repositionVoidFunctionFunction to reposition the viewport

Accessibility

KeyDescription
ArrowDownWhen focus is on trigger (vertical orientation), moves focus to the next trigger.
ArrowUpWhen focus is on trigger (vertical orientation), moves focus to the previous trigger.
ArrowRightWhen focus is on trigger (horizontal orientation), moves focus to the next trigger.
When focus is on content, moves focus to the next link.
ArrowLeftWhen focus is on trigger (horizontal orientation), moves focus to the previous trigger.
When focus is on content, moves focus to the previous link.
HomeWhen focus is on trigger, moves focus to the first trigger.
When focus is on content, moves focus to the first link.
EndWhen focus is on trigger, moves focus to the last trigger.
When focus is on content, moves focus to the last link.

Anatomy

<primitives:navigationMenu.root>
    <primitives:navigationMenu.list>
        <primitives:navigationMenu.item>
            <primitives:navigationMenu.trigger />
            <primitives:navigationMenu.content>
                <primitives:navigationMenu.link />
            </primitives:navigationMenu.content>
        </primitives:navigationMenu.item>

        <primitives:navigationMenu.item>
            <primitives:navigationMenu.link />
        </primitives:navigationMenu.item>
    </primitives:navigationMenu.list>
</primitives:navigationMenu.root>

When using the shared viewport pattern, add the optional viewport-related parts:

<primitives:navigationMenu.root>
    <primitives:navigationMenu.list>
        <primitives:navigationMenu.item>
            <primitives:navigationMenu.trigger />
            <primitives:navigationMenu.triggerProxy />
            <primitives:navigationMenu.viewportProxy />
        </primitives:navigationMenu.item>
    </primitives:navigationMenu.list>

    <primitives:navigationMenu.indicator>
        <primitives:navigationMenu.arrow />
    </primitives:navigationMenu.indicator>

    <primitives:navigationMenu.viewportPositioner>
        <primitives:navigationMenu.viewport>
            <primitives:navigationMenu.content>
                <primitives:navigationMenu.link />
            </primitives:navigationMenu.content>
        </primitives:navigationMenu.viewport>
    </primitives:navigationMenu.viewportPositioner>
</primitives:navigationMenu.root>