Skip to main content

Breadcrumb Block

The Breadcrumb Component is a fully customizable and accessible navigation breadcrumb built with React and TypeScript. It provides a complete breadcrumb navigation interface with modern design patterns, flexible customization options, and support for custom navigation items.


πŸš€ Installation​

npm install @nodeblocks/frontend-breadcrumb-block

πŸ“– Usage​

import {Breadcrumbs} from '@nodeblocks/frontend-breadcrumb-block';
Live Editor
  function BasicBreadcrumb() {
    return (
      <Breadcrumbs>
        <Breadcrumbs.BreadcrumbItem url="#home">
            Home
        </Breadcrumbs.BreadcrumbItem>
        <Breadcrumbs.BreadcrumbChevron />
        <Breadcrumbs.BreadcrumbItem url="#products">
            Products
        </Breadcrumbs.BreadcrumbItem>
      </Breadcrumbs>
    );
  }
Result
Loading...

πŸ”§ Props Reference​

Main Component Props​

PropTypeDefaultDescription
classNamestringundefinedAdditional CSS class name for styling the breadcrumb container
childrenBlocksOverrideundefinedFunction to override default blocks or add custom breadcrumb items

Note: The main component inherits all HTML nav element props.

Sub-Components​

The Breadcrumb component provides several sub-components. All sub-components receive their default values from the main component's context and can override these values through props.

PropTypeDefaultDescription
urlstringRequiredThe URL/href for the breadcrumb link
childrenReactNodeRequiredContent to display as the breadcrumb item text

Note: This component inherits all HTML a element props.

This component accepts no props and renders a chevron separator.


πŸ”§ TypeScript Support​

Full TypeScript support with comprehensive type definitions:

import {Breadcrumbs} from '@nodeblocks/frontend-breadcrumb-block';
import {ComponentProps, ReactNode} from 'react';

// Main component interface
interface BreadcrumbProps extends Omit<ComponentProps<'nav'>, 'children'> {
children?: BlocksOverride<DefaultBlocks, CustomBlocks>;
className?: string;
}

// BreadcrumbItem interface
interface BreadcrumbItemProps extends Omit<ComponentProps<'a'>, 'children'> {
url: string;
children: ReactNode;
}

// Usage example with data structure
interface BreadcrumbItem {
key: string;
url: string;
label: string;
}

const breadcrumbItems: BreadcrumbItem[] = [
{ key: 'home', url: '#home', label: 'Home' },
{ key: 'products', url: '#products', label: 'Products' },
{ key: 'current', url: '#products/laptop', label: 'Laptop' },
];

// Example with anchor props
function AdvancedBreadcrumb() {
return (
<Breadcrumbs>
{breadcrumbItems.map((item, index) => (
<>
<Breadcrumbs.BreadcrumbItem key={item.key} url={item.url}>
{item.label}
</Breadcrumbs.BreadcrumbItem>
{index < breadcrumbItems.length - 1 && <Breadcrumbs.BreadcrumbChevron />}
</>
))}
</Breadcrumbs>
);
}

Built with ❀️ using React, TypeScript, and modern web standards.