Navigation Menu
A collection of links and menus for website navigation.
import { For } from 'solid-js';
import type { JSX } from '@solidjs/web';
import { NavigationMenu } from 'base-ui-solid/navigation-menu';
import { REPO_URL } from './config';
import styles from './index.module.css';
export default function ExampleNavigationMenu() {
return (
<NavigationMenu.Root class={styles.Root}>
<NavigationMenu.List class={styles.List}>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.Trigger}>
Overview
<NavigationMenu.Icon class={styles.Icon}>
<CaretDownIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={styles.Content}>
<ul class={styles.GridLinkList}>
<For each={overviewLinks}>
{(item) => (
<li>
<Link class={styles.LinkCard} href={item.href}>
<h3 class={styles.LinkTitle}>{item.title}</h3>
<p class={styles.LinkDescription}>{item.description}</p>
</Link>
</li>
)}
</For>
</ul>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.Trigger}>
Handbook
<NavigationMenu.Icon class={styles.Icon}>
<CaretDownIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={styles.Content}>
<ul class={styles.FlexLinkList}>
<For each={handbookLinks}>
{(item) => (
<li>
<Link class={styles.LinkCard} href={item.href}>
<h3 class={styles.LinkTitle}>{item.title}</h3>
<p class={styles.LinkDescription}>{item.description}</p>
</Link>
</li>
)}
</For>
</ul>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<Link class={styles.Trigger} href={REPO_URL}>
GitHub
</Link>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Portal>
<NavigationMenu.Positioner
class={styles.Positioner}
sideOffset={10}
collisionPadding={{ top: 5, bottom: 5, left: 20, right: 20 }}
collisionAvoidance={{ side: 'none' }}
>
<NavigationMenu.Popup class={styles.Popup}>
<NavigationMenu.Arrow class={styles.Arrow} />
<NavigationMenu.Viewport class={styles.Viewport} />
</NavigationMenu.Popup>
</NavigationMenu.Positioner>
</NavigationMenu.Portal>
</NavigationMenu.Root>
);
}
function Link(props: NavigationMenu.Link.Props) {
return (
<NavigationMenu.Link
render={
// Use the `render` prop to render your framework's Link component
// for client-side routing.
// e.g. `<NextLink href={props.href} />` instead of `<a />`.
'a'
}
{...props}
/>
);
}
function CaretDownIcon(
props: Omit<JSX.IntrinsicElements['svg'], 'style'> & { style?: JSX.CSSProperties },
) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="currentColor"
{...props}
style={{ display: 'block', ...props.style }}
>
<path d="M12 6H4l4 4.5z" />
</svg>
);
}
const overviewLinks = [
{
href: '/solid/overview/quick-start',
title: 'Quick Start',
description: 'Install and assemble your first component.',
},
{
href: '/solid/overview/accessibility',
title: 'Accessibility',
description: 'Learn how we build accessible components.',
},
{
href: '/solid/overview/releases',
title: 'Releases',
description: 'See what’s new in the latest Base UI versions.',
},
{
href: '/solid/overview/about',
title: 'About',
description: 'Learn more about Base UI and our mission.',
},
] as const;
const handbookLinks = [
{
href: '/solid/handbook/styling',
title: 'Styling',
description:
'Base UI components can be styled with plain CSS, Tailwind CSS, CSS-in-JS, or CSS Modules.',
},
{
href: '/solid/handbook/animation',
title: 'Animation',
description:
'Base UI components can be animated with CSS transitions, CSS animations, or JavaScript libraries.',
},
{
href: '/solid/handbook/composition',
title: 'Composition',
description:
'Base UI components can be replaced and composed with your own existing components.',
},
] as const;
Anatomy
Import the component and assemble its parts:
import { NavigationMenu } from 'base-ui-solid/navigation-menu';
<NavigationMenu.Root>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Trigger>
<NavigationMenu.Icon />
</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Link />
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Portal>
<NavigationMenu.Backdrop />
<NavigationMenu.Positioner>
<NavigationMenu.Popup>
<NavigationMenu.Arrow />
<NavigationMenu.Viewport />
</NavigationMenu.Popup>
</NavigationMenu.Positioner>
</NavigationMenu.Portal>
</NavigationMenu.Root>;
Examples
Nested submenus
<NavigationMenu.Root> component can be nested within a higher-level <NavigationMenu.Content> part to create a multi-level navigation menu.
import { For } from 'solid-js';
import type { JSX } from '@solidjs/web';
import { NavigationMenu } from 'base-ui-solid/navigation-menu';
import styles from './index.module.css';
export default function ExampleNavigationMenu() {
return (
<NavigationMenu.Root class={styles.Root}>
<NavigationMenu.List class={styles.List}>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.Trigger}>
Overview
<NavigationMenu.Icon class={styles.Icon}>
<CaretDownIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={styles.Content}>
<ul class={styles.GridLinkList}>
<For each={overviewLinks}>
{(item) => (
<li>
<Link class={styles.LinkCard} href={item.href}>
<h3 class={styles.LinkTitle}>{item.title}</h3>
<p class={styles.LinkDescription}>{item.description}</p>
</Link>
</li>
)}
</For>
<li>
<NavigationMenu.Root orientation="vertical">
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.LinkCard}>
<span class={styles.LinkTitle}>Handbook</span>
<p class={styles.LinkDescription}>How to use Base UI effectively.</p>
<NavigationMenu.Icon class={styles.NestedIcon}>
<CaretRightIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={styles.Content}>
<ul class={styles.FlexLinkList}>
<For each={handbookLinks}>
{(item) => (
<li>
<Link class={styles.LinkCard} href={item.href}>
<h3 class={styles.LinkTitle}>{item.title}</h3>
<p class={styles.LinkDescription}>{item.description}</p>
</Link>
</li>
)}
</For>
</ul>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Portal>
<NavigationMenu.Positioner
class={styles.Positioner}
sideOffset={8}
alignOffset={-8}
align="end"
side="right"
>
<NavigationMenu.Popup class={styles.Popup}>
<NavigationMenu.Viewport class={styles.Viewport} />
</NavigationMenu.Popup>
</NavigationMenu.Positioner>
</NavigationMenu.Portal>
</NavigationMenu.Root>
</li>
</ul>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Portal>
<NavigationMenu.Positioner
class={styles.Positioner}
sideOffset={10}
collisionPadding={{ top: 5, bottom: 5, left: 20, right: 20 }}
>
<NavigationMenu.Popup class={styles.Popup}>
<NavigationMenu.Arrow class={styles.Arrow} />
<NavigationMenu.Viewport class={styles.Viewport} />
</NavigationMenu.Popup>
</NavigationMenu.Positioner>
</NavigationMenu.Portal>
</NavigationMenu.Root>
);
}
function Link(props: NavigationMenu.Link.Props) {
return (
<NavigationMenu.Link
render={
// Use the `render` prop to render your framework's Link component
// for client-side routing.
// e.g. `<NextLink href={props.href} />` instead of `<a />`.
'a'
}
{...props}
/>
);
}
function CaretDownIcon(
props: Omit<JSX.IntrinsicElements['svg'], 'style'> & { style?: JSX.CSSProperties },
) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="currentColor"
{...props}
style={{ display: 'block', ...props.style }}
>
<path d="M12 6H4l4 4.5z" />
</svg>
);
}
function CaretRightIcon(
props: Omit<JSX.IntrinsicElements['svg'], 'style'> & { style?: JSX.CSSProperties },
) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="currentColor"
{...props}
style={{ display: 'block', ...props.style }}
>
<path d="M6 12V4l4.5 4z" />
</svg>
);
}
const overviewLinks = [
{
href: '/solid/overview/quick-start',
title: 'Quick Start',
description: 'Install and assemble your first component.',
},
{
href: '/solid/overview/accessibility',
title: 'Accessibility',
description: 'Learn how we build accessible components.',
},
{
href: '/solid/overview/releases',
title: 'Releases',
description: 'See what’s new in the latest Base UI versions.',
},
] as const;
const handbookLinks = [
{
href: '/solid/handbook/styling',
title: 'Styling',
description:
'Base UI components can be styled with plain CSS, Tailwind CSS, CSS-in-JS, or CSS Modules.',
},
{
href: '/solid/handbook/animation',
title: 'Animation',
description:
'Base UI components can be animated with CSS transitions, CSS animations, or JavaScript libraries.',
},
{
href: '/solid/handbook/composition',
title: 'Composition',
description:
'Base UI components can be replaced and composed with your own existing components.',
},
] as const;
Nested inline submenus
For second-level navigation that should stay in the same panel, omit the nested <NavigationMenu.Portal> and render only List + Viewport with a defaultValue.
import { For } from 'solid-js';
import type { JSX } from '@solidjs/web';
import { NavigationMenu } from 'base-ui-solid/navigation-menu';
import { useMediaQuery } from 'base-ui-solid/unstable-use-media-query';
import { REPO_URL } from './config';
import { audienceMenus, guideLinks, guidesPanel } from './data';
import styles from './index.module.css';
export default function ExampleNavigationMenu() {
const isDesktop = useMediaQuery(
() => '(min-width: 700px)',
() => ({ defaultMatches: true }),
);
return (
<NavigationMenu.Root class={styles.Root}>
<NavigationMenu.List class={styles.List}>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.Trigger}>
Product
<NavigationMenu.Icon class={styles.Icon}>
<CaretDownIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={[styles.Content, styles.ProductContent]}>
<NavigationMenu.Root
class={styles.SubmenuRoot}
orientation={isDesktop() ? 'vertical' : 'horizontal'}
defaultValue="developers"
>
<div class={styles.SubmenuLayout}>
<NavigationMenu.List class={styles.SubmenuList}>
<For each={audienceMenus}>
{(menu) => (
<NavigationMenu.Item value={menu.value}>
<NavigationMenu.Trigger class={styles.SubmenuTrigger}>
<span class={styles.SubmenuLabel}>{menu.label}</span>
<span class={styles.SubmenuHint}>{menu.hint}</span>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={styles.SubmenuContent}>
<div>
<h4 class={styles.SubmenuTitle}>{menu.title}</h4>
<p class={styles.SubmenuDescription}>{menu.description}</p>
</div>
<ul class={styles.LinkList}>
<For each={menu.links}>
{(link) => (
<li>
<Link class={styles.LinkCard} href={link.href}>
<h5 class={styles.LinkTitle}>{link.title}</h5>
<p class={styles.LinkDescription}>{link.description}</p>
</Link>
</li>
)}
</For>
</ul>
</NavigationMenu.Content>
</NavigationMenu.Item>
)}
</For>
</NavigationMenu.List>
<NavigationMenu.Viewport class={styles.SubmenuViewport} />
</div>
</NavigationMenu.Root>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Trigger class={styles.Trigger}>
Learn
<NavigationMenu.Icon class={styles.Icon}>
<CaretDownIcon />
</NavigationMenu.Icon>
</NavigationMenu.Trigger>
<NavigationMenu.Content class={[styles.Content, styles.GuidesContent]}>
<div class={styles.GuidesPanel}>
<div>
<h4 class={styles.SubmenuTitle}>{guidesPanel.title}</h4>
<p class={styles.SubmenuDescription}>{guidesPanel.description}</p>
</div>
<ul class={styles.LinkList}>
<For each={guideLinks}>
{(link) => (
<li>
<Link class={styles.LinkCard} href={link.href}>
<h5 class={styles.LinkTitle}>{link.title}</h5>
<p class={styles.LinkDescription}>{link.description}</p>
</Link>
</li>
)}
</For>
</ul>
</div>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<Link class={styles.Trigger} href="/solid/overview/releases">
Releases
</Link>
</NavigationMenu.Item>
<NavigationMenu.Item>
<Link class={styles.Trigger} href={REPO_URL}>
GitHub
</Link>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Portal>
<NavigationMenu.Positioner
class={styles.Positioner}
sideOffset={10}
collisionPadding={{ top: 5, bottom: 5, left: 20, right: 20 }}
collisionAvoidance={{ side: 'none' }}
>
<NavigationMenu.Popup class={styles.Popup}>
<NavigationMenu.Arrow class={styles.Arrow} />
<NavigationMenu.Viewport class={styles.Viewport} />
</NavigationMenu.Popup>
</NavigationMenu.Positioner>
</NavigationMenu.Portal>
</NavigationMenu.Root>
);
}
function Link(props: NavigationMenu.Link.Props) {
return (
<NavigationMenu.Link
render={
// Use the `render` prop to render your framework's Link component
// for client-side routing.
// e.g. `<NextLink href={props.href} />` instead of `<a />`.
'a'
}
{...props}
/>
);
}
function CaretDownIcon(
props: Omit<JSX.IntrinsicElements['svg'], 'style'> & { style?: JSX.CSSProperties },
) {
return (
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="currentColor"
{...props}
style={{ display: 'block', ...props.style }}
>
<path d="M12 6H4l4 4.5z" />
</svg>
);
}
Custom links
The <NavigationMenu.Link> part can be customized to render the link from your framework using the render prop to enable client-side routing.
import NextLink from 'next/link';
import { NavigationMenu } from 'base-ui-solid/navigation-menu';
function Link(props: NavigationMenu.Link.Props) {
return (
<NavigationMenu.Link
render={(renderProps) => <NextLink {...renderProps} href={props.href} />}
{...props}
/>
);
}
Large menus
When you have large menu content that doesn’t fit in the viewport in some cases, you usually have two choices:
- Compress the navigation menu content
You can change the layout of the navigation menu to render less content or be more compact by reducing the space it takes up.
If your content is flexible, you can use the max-height property on .Popup to limit the height of the navigation menu to let it compress itself while preventing overflow.
.Content,
.Popup {
max-height: var(--available-height);
}
- Make the navigation menu scrollable
.Content,
.Popup {
max-height: var(--available-height);
}
.Content {
overflow-y: auto;
}
Native scrollbars are visible while transitioning content, so we recommend using the Scroll Area component instead of native scrollbars to keep them hidden, which also allows the Arrow to be centered correctly.
Closing animations
The popup stays rendered until its closing animation finishes.
See JavaScript animations for animating it with Motion and for manual control.
For Navigation Menu, call eventDetails.preventUnmountOnClose() in onValueChange when the value becomes null, and use actionsRef.current.close() instead of setting value to null directly.
API reference
Root
Groups all parts of the navigation menu.
Renders a <nav> element at the root, or <div> element when nested.
defaultValueUnionnull
value prop instead.Value | nullvalueUnionnull
defaultValue prop instead.Value | nullonValueChangefunction—
((value: Value | null, eventDetails: NavigationMenu.Root.ChangeEventDetails) => void)actionsRefRefObject<NavigationMenu.Root.Actions | null>—
unmount: Ends the closing phase of the navigation menu popup after an externally controlled closing animation finishes.
Call preventUnmountOnClose() in onValueChange first, otherwise the navigation menu popup completes closing on its own.
Whether it leaves the DOM is decided by keepMounted on the portal.close: Closes the navigation menu imperatively when called.RefObject<NavigationMenu.Root.Actions | null>onOpenChangeCompletefunction—
((open: boolean) => void)delaynumber50
numbercloseDelaynumber50
numberorientationUnion'horizontal'
'horizontal' | 'vertical'classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Root.State
type NavigationMenuRootState = {
/** If `true`, the popup is open. */
open: boolean;
/** Whether the navigation menu is nested. */
nested: boolean;
};Root.Actions
type NavigationMenuRootActions = { unmount: () => void; close: () => void };Root.ChangeEventReason
type NavigationMenuRootChangeEventReason =
| 'trigger-press'
| 'trigger-hover'
| 'outside-press'
| 'list-navigation'
| 'focus-out'
| 'escape-key'
| 'link-press'
| 'imperative-action'
| 'none';Root.ChangeEventDetails
type NavigationMenuRootChangeEventDetails = (
| { reason: 'trigger-press'; event: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent }
| { reason: 'trigger-hover'; event: MouseEvent }
| { reason: 'outside-press'; event: MouseEvent | PointerEvent | TouchEvent }
| { reason: 'list-navigation'; event: KeyboardEvent }
| { reason: 'focus-out'; event: KeyboardEvent | FocusEvent }
| { reason: 'escape-key'; event: KeyboardEvent }
| { reason: 'link-press'; event: MouseEvent | PointerEvent }
| { reason: 'imperative-action'; event: Event }
| { reason: 'none'; event: Event }
) & {
/** Cancels Base UI from handling the event. */
cancel: () => void;
/** Allows the event to propagate in cases where Base UI will stop the propagation. */
allowPropagation: () => void;
/** Indicates whether the event has been canceled. */
isCanceled: boolean;
/** Indicates whether the event is allowed to propagate. */
isPropagationAllowed: boolean;
/** The element that triggered the event, if applicable. */
trigger: Element | undefined;
/** Prevents the popup from unmounting until the `unmount` action is called. */
preventUnmountOnClose: () => void;
};Root.Value
type NavigationMenuRootValue<TValue = any> = TValue | null;List
Contains a list of navigation menu items.
Renders a <ul> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)List.State
type NavigationMenuListState = {
/** If `true`, the popup is open. */
open: boolean;
};Item
An individual navigation menu item.
Renders a <li> element.
valueany—
anyclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Item.State
type NavigationMenuItemState = {};Trigger
Opens the navigation menu popup when hovered or clicked, revealing the
associated content.
Renders a <button> element.
nativeButtonbooleantrue
<button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>).booleandisabledbooleanfalse
booleanclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-popup-open-—
-data-pressed-—
-data-disabled-—
-Attribute | Description | |
|---|---|---|
data-popup-open | Present when the corresponding navigation menu is open. | |
data-pressed | Present when the trigger is pressed. | |
data-disabled | Present when the trigger is disabled. | |
Trigger.State
type NavigationMenuTriggerState = {
/** If `true`, the popup is open and the item is active. */
open: boolean;
/** Whether the component should ignore user interaction. */
disabled: boolean;
};Icon
An icon that indicates that the trigger button opens a menu.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-popup-open-—
-Attribute | Description | |
|---|---|---|
data-popup-open | Present when the navigation menu is open and the item is active. | |
Icon.State
type NavigationMenuIconState = {
/** Whether the navigation menu is open and the item is active. */
open: boolean;
};Content
A container for the content of the navigation menu item that is moved into the popup
when the item is active.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)keepMountedbooleanfalse
booleanrenderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-activation-directionUnion—
'left' | 'right' | 'up' | 'down'data-starting-style-—
-data-ending-style-—
-Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-activation-direction | Which direction another trigger was activated from. | |
data-starting-style | Present when the content begins animating in. | |
data-ending-style | Present when the content is animating out. | |
Content.State
type NavigationMenuContentState = {
/** If `true`, the component is open. */
open: boolean;
/** The transition status of the component. */
transitionStatus: TransitionStatus;
/** The direction of the activation. */
activationDirection: 'left' | 'right' | 'up' | 'down' | null;
};Link
A link in the navigation menu that can be used to navigate to a different page or section.
Renders an <a> element.
closeOnClickbooleanfalse
booleanactivebooleanfalse
booleanclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-active-—
-Attribute | Description | |
|---|---|---|
data-active | Present when the link is the currently active page. | |
Link.State
type NavigationMenuLinkState = {
/** Whether the link is the currently active page. */
active: boolean;
};Backdrop
A backdrop for the navigation menu popup.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-starting-style-—
-data-ending-style-—
-Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-starting-style | Present when the popup begins animating in. | |
data-ending-style | Present when the popup is animating out. | |
Backdrop.State
type NavigationMenuBackdropState = {
/** If `true`, the popup is open. */
open: boolean;
/** The transition status of the popup. */
transitionStatus: TransitionStatus;
};Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>.
Renders a <div> element.
containerUnion—
HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | nullclassfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)keepMountedbooleanfalse
booleanrenderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Portal.State
type NavigationMenuPortalState = {};Positioner
Positions the navigation menu against the currently active trigger.
Renders a <div> element.
disableAnchorTrackingbooleanfalse
booleanalignAlign'center'
AlignalignOffsetUnion0
data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.number | OffsetFunctionsideSide'bottom'
SidesideOffsetUnion0
data object parameter with the following properties: data.anchor: the dimensions of the anchor element with properties width and height.data.positioner: the dimensions of the positioner element with properties width and height.data.side: which side of the anchor element the positioner is aligned against.data.align: how the positioner is aligned relative to the specified side.number | OffsetFunctionarrowPaddingnumber5
numberanchorfunction—
Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | nullcollisionAvoidanceCollisionAvoidance—
side controls overflow on the preferred placement axis (top/bottom or left/right): 'flip': keep the requested side when it fits; otherwise try the opposite side
(top and bottom, or left and right).'shift': never change side; keep the requested side and move the popup within
the clipping boundary so it stays visible.'none': do not correct side-axis overflow. align controls overflow on the alignment axis (start/center/end): 'flip': keep side, but swap start and end when the requested alignment overflows.'shift': keep side and requested alignment, then nudge the popup along the
alignment axis to fit.'none': do not correct alignment-axis overflow. fallbackAxisSide controls fallback behavior on the perpendicular axis when the
preferred axis cannot fit: 'start': allow perpendicular fallback and try the logical start side first
(top before bottom, or left before right in LTR).'end': allow perpendicular fallback and try the logical end side first
(bottom before top, or right before left in LTR).'none': do not fallback to the perpendicular axis. When side is 'shift', explicitly setting align only supports 'shift' or 'none'.
If align is omitted, it defaults to 'flip'.CollisionAvoidancecollisionBoundaryBoundary'clipping-ancestors'
BoundarycollisionPaddingPadding5
Paddingstickybooleanfalse
booleanpositionMethodUnion'absolute'
position property to use.'absolute' | 'fixed'classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-anchor-hidden-—
-data-alignUnion—
'start' | 'center' | 'end'data-instant-—
-data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-align | Indicates how the popup is aligned relative to the specified side. | |
data-instant | Present if animations should be instant. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
CSS variables
--anchor-heightnumber—
number--anchor-widthnumber—
number--available-heightnumber—
number--available-widthnumber—
number--positioner-heightnumber—
number--positioner-widthnumber—
number--transform-originstring—
stringCSS Variable | Description | |
|---|---|---|
--anchor-height | The anchor’s height. | |
--anchor-width | The anchor’s width. | |
--available-height | The available height between the trigger and the edge of the viewport. | |
--available-width | The available width between the trigger and the edge of the viewport. | |
--positioner-height | The fixed height of the positioner element. | |
--positioner-width | The fixed width of the positioner element. | |
--transform-origin | The coordinates that this element is anchored to. Used for animations and transitions. | |
Positioner.State
type NavigationMenuPositionerState = {
/** Whether the navigation menu is currently open. */
open: boolean;
/** The side of the anchor the component is placed on. */
side: Side;
/** The alignment of the component relative to the anchor. */
align: Align;
/** Whether the anchor element is hidden. */
anchorHidden: boolean;
/** Whether CSS transitions should be disabled. */
instant: boolean;
};Popup
A container for the navigation menu contents.
Renders a <nav> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-anchor-hidden-—
-data-alignUnion—
'start' | 'center' | 'end'data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'data-starting-style-—
-data-ending-style-—
-Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-anchor-hidden | Present when the anchor is hidden. | |
data-align | Indicates how the popup is aligned relative to the specified side. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
data-starting-style | Present when the popup begins animating in. | |
data-ending-style | Present when the popup is animating out. | |
CSS variables
--popup-heightnumber—
number--popup-widthnumber—
numberCSS Variable | Description | |
|---|---|---|
--popup-height | The fixed height of the popup element. | |
--popup-width | The fixed width of the popup element. | |
Popup.State
type NavigationMenuPopupState = {
/** If `true`, the popup is open. */
open: boolean;
/** The transition status of the popup. */
transitionStatus: TransitionStatus;
/** The side of the anchor the popup is positioned on. */
side: Side;
/** The alignment of the popup relative to the anchor. */
align: Align;
/** Whether the anchor element is hidden. */
anchorHidden: boolean;
};Viewport
The clipping viewport of the navigation menu’s current content.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Viewport.State
type NavigationMenuViewportState = {};Arrow
Displays an element pointing toward the navigation menu’s current anchor.
Renders a <div> element.
classfunction—
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Data attributes
data-open-—
-data-closed-—
-data-uncentered-—
-data-alignUnion—
'start' | 'center' | 'end'data-sideUnion—
'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'Attribute | Description | |
|---|---|---|
data-open | Present when the popup is open. | |
data-closed | Present when the popup is closed. | |
data-uncentered | Present when the popup arrow is uncentered. | |
data-align | Indicates how the popup is aligned relative to specified side. | |
data-side | Indicates which side the popup is positioned relative to the trigger. | |
Arrow.State
type NavigationMenuArrowState = {
/** Whether the popup is currently open. */
open: boolean;
/** The side of the anchor the component is placed on. */
side: Side;
/** The alignment of the component relative to the anchor. */
align: Align;
/** Whether the arrow cannot be centered on the anchor. */
uncentered: boolean;
};