Skip to main content

Starwind UI v3.0 beta is now available! Read the migration guide

Navigation Menu

Navigation Menu provides Runtime-backed navigation disclosure, focus management, and floating content positioning.

Installation

Framework Availability

Astro Available React Available

Navigation Menu is available for Astro and React.

Usage

---
import {
NavigationMenu,
NavigationMenuContent,
NavigationMenuItem,
NavigationMenuLink,
NavigationMenuList,
NavigationMenuTrigger,
} from "@/components/starwind/navigation-menu";
---
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem value="item-one">
<NavigationMenuTrigger>Item One</NavigationMenuTrigger>
<NavigationMenuContent>
<NavigationMenuLink href="/docs/">Link</NavigationMenuLink>
</NavigationMenuContent>
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>

Composition

Use the following composition to build a NavigationMenu:

NavigationMenu
├── NavigationMenuList
│ ├── NavigationMenuItem
│ │ ├── NavigationMenuTrigger
│ │ └── NavigationMenuContent
│ │ ├── NavigationMenuLink
│ │ └── NavigationMenuLink
│ └── NavigationMenuItem
│ └── NavigationMenuLink
└── NavigationMenuIndicator

API Reference

Styled Component API

These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.

Navigation Menu

Inherits nav attributes. Omits `defaultValue`, `onChange`, and `value`.

Contains the following additional props:

Prop Type Default Toggle details
align "start" | "center" | "end" "start"
Description
Aligns the component within its available axis.
Classification
Wrapper prop
alignOffset number 0
Description
Offsets the component from its selected alignment in pixels.
Classification
Wrapper prop
avoidCollisions boolean true
Description
Repositions floating content to keep it inside the collision boundary.
Classification
Wrapper prop
collisionPadding number 8
Description
Sets the minimum space retained around a collision boundary.
Classification
Wrapper prop
side "top" | "right" | "bottom" | "left" "bottom"
Description
Selects the preferred side for floating content.
Classification
Wrapper prop
sideOffset number 8
Description
Sets the distance in pixels between floating content and its anchor.
Classification
Wrapper prop

Navigation Menu Item

Inherits li attributes.

Contains the following additional props:

Prop Type Default Toggle details
value string
Description
Controls or identifies the component value.
Classification
Wrapper prop

Navigation Menu Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean false
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
navigation-menu.Trigger.asChild
closeDelay number
Description
Sets the delay in milliseconds before closing.
Classification
Primitive override
Primitive prop
navigation-menu.Trigger.closeDelay
iconClass string
Description
Adds classes to the component's generated icon.
Classification
Wrapper prop
openDelay number
Description
Sets the delay in milliseconds before opening.
Classification
Primitive override
Primitive prop
navigation-menu.Trigger.openDelay
showIcon boolean true
Description
Shows the component's generated icon.
Classification
Wrapper prop

Navigation Menu Positioner

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
sideOffset number 8
Description
Sets the distance in pixels between floating content and its anchor.
Classification
Primitive override
Primitive prop
navigation-menu.Positioner.sideOffset

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Navigation Menu.

Runtime API

Navigation Menu primitive
createNavigationMenu from @starwind-ui/runtime/navigation-menu

Changelog

v1.0.0

  • Added the Runtime-backed Navigation Menu with keyboard navigation and shared viewport behavior.
  • See the Navigation Menu Primitive for the underlying unstyled anatomy and behavior API.