Skip to content

TopNav

Horizontal top navigation bar with heading, start, center, and end content slots. Adapts to mobile layouts when rendered inside AppShell.

<TopNav
{...args}
endContent={<Button label="Create" size="sm" variant="primary" />}
heading={<TopNavHeading heading="Silver UI" />}>
<TopNavItem href="/docs" isSelected label="Docs" />
<TopNavItem href="/components" label="Components" />
</TopNav>
<TopNav
{...args}
centerContent={
<>
<TopNavItem href="/docs" isSelected label="Docs" />
<TopNavItem href="/components" label="Components" />
<TopNavItem href="/guides" label="Guides" />
</>
}
endContent={<Button label="Sign in" size="sm" />}
heading={<TopNavHeading heading="Silver UI" />}
/>
<TopNav
{...args}
endContent={<Button label="Sign in" size="sm" />}
heading={<TopNavHeading heading="Silver UI" />}
startContent={
<>
<TopNavItem href="/docs" isSelected label="Docs" />
<TopNavItem href="/components" label="Components" />
</>
}
/>
<TopNav {...args} endContent={<Button label="Sign in" size="sm" />}>
<TopNavItem href="/home" isSelected label="Home" />
<TopNavItem href="/about" label="About" />
<TopNavItem href="/contact" label="Contact" />
</TopNav>
<TopNav {...args} heading={<TopNavHeading heading="Silver UI" />}>
<TopNavItem href="/docs" label="Docs" />
<TopNavItem href="/admin" isDisabled label="Admin" />
<TopNavItem href="/settings" isDisabled label="Settings" />
</TopNav>
<TopNav
{...args}
endContent={
<>
<TopNavItem href="/search" icon={Search} isIconOnly label="Search" />
<TopNavItem
href="/notifications"
icon={Bell}
isIconOnly
label="Notifications"
/>
<TopNavItem
href="/settings"
icon={Settings}
isIconOnly
label="Settings"
/>
</>
}
heading={<TopNavHeading heading="Silver UI" />}>
<TopNavItem href="/docs" isSelected label="Docs" />
<TopNavItem href="/components" label="Components" />
</TopNav>
<TopNav {...args} heading={<TopNavHeading heading="Silver UI" />}>
<TopNavItem href="/docs" isSelected label="Docs" />
<TopNavItem
icon={Search}
label="Search"
onClick={() => {
// Action-only item (no href) renders as a button.
}}
/>
<TopNavItem
icon={Settings}
label="Settings"
onClick={() => {
// Action-only item (no href) renders as a button.
}}
/>
</TopNav>
<TopNav {...args} heading={<TopNavHeading heading="Silver UI" />}>
<TopNavItem href="/home" icon={Home} isSelected label="Home" />
<TopNavItem href="/search" icon={Search} label="Search" />
<TopNavItem href="/settings" icon={Settings} label="Settings" />
</TopNav>
<div style={{display: 'flex', flexDirection: 'column', gap: 24}}>
<TopNav
heading={<TopNavHeading heading="Silver UI" />}
label="With heading only">
<TopNavItem href="/docs" label="Docs" />
</TopNav>
<TopNav
heading={
<TopNavHeading
heading="Silver UI"
logo={<Avatar name="S" size="xsmall" />}
/>
}
label="With logo">
<TopNavItem href="/docs" label="Docs" />
</TopNav>
<TopNav
heading={
<TopNavHeading
heading="Silver UI"
subheading="Design System"
superheading="Acme Corp"
/>
}
label="With super and subheading">
<TopNavItem href="/docs" label="Docs" />
</TopNav>
<TopNav
heading={
<TopNavHeading
headerEndContent={<Badge color="info" label="Beta" size="sm" />}
heading="Silver UI"
/>
}
label="With end content">
<TopNavItem href="/docs" label="Docs" />
</TopNav>
<TopNav
heading={<TopNavHeading heading="Silver UI" headingHref="/" />}
label="With linked heading">
<TopNavItem href="/docs" label="Docs" />
</TopNav>
</div>

Horizontal top navigation bar with heading, start, center, and end content slots. Adapts to mobile layouts when rendered inside AppShell.

PropTypeDefaultDescription
centerContentReactNode—Content rendered in the center section of the navigation bar.
childrenReactNode—Shorthand for startContent. Rendered in the start section when startContent is not provided.
classNamestring—Additional CSS class names applied to the nav element.
data-testidstring—Test ID applied to the nav element.
endContentReactNode—Content rendered in the end (right) section of the navigation bar.
headingReactNode—Branding or title content rendered at the start of the bar.
labelstring'Top navigation'Accessible label for the navigation landmark.
refRef<HTMLElement>—Ref forwarded to the nav element.
startContentReactNode—Content rendered in the start (left) section after the heading.
styleCSSProperties—Inline styles applied to the nav element.
PropTypeDefaultDescription
aria-labelstring—Accessible label for the heading link. Use when heading text is absent (e.g., logo-only headings) to ensure the link has an accessible name.
asLinkComponent—
classNamestring—
data-testidstring—
headerEndContentReactNode—
headingstring—
headingHrefstring—
hrefstring—
logoReactNode—
refRef<HTMLElement>—
styleCSSProperties—
subheadingstring—
superheadingstring—

A single navigation item inside a TopNav. Renders as a link when `href` is provided, or a button driven by `onClick` otherwise. Supports icons, selected state, and adapts to drawer layout on mobile.

PropTypeDefaultDescription
asLinkComponent—Custom link component used for routing.
childrenReactNode—Custom label content. Falls back to the label prop text.
classNamestring—Additional CSS class names applied to the item.
data-testidstring—Test ID applied to the item.
hrefstring—Link destination. When set, the item renders as a link. When omitted, the item renders as a button driven by onClick.
iconIconComponent—Icon rendered before the label.
isDisabledbooleanfalseWhether the item is disabled.
isIconOnlybooleanfalseWhether only the icon is visible (label used for accessibility).
isSelectedbooleanfalseWhether the item is currently selected.
label*string—Accessible item label, also used as visible text when children are omitted.
onClickMouseEventHandler<HTMLElement>—Click handler called when the item is clicked.
refRef<HTMLElement>—Ref forwarded to the anchor or button element.
relstring—The rel attribute for the anchor element. noopener noreferrer are added automatically for target="_blank". Ignored when rendering as a button (no href).
styleCSSProperties—Inline styles applied to the item.
targetstring—The target attribute for the anchor element. Ignored when rendering as a button (no href).