Navigation Menu
ericts-ui/navigation-menuFreeComponent
A Base UI navigation menu with centered popups, animated viewport sizing, and shadcn-style composition.
Live preview
live · rendered by the registry
Rendered by ericts-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.ericts.com/r/navigation-menu.jsonSource
1"use client";23import { NavigationMenu as NavigationMenuPrimitive } from "@base-ui/react/navigation-menu";4import { ChevronDown } from "lucide-react";5import { cva } from "class-variance-authority";67import { cn } from "@/lib/utils";89type NavigationMenuProps = NavigationMenuPrimitive.Root.Props &10 Pick<NavigationMenuPrimitive.Positioner.Props, "align"> & {11 positionerClassName?: string;12 /**13 * Render the built-in positioner. Set to false when composing your own14 * `NavigationMenuPositioner` in `children` (e.g. to change side or15 * offsets), so two portalled positioners never mount at once.16 */17 positioner?: boolean;18 };1920function NavigationMenu({21 align = "center",22 className,23 children,24 positionerClassName,25 positioner = true,26 ...props27}: NavigationMenuProps) {28 return (29 <NavigationMenuPrimitive.Root30 data-slot="navigation-menu"31 className={cn(32 "group/navigation-menu relative flex max-w-max flex-1 items-center justify-center",33 className,34 )}35 {...props}36 >37 {children}38 {positioner ? (39 <NavigationMenuPositioner40 align={align}41 className={positionerClassName}42 />43 ) : null}44 </NavigationMenuPrimitive.Root>45 );46}4748function NavigationMenuList({49 className,50 ...props51}: NavigationMenuPrimitive.List.Props) {52 return (53 <NavigationMenuPrimitive.List54 data-slot="navigation-menu-list"55 className={cn(56 "flex flex-1 list-none items-center justify-center gap-0",57 className,58 )}59 {...props}60 />61 );62}6364function NavigationMenuItem({65 className,66 ...props67}: NavigationMenuPrimitive.Item.Props) {68 return (69 <NavigationMenuPrimitive.Item70 data-slot="navigation-menu-item"71 className={cn("relative", className)}72 {...props}73 />74 );75}7677const navigationMenuTriggerStyle = cva(78 "group/navigation-menu-trigger inline-flex h-8 w-max items-center justify-center rounded-md px-3 text-sm font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none",79);8081function NavigationMenuTrigger({82 className,83 children,84 ...props85}: NavigationMenuPrimitive.Trigger.Props) {86 return (87 <NavigationMenuPrimitive.Trigger88 data-slot="navigation-menu-trigger"89// … truncated
What it pulls in
npm packages
Files it writes
More from ericts-ui
All 43 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Adaptive Draweradaptive-drawer | ericts-ui | Components | Free | 2 deps | |
| Adaptive Switchadaptive-switch | ericts-ui | Components | Free | 2 deps | |
| Check Markcheck-mark | ericts-ui | Components | Free | no deps · 2 files | |
| Context Cursorcontext-cursor | ericts-ui | Components | Free | 1 dep | |
| Copy Buttoncopy-button | ericts-ui | Components | Free | 2 deps | |
| Expandable Dialogexpandable-dialog | ericts-ui | Components | Free | 1 dep | |
| Expandable Panelexpandable-panel | ericts-ui | Components | Free | 2 deps | |
| Expandable Segmented Tabsexpandable-segmented-tabs | ericts-ui | Components | Free | 1 dep |
