XDSTopNavItem@xds/core · TopNav

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.

Best practices

GuidancePractices
DoInclude a product logo and name in the heading slot to clearly identify the application.
DoLimit primary navigation items to 5 or fewer for quick scanning and minimal cognitive load.
Don'tAvoid using TopNav to filter page content — use Tabs or filter controls instead.
Don'tAvoid deeply nested navigation hierarchies — keep menus to one level of depth.

Anatomy

ElementDescription
Product icon and namerequiredIdentifies the product in the navigation bar.
Navigation itemsrequiredPrimary links for product-level destinations.
More menuOverflow menu for additional navigation items.
Flex areaFlexible region for search, primary action buttons, or other controls.

Import

ts
import {XDSTopNavItem} from '@xds/core/TopNav'

Props

PropTypeDescription
labelrequired
stringAccessible label for the nav item. Rendered as visible text by default. When isIconOnly is true, used as aria-label instead.
href
stringNavigation target URL.
isSelected
boolean (default: false)Whether this nav item is currently selected. Sets aria-current="page" and applies highlighted styles.
isDisabled
boolean (default: false)Whether the nav item is disabled. Sets aria-disabled and prevents interaction.
isIconOnly
boolean (default: false)Renders the item as a square icon-only element. When true, label becomes the aria-label and visible text is hidden. Requires icon to be set.
icon
ReactNodeOptional icon to display before the label.
children
ReactNodeCustom content to render instead of the label text.
as
XDSLinkComponentTypeCustom component to render instead of <a>. Overrides the provider-level default set by XDSLinkProvider. Must accept href, className, style, and children props.

Showcase source

tsx
'use client';
import {XDSTopNav, XDSTopNavHeading, XDSTopNavItem} from '@xds/core/TopNav';
function HomeIcon() {
return (
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
<path strokeLinecap="round" strokeLinejoin="round" d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
</svg>
);
}
export default function TopNavItemShowcase() {
return (
<XDSTopNav
label="Navigation items demo"
heading={<XDSTopNavHeading heading="App" />}
startContent={
<>
<XDSTopNavItem label="Dashboard" href="#" isSelected icon={<HomeIcon />} />
<XDSTopNavItem label="Projects" href="#" />
<XDSTopNavItem label="Reports" href="#" />
<XDSTopNavItem label="Archived" href="#" isDisabled />
</>
}
/>
);
}