Skip to contents

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:

Anatomy
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>
  );
}

The <NavigationMenu.Link> part can be customized to render the link from your framework using the render prop to enable client-side routing.

Next.js example
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:

  1. 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.

Compact layout
.Content,
.Popup {
  max-height: var(--available-height);
}
  1. Make the navigation menu scrollable
Scrollable layout
.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.

Prop
Type
Default
defaultValueUnionnull
The uncontrolled value of the item that should be initially selected. To render a controlled navigation menu, use the value prop instead.Value | null
valueUnionnull
The controlled value of the navigation menu item that should be currently open. When non-nullish, the menu will be open. When nullish, the menu will be closed. To render an uncontrolled navigation menu, use the defaultValue prop instead.Value | null
onValueChangefunction—
Callback fired when the value changes.((value: Value | null, eventDetails: NavigationMenu.Root.ChangeEventDetails) => void)
actionsRefRefObject<NavigationMenu.Root.Actions | null>—
A ref to imperative actions. 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—
Event handler called after any animations complete when the navigation menu is closed.((open: boolean) => void)
delaynumber50
How long to wait before opening the navigation popup. Specified in milliseconds.number
closeDelaynumber50
How long to wait before closing the navigation popup. Specified in milliseconds.number
orientationUnion'horizontal'
The orientation of the navigation menu.'horizontal' | 'vertical'
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.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.

Prop
Type
Default
valueany—
A unique value that identifies this navigation menu item. If no value is provided, a unique ID will be generated automatically. Use when controlling the navigation menu programmatically.any
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.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.

Prop
Type
Default
nativeButtonbooleantrue
Whether the component renders a native <button> element when replacing it via the render prop. Set to false if the rendered element is not a button (for example, <div>).boolean
disabledbooleanfalse
Whether the component should ignore user interaction.boolean
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
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.-
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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
data-popup-open-—
Present when the navigation menu is open and the item is active.-
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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
keepMountedbooleanfalse
Whether to keep the content mounted in the DOM while the popup is closed. Ensures the content is present during server-side rendering for web crawlers.boolean
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
data-open-—
Present when the popup is open.-
data-closed-—
Present when the popup is closed.-
data-activation-directionUnion—
Which direction another trigger was activated from.'left' | 'right' | 'up' | 'down'
data-starting-style-—
Present when the content begins animating in.-
data-ending-style-—
Present when the content is animating out.-
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;
};

A link in the navigation menu that can be used to navigate to a different page or section. Renders an <a> element.

Prop
Type
Default
closeOnClickbooleanfalse
Whether to close the navigation menu when the link is clicked.boolean
activebooleanfalse
Whether the link is the currently active page.boolean
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
data-active-—
Present when the link is the currently active page.-
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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
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.-
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.

Prop
Type
Default
containerUnion—
A parent element to render the portal element into.HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
keepMountedbooleanfalse
Whether to keep the portal mounted in the DOM while the popup is hidden.boolean
renderfunction—
Replace the default element with a tag name, component, or render function.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.

Prop
Type
Default
disableAnchorTrackingbooleanfalse
Whether to disable the popup from tracking any layout shift of its positioning anchor.boolean
alignAlign'center'
How to align the popup relative to the specified side.Align
alignOffsetUnion0
Additional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a 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 | OffsetFunction
sideSide'bottom'
Which side of the anchor element to align the popup against. May automatically change to avoid collisions.Side
sideOffsetUnion0
Distance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment. The function takes a 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 | OffsetFunction
arrowPaddingnumber5
Minimum distance to maintain between the arrow and the edges of the popup. Use it to prevent the arrow element from hanging out of the rounded corners of a popup.number
anchorfunction—
An element to position the popup against. By default, the popup will be positioned against the trigger.Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null
collisionAvoidanceCollisionAvoidance—
Determines how to handle collisions when positioning the popup. 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'.CollisionAvoidance
collisionBoundaryBoundary'clipping-ancestors'
An element or a rectangle that delimits the area that the popup is confined to.Boundary
collisionPaddingPadding5
Additional space to maintain from the edge of the collision boundary.Padding
stickybooleanfalse
Whether to maintain the popup in the viewport after the anchor element was scrolled out of view.boolean
positionMethodUnion'absolute'
Determines which CSS position property to use.'absolute' | 'fixed'
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
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-alignUnion—
Indicates how the popup is aligned relative to the specified side.'start' | 'center' | 'end'
data-instant-—
Present if animations should be instant.-
data-sideUnion—
Indicates which side the popup is positioned relative to the trigger.'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

Name
Type
Default
--anchor-heightnumber—
The anchor’s height.number
--anchor-widthnumber—
The anchor’s width.number
--available-heightnumber—
The available height between the trigger and the edge of the viewport.number
--available-widthnumber—
The available width between the trigger and the edge of the viewport.number
--positioner-heightnumber—
The fixed height of the positioner element.number
--positioner-widthnumber—
The fixed width of the positioner element.number
--transform-originstring—
The coordinates that this element is anchored to. Used for animations and transitions.string
CSS 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;
};

A container for the navigation menu contents. Renders a <nav> element.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
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-alignUnion—
Indicates how the popup is aligned relative to the specified side.'start' | 'center' | 'end'
data-sideUnion—
Indicates which side the popup is positioned relative to the trigger.'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'
data-starting-style-—
Present when the popup begins animating in.-
data-ending-style-—
Present when the popup is animating out.-
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

Name
Type
Default
--popup-heightnumber—
The fixed height of the popup element.number
--popup-widthnumber—
The fixed width of the popup element.number
CSS 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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.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.

Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that returns a class based on the component’s state.JSX.ClassValue | ((state) => JSX.ClassValue)
stylefunction—
Style applied to the element, or a function that returns a style object based on the component’s state.JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)
renderfunction—
Replace the default element with a tag name, component, or render function.keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)

Data attributes

Name
Type
Default
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-alignUnion—
Indicates how the popup is aligned relative to specified side.'start' | 'center' | 'end'
data-sideUnion—
Indicates which side the popup is positioned relative to the trigger.'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;
};