Breadcrumbs
The <smart-breadcrumbs> component renders a list of navigation items separated by visual delimiters (chevron, slash, or arrow shape). It follows the Base + Standard + Wrapper pattern with an InjectionToken-based extension mechanism. The abstract BreadcrumbsBaseComponent defines the shared API — options (IBreadcrumbsOptions), cssClass (alias class), and the itemClick output. BreadcrumbsStandardComponent is a barebones placeholder using native <nav>, <ol>, <li>, <a>, and <button> elements. BreadcrumbsComponent is the public wrapper that renders BreadcrumbsStandardComponent by default and accepts a custom replacement via BREADCRUMBS_STANDARD_COMPONENT_TOKEN.
Usage
<smart-breadcrumbs [options]="options" (itemClick)="onItemClick($event)" />
@if (lastItemId(); as itemId) {
<p>Last clicked: {{ itemId }}</p>
}
The preview renders the code above in an application that registers every preset (provideSmartPresets(), see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Components
BreadcrumbsComponent (<smart-breadcrumbs>)
Main wrapper. Delegates to BreadcrumbsStandardComponent by default. When BREADCRUMBS_STANDARD_COMPONENT_TOKEN is provided, renders the injected component via NgComponentOutlet and passes it options and class. Re-emits itemClick from whichever component it renders.
BreadcrumbsStandardComponent (<smart-breadcrumbs-standard>)
Barebones placeholder using native HTML. Renders a <nav class="breadcrumbs"> (with aria-label from options.ariaLabel or default "Breadcrumb") containing an <ol> of items. Each item renders as <a class="breadcrumbs-link"> (when href provided) or <button class="breadcrumbs-button"> (otherwise, emitting itemClick). Items get current class and aria-current="page" when item.current === true. Supports iconTpl (e.g. for the home item) and srOnlyLabel. Items are joined by a <span class="breadcrumbs-separator"> with a data-separator attribute reflecting options.separator (defaults to chevron). It ignores options.layout.
BreadcrumbsPresetComponent (<smart-breadcrumbs-preset>)
Styled variation that extends BreadcrumbsBaseComponent and is a drop-in replacement for BreadcrumbsStandardComponent. Register it via BREADCRUMBS_STANDARD_COMPONENT_TOKEN ({ provide: BREADCRUMBS_STANDARD_COMPONENT_TOKEN, useValue: BreadcrumbsPresetComponent }) to restyle every <smart-breadcrumbs>, register every preset at once with provideSmartPresets(), or use the <smart-breadcrumbs-preset> selector directly. Translates the Preline breadcrumb: muted links (text-gray-600) that brighten to blue on hover/focus, a bold non-link current crumb (font-semibold text-gray-900), and a configurable separator SVG between crumbs selected via options.separator — chevron (default), slash (drawn slightly larger), or arrow. The options.layout field wraps the bar: contained (inline padded gray panel with rounded corners) and full-width-bar (full-width gray bar with top/bottom borders); the simple-with-slashes layout also implies a slash separator when separator is unset; simple-with-chevrons changes nothing (no wrapper, and the chevron is already the default separator). Items render as <a> (when href is set and not current), <button> (no href → emits itemClick), or a plain <span> (when current). All classes are smart:-prefixed Tailwind with explicit dark: variants; the class recipes are internal to the preset (not exported).
Used directly, <smart-breadcrumbs-preset> takes the extra classes as class or [cssClass]; on <smart-breadcrumbs> pass class and the wrapper forwards it.
BreadcrumbsBaseComponent (abstract)
Abstract base directive. Exposes:
options: InputSignal<IBreadcrumbsOptions | undefined>cssClass: InputSignal<string>(aliasclass)itemClick: OutputEmitterRef<IBreadcrumbsItemClick>
IBreadcrumbsItemClick = { itemId: string }.
API
Inputs
| Input | Type | Default | Description |
|---|---|---|---|
options | InputSignal<IBreadcrumbsOptions | undefined> | - | Breadcrumbs configuration |
class | InputSignal<string> | '' | External CSS classes (alias for cssClass) |
Outputs
| Output | Type | Description |
|---|---|---|
itemClick | OutputEmitterRef<IBreadcrumbsItemClick> | Emitted when a button-type breadcrumb is clicked |
IBreadcrumbsOptions
| Field | Type | Default | Description |
|---|---|---|---|
layout | SmartBreadcrumbsLayout | undefined | Preset only: contained or full-width-bar wrap the trail in a gray bar; simple-with-slashes implies the slash separator; simple-with-chevrons changes nothing. The standard ignores it. |
ariaLabel | string | 'Breadcrumb' | Accessible name of the nav. |
separator | SmartBreadcrumbsSeparator | 'chevron' | Glyph between items: 'chevron', 'slash' or 'arrow', drawn by the preset; the standard exposes it as data-separator. |
items | IBreadcrumbItem[] | required | The trail, first to last. |
IBreadcrumbItem
| Field | Type | Default | Description |
|---|---|---|---|
id | string | required | Reported as itemId by itemClick. |
label | string | undefined | Visible text. |
href | string | undefined | Renders the item as a link; without it the item is a button that emits itemClick. |
iconTpl | TemplateRef<unknown> | undefined | Icon before the label (e.g. a home icon). |
srOnlyLabel | string | undefined | Text for screen readers only, for an icon-only item. |
current | boolean | undefined | Marks the current page (aria-current="page"); the preset renders it as plain text, not a link. |
SmartBreadcrumbsLayout is 'contained' | 'full-width-bar' | 'simple-with-chevrons' | 'simple-with-slashes'; SmartBreadcrumbsSeparator is 'chevron' | 'slash' | 'arrow'.
BREADCRUMBS_STANDARD_COMPONENT_TOKEN
InjectionToken that replaces the default BreadcrumbsStandardComponent with a custom implementation: provide a Type<BreadcrumbsBaseComponent>. The wrapper passes it options and class and re-emits its itemClick.
Extending the base class
import {
ChangeDetectionStrategy,
Component,
ViewEncapsulation,
} from '@angular/core';
import {
BreadcrumbsBaseComponent,
BreadcrumbsComponent,
BREADCRUMBS_STANDARD_COMPONENT_TOKEN,
IBreadcrumbsOptions,
} from '@smartsoft001/angular';
@Component({
selector: 'docs-custom-breadcrumbs',
template: `
<nav
class="docs-breadcrumbs"
[class]="cssClass()"
[attr.aria-label]="options()?.ariaLabel ?? 'Breadcrumb'"
>
<ol class="docs-breadcrumbs__list">
@for (item of options()?.items ?? []; track item.id; let last = $last) {
<li class="docs-breadcrumbs__item">
<a
class="docs-breadcrumbs__link"
[href]="item.href ?? '#'"
[attr.aria-current]="item.current ? 'page' : null"
(click)="select($event, item.id)"
>
{{ item.label }}
</a>
@if (!last) {
<span class="docs-breadcrumbs__separator" aria-hidden="true">
/
</span>
}
</li>
}
</ol>
</nav>
`,
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CustomBreadcrumbsComponent extends BreadcrumbsBaseComponent {
select(event: MouseEvent, itemId: string): void {
event.preventDefault();
this.itemClick.emit({ itemId });
}
}
@Component({
selector: 'docs-breadcrumbs-custom-example',
imports: [BreadcrumbsComponent],
providers: [
{
provide: BREADCRUMBS_STANDARD_COMPONENT_TOKEN,
useValue: CustomBreadcrumbsComponent,
},
],
template: `<smart-breadcrumbs [options]="options" />`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BreadcrumbsCustomExampleComponent {
options: IBreadcrumbsOptions = {
items: [
{ id: 'home', label: 'Home', href: '#' },
{ id: 'center', label: 'App Center', href: '#' },
{ id: 'app', label: 'Application', current: true },
],
};
}
Source
The component lives in packages/shared/angular/src/lib/components/breadcrumbs and is documented for Claude Code by the angular-components-breadcrumbs skill.
SmartBreadcrumbs renders a breadcrumb trail inside a nav (labelled options.ariaLabel, 'Breadcrumb' by default). Items with href are links; items without one are buttons reported through onItemClick({ itemId }), so the trail also works with a router that navigates in code. The item marked current gets aria-current="page". options.separator and options.layout choose the look, styled by SmartBreadcrumbsPreset.
Usage
import { useState } from 'react';
import {
IBreadcrumbsItemClick,
IBreadcrumbsOptions,
SmartBreadcrumbs,
} from '@smartsoft001/react';
const options: IBreadcrumbsOptions = {
separator: 'slash',
items: [
{ id: 'home', label: 'Home' },
{ id: 'projects', label: 'Projects' },
{ id: 'nero', label: 'Project Nero', current: true },
],
};
export function BreadcrumbsUsageExample() {
const [lastItemId, setLastItemId] = useState<string | null>(null);
const onItemClick = ({ itemId }: IBreadcrumbsItemClick) =>
setLastItemId(itemId);
return (
<>
<SmartBreadcrumbs options={options} onItemClick={onItemClick} />
{lastItemId && <p>Last clicked: {lastItemId}</p>}
</>
);
}
The preview renders the code above in an application that registers every preset (SMART_PRESET_COMPONENTS on SmartProvider, see Installation) and the English translations; without the presets, a component that has one renders its standard implementation instead, for most components unstyled markup.
Exports
All from @smartsoft001/react.
| Export | Kind | What it is |
|---|---|---|
SmartBreadcrumbs | component | Renders the implementation registered as components.breadcrumbs on SmartProvider, SmartBreadcrumbsStandard by default. |
SmartBreadcrumbsPreset | component | Styled breadcrumbs variation (preset). |
SmartBreadcrumbsStandard | component | The default breadcrumbs rendering: semantic markup with breadcrumbs-* class hooks; items with href are links, the others buttons reporting onItemClick. |
useBreadcrumbs | hook | The behaviour every breadcrumbs variant shares: the items to render and the click on an item without href, reported as { itemId }. |
The preset's class helpers (getBreadcrumbsNavClasses, getBreadcrumbsListClasses, getBreadcrumbsItemClasses, getBreadcrumbsLinkClasses, getBreadcrumbsCurrentClasses, getBreadcrumbsSeparatorClasses, resolveBreadcrumbsSeparator) are exported too, for a custom implementation that wants the preset look.
Props and Types
SmartBreadcrumbsProps
| Prop | Type | Default | Description |
|---|---|---|---|
options? | IBreadcrumbsOptions | — | The items and the look. |
className? | string | — | Classes on the root nav. |
onItemClick? | (event: IBreadcrumbsItemClick) => void | — | Click on an item without href (rendered as a button). |
IBreadcrumbsOptions
| Field | Type | Default | Description |
|---|---|---|---|
layout? | SmartBreadcrumbsLayout | — | contained or full-width-bar wrap the trail in a bar; simple-with-slashes implies the slash separator; simple-with-chevrons changes nothing. Read by the preset only; the standard markup ignores it. |
ariaLabel? | string | 'Breadcrumb' | Accessible name of the nav. |
separator? | SmartBreadcrumbsSeparator | 'chevron' | Glyph between items (data-separator on the standard markup). |
items | IBreadcrumbItem[] | required | The trail, first to last. |
IBreadcrumbsItemClick
Payload of onItemClick.
| Field | Type | Default | Description |
|---|---|---|---|
itemId | string | required | The id of the clicked item. |
IBreadcrumbItem
| Field | Type | Default | Description |
|---|---|---|---|
id | string | required | Reported as itemId by onItemClick. |
label? | string | — | Visible text. |
href? | string | — | Renders the item as a link; without it the item is a button. |
iconTpl? | ReactNode | — | Icon before the label (e.g. a home icon). |
srOnlyLabel? | string | — | Text for screen readers only, for an icon-only item. |
current? | boolean | — | Marks the current page (aria-current="page"). |
Related types
SmartBreadcrumbsLayout:'contained' \| 'full-width-bar' \| 'simple-with-chevrons' \| 'simple-with-slashes'SmartBreadcrumbsSeparator:'chevron' \| 'slash' \| 'arrow'
Replacing the Implementation
SmartBreadcrumbs renders the component registered under the 'breadcrumbs' key of SmartProvider's components, and SmartBreadcrumbsStandard when nothing is registered there. Every SmartBreadcrumbs below the provider then renders the registered component, which receives the same props.
SmartBreadcrumbsPreset is the styled (preset) implementation: register it under the 'breadcrumbs' key of SmartProvider's components, render it directly in place of SmartBreadcrumbs, or spread SMART_PRESET_COMPONENTS on the provider to register every preset at once (see the react-provider skill). Pass components as a stable object (a module constant or a memoised value), or the context changes on every render.
The useBreadcrumbs hook
The behaviour every breadcrumbs variant shares: the items to render and the click on an item without href, reported as { itemId }.
| Returns | Type | Description |
|---|---|---|
items | IBreadcrumbItem[] | options.items ?? []. |
itemClick | (itemId: string) => void | undefined | Reports a click on an item without href as { itemId }. |
import type { MouseEvent } from 'react';
import {
IBreadcrumbsOptions,
SmartBreadcrumbs,
SmartBreadcrumbsProps,
SmartProvider,
useBreadcrumbs,
} from '@smartsoft001/react';
export function CustomBreadcrumbs({
options,
className,
onItemClick,
}: SmartBreadcrumbsProps) {
const { items, itemClick } = useBreadcrumbs({ options, onItemClick });
const select = (event: MouseEvent, itemId: string) => {
event.preventDefault();
itemClick(itemId);
};
return (
<nav
className={['docs-breadcrumbs', className].filter(Boolean).join(' ')}
aria-label={options?.ariaLabel ?? 'Breadcrumb'}
>
<ol className="docs-breadcrumbs__list">
{items.map((item, index) => (
<li key={item.id} className="docs-breadcrumbs__item">
<a
className="docs-breadcrumbs__link"
href={item.href ?? '#'}
aria-current={item.current ? 'page' : undefined}
onClick={(event) => select(event, item.id)}
>
{item.label}
</a>
{index < items.length - 1 && (
<span className="docs-breadcrumbs__separator" aria-hidden="true">
/
</span>
)}
</li>
))}
</ol>
</nav>
);
}
// A module constant: a new object on every render would change the context.
const components = { breadcrumbs: CustomBreadcrumbs };
const options: IBreadcrumbsOptions = {
items: [
{ id: 'home', label: 'Home', href: '#' },
{ id: 'center', label: 'App Center', href: '#' },
{ id: 'app', label: 'Application', current: true },
],
};
export function BreadcrumbsCustomExample() {
return (
<SmartProvider components={components}>
<SmartBreadcrumbs options={options} />
</SmartProvider>
);
}
Styling
SmartBreadcrumbsStandardrenders semantic markup withbreadcrumbs-*class hooks (breadcrumbs-link,breadcrumbs-button,breadcrumbs-separator,current) anddata-separatorfor your own CSS.SmartBreadcrumbsPresetrenders muted links, a bold current crumb and the separator glyph, withsmart:dark:variants.
Source
The component lives in packages/shared/react/src/lib/components/breadcrumbs and is documented for Claude Code by the react-components-breadcrumbs skill.