About
Main navigation bar container with slot-based layout. Children are accepted as an alias for startContent. Astryx by Meta. Source: https://astryx.atmeta.com/components/TopNav
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Top Nav to your project and fits it to your theme.
Code
How Astryx Top Nav is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
'use client';
/* Copyright (c) 2026 Meta Platforms, Inc. See the MIT notice in astryx-top-nav.tsx. */
import '@/components/ui/astryx-top-nav-utils/astryx-preview.css';
import '@astryxdesign/theme-neutral/fonts.css';
import {useSyncExternalStore} from 'react';
import {Theme} from '@astryxdesign/core/theme';
import {neutralTheme} from '@astryxdesign/theme-neutral/built';
import {TopNav, TopNavHeading, TopNavItem} from '@/components/ui/astryx-top-nav';
import {NavIcon} from '@astryxdesign/core/NavIcon';
import {Button} from '@astryxdesign/core/Button';
import {Icon} from '@astryxdesign/core/Icon';
import {
BellIcon as NotificationIcon,
CubeIcon as PackageIcon,
UserCircleIcon,
} from '@heroicons/react/24/outline';
import {useToast} from '@astryxdesign/core/Toast';
function OfficialSample() {
const showToast = useToast();
return (
<TopNav
style={{width: 600, maxWidth: '100%'}}
label="Main navigation"
heading={
<TopNavHeading
heading="My App"
logo={<NavIcon icon={<Icon icon={PackageIcon} size="sm" />} />}
/>
}
startContent={
<>
<TopNavItem label="Home" href="#" isSelected />
<TopNavItem label="Products" href="#" />
<TopNavItem label="About" href="#" />
</>
}
endContent={
<>
<Button
onClick={() => showToast({body: 'Demo: search would open here'})}
label="Search"
variant="ghost"
icon={<Icon icon="search" color="inherit" />}
isIconOnly
/>
<Button
onClick={() =>
showToast({body: 'Demo: your notifications would open here'})
}
label="Notifications"
variant="ghost"
icon={<NotificationIcon />}
isIconOnly
/>
<Button
onClick={() =>
showToast({body: 'Demo: your profile menu would open here'})
}
label="Profile"
variant="ghost"
icon={<UserCircleIcon />}
isIconOnly
/>
</>
}
/>
);
}
function readPreviewMode() {
const {classList} = document.documentElement;
return classList.contains('dark') ? 'dark' : 'light';
}
function subscribeToPreviewMode(callback: () => void) {
const observer = new MutationObserver(callback);
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['class']});
return () => observer.disconnect();
}
export default function Demo() {
const mode = useSyncExternalStore(subscribeToPreviewMode, readPreviewMode, () => 'light' as const);
return (
<Theme theme={neutralTheme} mode={mode}>
<div className="astryx-demo">
<div className="astryx-demo-content" data-centered style={{maxWidth: 600}}>
<OfficialSample />
</div>
</div>
</Theme>
);
}















