Dynamic Breadcrumb Navigation Component
In complex web applications like a financial dashboard or an e-commerce platform, users often navigate through multiple levels of content. A clear breadcrumb navigation helps users understand their current location within the application hierarchy and provides an intuitive way to backtrack. This problem focuses on building a robust and accessible Breadcrumbs component that dynamically adapts to path length.
Your task is to create a reusable Breadcrumbs React functional component with the following features:
Breadcrumbs component that accepts a path prop. The path prop will be an array of objects, each representing a segment: { label: string; href?: string; }. The href property is optional for the last item (current page) and for the ellipsis./ or >) between path segments.path contains more than a specified number of maxVisibleItems (default to 4), the component should display the first item, followed by an ellipsis (...), and then the last maxVisibleItems - 2 items. The ellipsis itself should not be clickable. For example, if maxVisibleItems is 4 and the path is [A, B, C, D, E, F], it should render as A > ... > E > F....) should be clearly visible and not clickable.Breadcrumbs component renders correctly based on the provided path data.<a> links./) is correctly placed between all visible path segments.maxVisibleItems) are truncated as specified: first item, ellipsis, and the last maxVisibleItems - 2 items.aria-label="Breadcrumb" on nav, aria-current="page" on the last item) for accessibility.path array (renders nothing) and a path array with a single item (renders only the current item).Constraints
styles.css. No CSS-in-JS or CSS pre-processors are required.href values are simple strings and do not require integration with a client-side routing library (e.g., React Router).maxVisibleItems should be 4.path array based on the current URL.Loading editor...