Navbar
Build consistent navigation experiences with semantic slots for logo, navigation, and actions. The Navbar component provides a flexible foundation for headers that work across all screen sizes.
Built with compound components for maximum flexibility—compose Logo, Navigation, and Actions slots to create any navbar layout.
Installation
shellUsage
tsxAnatomy
The Navbar is a compound component with four parts:
tsxProps
Root
Logo, Navigation, Actions
All slot components extend FlexProps and support all Flex layout properties.
Examples
Basic Navbar
Simple navbar with logo and navigation links:
tsxMarketing Navbar
Full marketing navbar with all slots populated:
tsxSlot Architecture
Navbar acts as a layout container with three semantic slots. Each slot has a specific purpose and behavior. Visualize the slot boundaries to understand the layout:
tsxWith Icons
Add icons to navigation items for visual clarity:
tsxWith Next.js Link
Integrate with Next.js routing using asChild:
tsxWith User Menu
Dashboard navbar with dropdown user menu:
tsxMinimal Logo Only
When you only need branding without navigation:
tsxWith Shell Layout
Combine Navbar with Shell for complete page layouts:
tsxPosition
Use the position prop to control how the navbar behaves when scrolling.
Fixed
Fixed navbars stay at the top of the viewport. Content scrolls beneath them. Add padding to your page content to prevent overlap.
tsxSticky
Sticky navbars scroll with content until they reach the top, then stick in place.
tsxStatic
Static navbars flow with the document and scroll out of view.
tsxSize
Use the size prop to control navbar padding. Height is content-driven, adjusting automatically to fit your content.
Size 1
Compact padding for dense interfaces or mobile layouts.
tsxSize 2
Standard padding for most applications. The default size.
tsxSize 3
Spacious padding for prominent headers or when you want more breathing room.
tsxSlots
Navbar exposes three semantic slots that handle layout automatically. Understanding slot behavior helps you build effective navigation.
Logo
The Logo slot is designed for brand identity elements. It never shrinks and stays left-aligned.
tsxNavigation
The Navigation slot expands to fill available space and centers its content. Use it for primary navigation links.
tsxActions
The Actions slot is right-aligned and never shrinks. Use it for CTAs, user menus, and utility controls.
tsxPolymorphism
AsChild
Use the asChild prop on any slot to merge its props with a child element. This is useful for custom wrappers or routing integration.
tsxAccessibility
The Navbar component follows WAI-ARIA best practices for navigation landmarks.
Semantic Structure
Navbar.Rootrenders as a semantic<header>elementNavbar.Navigationrenders as a<nav>element withrole="navigation"- Proper heading hierarchy should be maintained within logo content
Keyboard Navigation
- All interactive elements within the navbar are keyboard accessible
- Focus order follows visual order: logo, navigation, actions
- Use Button or Link components for interactive elements to ensure proper focus handling
Screen Readers
- The
<header>landmark helps screen reader users identify the navigation area - The
<nav>element within Navigation slot provides additional context - Ensure all interactive elements have appropriate labels
Changelog
Changed
- Replaced
heightprop withsizeprop (1, 2, 3) for padding-based sizing - Height is now content-driven instead of fixed
- Slots now extend
FlexPropsfor full layout control (gap, align, justify, etc.)
Added
- Initial release with compound component architecture
- Semantic slots for Logo, Navigation, and Actions
- Position variants: fixed, sticky, static
- Size options: 1 (compact), 2 (default), 3 (spacious)
asChildprop for all slots using Radix Slot pattern- Responsive gap adjustments for mobile layouts