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 / Ctrl 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.
selectedTabIdstring—Active tab ID.
onTabChange(id: string) => void—Tab change handler.
userNamestring'Adam'User display name.
userEmailstring—User email address.
userPersonAvatarPerson—Avatar person identifier.
notificationsNotificationData[][]Notification items.
onNotificationClick(id: string) => void—Notification click handler.
onMarkAllAsRead() => void—Mark all notifications read.
onViewAll() => void—View all notifications.
showUpgradeButtonbooleantrueShow upgrade CTA.
onSearchClick() => void—Search click handler.
widthnumber | string'100%'Container width.
leftSlotReactNode—Custom left content.
centerSlotReactNode—Custom center content.
rightSlotReactNode—Custom right content.

On this page