Breadcrumb5
mynaui/breadcrumb5FreeComponent
Breadcrumbs are a navigational UI component that helps users keep track of their location within a website or web app.
Install it
npx shadcn@latest add https://mynaui.com/r/breadcrumb5.jsonSource
1import {2 Breadcrumb,3 BreadcrumbItem,4 BreadcrumbLink,5 BreadcrumbList,6 BreadcrumbPage,7 BreadcrumbSeparator,8} from "@/ui/breadcrumb";9import { ChevronRight, Dots } from "@mynaui/icons-react";10import {11 DropdownMenu,12 DropdownMenuContent,13 DropdownMenuItem,14 DropdownMenuTrigger,15} from "@/ui/dropdown-menu";1617export default function TruncatedBreadcrumb() {18 const items = [19 { name: "Home", href: "#" },20 { name: "Products", href: "#" },21 { name: "Electronics", href: "#" },22 { name: "Computers", href: "#" },23 { name: "Laptops", href: "#" },24 { name: "Gaming", href: "#" },25 {26 name: "This is a very long category name that needs to be truncated",27 href: "#",28 current: true,29 },30 ];3132 // Function to truncate text33 const truncateText = (text: string, maxLength: number) => {34 if (text.length <= maxLength) return text;35 return text.slice(0, maxLength) + "...";36 };3738 return (39 <Breadcrumb>40 <BreadcrumbList>41 <BreadcrumbItem>42 <BreadcrumbLink href={items[0].href}>{items[0].name}</BreadcrumbLink>43 </BreadcrumbItem>44 <BreadcrumbSeparator>45 <ChevronRight className="stroke-2" />46 </BreadcrumbSeparator>4748 {items.length > 3 && (49 <BreadcrumbItem>50 <DropdownMenu>51 <DropdownMenuTrigger>52 <Dots className="stroke-2" />53 </DropdownMenuTrigger>54 <DropdownMenuContent align="start">55 {items.slice(1, -1).map((item) => (56 <DropdownMenuItem key={item.name}>57 <a href={item.href} className="w-full">58 {item.name}59 </a>60 </DropdownMenuItem>61 ))}62 </DropdownMenuContent>63 </DropdownMenu>64 </BreadcrumbItem>65 )}6667 {/* Show penultimate item if there are more than 2 items */}68 {items.length > 2 && (69 <>70 <BreadcrumbSeparator>71 <ChevronRight className="stroke-2" />72 </BreadcrumbSeparator>73 <BreadcrumbItem>74 <BreadcrumbLink href={items[items.length - 2].href}>75 {items[items.length - 2].name}76 </BreadcrumbLink>77 </BreadcrumbItem>78 </>79 )}8081 {/* Last item (always shown, truncated if needed) */}82 <BreadcrumbSeparator>83 <ChevronRight className="stroke-2" />84// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from mynaui
All 346 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordion1accordion1 | mynaui | Components | Free | no deps · 2 files | |
| Accordion2accordion2 | mynaui | Components | Free | no deps · 2 files | |
| Accordion3accordion3 | mynaui | Components | Free | no deps · 2 files | |
| Accordion4accordion4 | mynaui | Components | Free | 1 dep · 2 files | |
| Accordion5accordion5 | mynaui | Components | Free | 1 dep · 2 files | |
| Alert dialog1alert-dialog1 | mynaui | Components | Free | no deps · 2 files | |
| Alert dialog2alert-dialog2 | mynaui | Components | Free | 1 dep · 2 files | |
| Alert dialog3alert-dialog3 | mynaui | Components | Free | 1 dep · 2 files |
