Navbar 01
shadcn-ui-blocks-shadcnship/navbar-01FreeBlock
Responsive navbar with dropdown navigation menus on desktop and an accordion-based mobile menu. Use it as your site-wide header to provide clear, accessible navigation across all screen sizes and devices.
See it running
Open the demo on shadcn-ui-blocks
shadcnship.com/blocks/navbar-01Install it
npx shadcn@latest add https://shadcnship.com/r/navbar-01.jsonSource
1"use client";23import { useState } from "react";4import { cn } from "@/lib/utils";5import { Button } from "@/components/ui/button";6import {7 NavigationMenu,8 NavigationMenuContent,9 NavigationMenuItem,10 NavigationMenuLink,11 NavigationMenuList,12 NavigationMenuTrigger,13} from "@/components/ui/navigation-menu";14import {15 Sheet,16 SheetContent,17 SheetHeader,18 SheetTitle,19 SheetTrigger,20} from "@/components/ui/sheet";21import {22 Blocks,23 ChevronDown,24 Layers,25 Menu,26 Sparkles,27 Sunset,28} from "lucide-react";2930// ---- Types ----3132interface NavSubItem {33 text: string;34 url: string;35 description?: string;36 icon?: React.ReactNode;37}3839interface NavItemSimple {40 type: "link";41 text: string;42 url: string;43}4445interface NavItemMenu {46 type: "menu";47 title: string;48 items: NavSubItem[];49}5051type NavItem = NavItemSimple | NavItemMenu;5253interface NavButton {54 text: string;55 url: string;56 variant?: "default" | "outline" | "ghost" | "secondary";57}5859interface Navbar01Props {60 logo?: React.ReactNode;61 navItems?: NavItem[];62 buttons?: NavButton[];63 className?: string;64}6566// ---- Desktop menu item card ----6768const SubItemCard = ({ item }: { item: NavSubItem }) => (69 <NavigationMenuLink asChild>70 <a71 href={item.url}72 className="flex items-start gap-2 rounded-md p-4 transition-colors hover:bg-muted"73 >74 {item.icon && (75 <div className="mt-0.5 flex size-9 shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground">76 {item.icon}77 </div>78 )}79 <div>80 <p className="text-sm leading-snug font-semibold">{item.text}</p>81 {item.description && (82 <p className="mt-0.5 text-sm leading-snug text-muted-foreground">83 {item.description}84 </p>85 )}86 </div>87 </a>88 </NavigationMenuLink>89);9091// ---- Mobile accordion group ----9293const MobileMenuGroup = ({ item }: { item: NavItemMenu }) => {94 const [open, setOpen] = useState(false);95 return (96 <div>97 <button98 onClick={() => setOpen(!open)}99 className="flex w-full items-center justify-between py-3 text-base font-semibold"100 >101 {item.title}102 <ChevronDown103 className={cn(104 "size-4 text-muted-foreground transition-transform",105 open && "rotate-180",106 )}107 />108 </button>109 {open && (110 <div className="flex flex-col gap-1 pb-2 pl-2">111 {item.items.map((sub) => (112 <a113// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn-ui-blocks
All 74 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Square Grid Backgroundbackground-01 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Dot Pattern Backgroundbackground-02 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Diagonal Stripes Backgroundbackground-03 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Vertical Lines Backgroundbackground-04 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Interactive Grid Backgroundbackground-05 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Banner 01banner-01 | shadcn-ui-blocks | Blocks | Free | 1 dep | |
| Blog 01blog-01 | shadcn-ui-blocks | Blocks | Free | no deps | |
| Changelog 01changelog-01 | shadcn-ui-blocks | Blocks | Free | no deps |
