Breadcrumbs
Enhances user experience by visually representing path within system hierarchy, facilitating easy backward traversal. The
displays a hierarchical navigation path, allowing users to understand their current location within the application structure and navigate back to previous levels. It automatically adjusts the number of visible breadcrumbs based on the available width and collapses excess links into a dropdown menu.
Technical Overview
The
component renders a list of links representing the navigation path. It intelligently manages the display of these links based on screen size, collapsing less relevant links into a menu to save space. It also provides optional features like a back button and customization options.
Key Features
- Responsive Design: Automatically adjusts the number of visible breadcrumbs based on predefined width zones (
lg
,md
,sm
). The thresholds for each zone are configurable. The default value are:- SM: Up to 3 items
- MD: Up to 4 items
- LG: Up to 6 items
- Collapsible Menu: Older path segments are collapsed into a dropdown menu (
) when the number of items exceeds the threshold for the current width zone.lmn-menu - Back Button: It is optional to include a back button, which enables users to navigate up one level in the hierarchy. It is possible to show this button also when some of the levels are hidden inside of the menu. This button is not shown when the user is on the homepage/root.
- Customizable Links: Supports custom templates for rendering individual breadcrumb links using the
directive.lmnBreadcrumbsCustomLink - Custom Start Slot: Allows injecting custom content at the beginning of the breadcrumbs trail using the
directive.lmnBreadcrumbsCustomSlotStart - Accessibility Support: Implements ARIA attributes, including
role="navigation"
,aria-label
for the list, andaria-current
for the last item, enhancing screen reader compatibility.aria-current
can be configured. - Negative State: Supports a
negative
state for display on dark backgrounds. - Multiline: When the viewport doesn’t allow the path to fit in a single row, the text automatically wrap into multiple lines.
When to Use
Use the
when:
- You need to show the user's current location within a hierarchical navigation structure.
- You want to provide users with easy access to navigate back to parent pages or sections.
- The navigation path can become long and needs responsive handling for different screen sizes.
Implementation
To implement the breadcrumbs component, you need to:
- Include the
<
tag in your template.lmn-breadcrumbs > - Provide the required inputs.
Selector:
Inputs:
items
: Required. An array of
objects representing the navigation path. Each link object should haveLmnBreadcrumbsLink id
,label
(string
or
), andSignal <string>url
. An optionalariaLabel
(string
or
) can be provided for accessibility.Signal <string>listName
: Required. Astring
or
used as theSignal <string>aria-label
for the breadcrumbs list (<ul>
).hideBackButton
: Optional (boolean
, default:false
). Hides the back button if set totrue
.negative
: Optional (boolean
, default:false
). Applies negative styling for dark backgrounds.ariaCurrent
: Optional (
, default:LmnBreadcrumbsAriaCurrentRole 'page'
). Sets thearia-current
attribute value for the last breadcrumb item.visibleElementThresholds
: Optional (Partial<Record<
, default:LmnWidthZone , number>>{ lg: 6, md: 4, sm: 3 }
). Overrides the default maximum number of visible breadcrumbs for different width zones (lg
,md
,sm
).
Outputs:
triggerLink
: Emits
when a breadcrumb link is clicked or activated via keyboard. The event includes the originalLmnBreadcrumbsLinkTriggerEvent
and theEvent
object. Note: The component callsLmnBreadcrumbsLink event.preventDefault()
internally.triggerListItem
: Emits
when an item in the collapsed menu is clicked.LmnListItemTriggerEvent triggerBackButton
: Emits the original
when the back button is clicked.Event
Customization:
Custom Link Template: Provide a template using the
structural directive to customize the rendering of each link. The template context provides theLmnBreadcrumbsCustomLinkDirective
object implicitly (LmnBreadcrumbsLink $implicit
).Custom Start Slot: Add content before the breadcrumb items using the
attribute directive.lmnBreadcrumbsCustomSlotStart