EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Navigation·component·@astryxdesign/core

Top Nav

Main navigation bar container with slot-based layout. Children are accepted as an alias for startContent.

Open in Playground @astryxdesign/core/TopNav

Showcases and examples

7 documented examples

Top Nav

TopNav API entry

Preview loads on approachPreview loads on approach
Exact source · top-nav-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {TopNav, TopNavHeading, TopNavItem} from '@astryxdesign/core/TopNav';
import {NavIcon} from '@astryxdesign/core/NavIcon';
import {Button} from '@astryxdesign/core/Button';
import {Icon} from '@astryxdesign/core/Icon';
import {BellIcon, CubeIcon, UserCircleIcon} from '@heroicons/react/24/outline';

export default function TopNavShowcase() {
  return (
    <TopNav
      style={{width: 600}}
      label="Main navigation"
      heading={
        <TopNavHeading
          heading="My App"
          logo={<NavIcon icon={<Icon icon={CubeIcon} size="sm" />} />}
        />
      }
      startContent={
        <>
          <TopNavItem label="Home" href="#" isSelected />
          <TopNavItem label="Products" href="#" />
          <TopNavItem label="About" href="#" />
        </>
      }
      endContent={
        <>
          <Button
            label="Search"
            variant="ghost"
            icon={<Icon icon="search" color="inherit" />}
            isIconOnly
          />
          <Button
            label="Notifications"
            variant="ghost"
            icon={<BellIcon />}
            isIconOnly
          />
          <Button
            label="Profile"
            variant="ghost"
            icon={<UserCircleIcon />}
            isIconOnly
          />
        </>
      }
    />
  );
}

Usage

TopNav is a horizontal navigation bar for product-level navigation in application headers. Use TopNav for 5 or fewer always-visible navigation items, or minimal navigation paired with search and controls. For complex navigation hierarchies, use a sidebar; to filter content, use tabs or filter buttons instead.

  • Include a product logo and name in the heading slot to clearly identify the application.
  • Limit primary navigation items to 5 or fewer for quick scanning and minimal cognitive load.
  • Avoid using TopNav to filter page content; use Tabs or filter controls instead.
  • Avoid deeply nested navigation hierarchies; keep menus to one level of depth.

Typed props

PropType and behavior
headingReactNode
Heading slot content (logo, brand): positioned at the left edge of the nav bar.
Slot: Text
startContentReactNode
Start content slot for navigation items or breadcrumbs: positioned after the heading, left-aligned.
Slot: Icon
childrenReactNode
Alias for startContent. Prefer startContent when composing with heading, centerContent, or endContent; children keeps the common React nav-item pattern from silently dropping items.
centerContentReactNode
Center content slot (tabs, search bar, primary navigation): when provided, switches the layout to a three-column CSS grid for true horizontal centering.
Slot: Text
endContentReactNode
End content slot for search, icons, or user profile: positioned at the right edge.
Slot: Icon, Badge
labelstring · default 'Top navigation'
Accessible label for the navigation landmark, applied as aria-label on the <nav> element.
xstyleStyleXStyles
StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value: not an inline style object like style={{}}.

Anatomy

Product icon and name · required

Identifies the product in the navigation bar.

Navigation items · required

Primary links for product-level destinations.

More menu · optional

Overflow menu for additional navigation items.

Flex area · optional

Flexible region for search, primary action buttons, or other controls.

Theming

Targets

astryx-top-nav

States: mode

astryx-top-nav-item

States: mode, selected

astryx-top-nav-heading
astryx-top-nav-mega-menu

States: mode

astryx-top-nav-mega-menu-item

States: mode

astryx-top-nav-mega-menu-featured-card
astryx-top-nav-menu