Command Palette

Search for a command to run...

Docs
Smart Breadcrumb

Smart Breadcrumb

Intelligent breadcrumb navigation with ellipsis for long paths and responsive design

Loading...

Installation

Usage

import SmartBreadcrumb from "@/components/ruixen/smart-breadcrumb";
 
const breadcrumbItems = [
  { label: "Home", href: "/" },
  { label: "Products", href: "/products" },
  { label: "Electronics", href: "/products/electronics" },
  { label: "Laptops", href: "/products/electronics/laptops" },
  { label: "Gaming Laptops" }, // Current page (no href)
];
 
export default function App() {
  return (
    <div className="p-4">
      <SmartBreadcrumb items={breadcrumbItems} />
    </div>
  );
}

Props

PropTypeDefaultDescription
itemsBreadcrumbItem[]-Array of breadcrumb items
maxItemsnumber3Maximum items to show before ellipsis
separatorReactNode/Custom separator component
PropertyTypeDescription
labelstringDisplay text for the breadcrumb
hrefstringOptional link URL (omit for current page)

Features

  • Smart Truncation: Shows ellipsis for long navigation paths
  • Responsive Design: Adapts to different screen sizes
  • Current Page Indicator: Last item shows current page
  • Clickable Links: Navigate to previous pages
  • Customizable Separator: Use custom separator icons
  • Accessible: Full keyboard and screen reader support

Customization

You can customize the appearance and behavior:

// Custom separator
<SmartBreadcrumb
  items={items}
  separator={<ChevronRight className="h-4 w-4" />}
  maxItems={5}
/>
 
// Custom styling
<SmartBreadcrumb
  items={items}
  className="bg-gray-100 p-2 rounded"
/>

Use Cases

Perfect for:

  • E-commerce Sites: Product category navigation
  • File Systems: Folder path navigation
  • Multi-level Menus: Deep navigation structures
  • Documentation: Section and page navigation
  • Admin Panels: Hierarchical page navigation