GitHub
Core
Glass
Brutal
Humanist

Top Navigation

TopNavigation provides a consistent header for app navigation, search, and user profile management.

Top Navigation Playground

Top Navigation Playground
Preview
Code

Overview

Controls
Type:
Default
Title Only
Search Type:
Search Bar
Search Icon
Back Button:

Installation

You can add the top navigation component to your project manually:

1

Install the following dependencies:

npm install class-variance-authority clsx @phosphor-icons/react @react-aria/button @react-aria/focus @react-aria/interactions
2

Copy and paste the following code into your project.

Loading source code...
3

Update the import paths to match your project setup.

Update the import aliases (e.g. @/components, @/utils) in the copied files to match your project's path configuration.

Basic Usage

import { TopNavigation } from '@versaui/ui/components/TopNavigation';

const tabs = [
  { id: 'overview', label: 'Overview' },
  { id: 'projects', label: 'Projects' },
  { id: 'analytics', label: 'Analytics' },
];

<TopNavigation
  tabs={tabs}
  selectedTabId="overview"
  onTabChange={(id) => setCurrentTab(id)}
/>

Types

Default

Navigation with tabs and full layout:

<TopNavigation type="default" tabs={tabs} />

Title

Simplified header with page title instead of tabs:

<TopNavigation type="title" pageTitle="Dashboard" />

Search Types

Full search bar displayed in the header:

<TopNavigation searchType="bar" />

Search Icon

Compact search icon button:

<TopNavigation searchType="icon" />

Custom Slots

Customize left, center, and right sections:

<TopNavigation
  leftSlot={<Logo />}
  centerSlot={<SearchBar />}
  rightSlot={<UserMenu />}
/>

Notifications

Pass notification data to display a notification panel:

<TopNavigation
  notifications={[
    {
      id: '1',
      title: 'New comment',
      description: 'Sarah mentioned you',
      timestamp: '2 min ago',
      unread: true,
      leadingItem: 'icon',
    },
  ]}
  onNotificationClick={(id) => markAsRead(id)}
  onMarkAllAsRead={() => markAll()}
/>

Accessibility

  • Uses <header> with proper semantic structure
  • Navigation tabs are keyboard accessible
  • Search bar supports ⌘K shortcut
  • User profile menu is keyboard navigable
  • Notifications panel supports Tab navigation

TopNavigation Props

PropTypeDefaultDescription
type'default' | 'title''default'Layout type.
searchType'bar' | 'icon''bar'Search display style.
pageTitlestring'Page Title'Page title text.
tabsContainerTabItem[]Navigation tab items.
selectedTabIdstringActive tab ID.
onTabChange(id: string) => voidTab change handler.
userNamestring'Adam'User display name.
userEmailstringUser email address.
userPersonAvatarPersonAvatar person identifier.
notificationsNotificationData[][]Notification items.
onNotificationClick(id: string) => voidNotification click handler.
onMarkAllAsRead() => voidMark all notifications read.
onViewAll() => voidView all notifications.
showUpgradeButtonbooleantrueShow upgrade CTA.
onSearchClick() => voidSearch click handler.
widthnumber | string'100%'Container width.
leftSlotReactNodeCustom left content.
centerSlotReactNodeCustom center content.
rightSlotReactNodeCustom right content.

On this page