Skip to content

Breadcrumbs ​

Breadcrumbs show where the user is in a hierarchy as a row of links, from the top level down to the current page.

IonBreadcrumbs is the container — a wrapping flex row that decides which crumb is active, which crumbs show a separator, and which collapse. IonBreadcrumb is one item. Put the IonBreadcrumbs inside an IonBreadcrumbs: outside it they are never marked active, keep their separator, and never collapse.

Basic usage ​

The last crumb is automatically made active (the ColorActive color and ActiveFontWeight weight) and loses its separator. The separator is / in md mode and a forward chevron in ios mode.

razor
@* The last breadcrumb becomes active and drops its separator automatically. *@
<IonBreadcrumbs>
    <IonBreadcrumb Href="/">Home</IonBreadcrumb>
    <IonBreadcrumb Href="/electronics">Electronics</IonBreadcrumb>
    <IonBreadcrumb Href="/electronics/cameras">Cameras</IonBreadcrumb>
    <IonBreadcrumb>Film</IonBreadcrumb>
</IonBreadcrumbs>

Handling taps ​

Href renders the crumb as an anchor with the link look (ion-activatable). A tap raises OnClick and then navigates to Href through the app's NavigationManager — a forward push with the mode's transition, or as set by RouterDirection ("back", "root"), the same as IonItem. To handle the tap yourself instead, leave out Href and use OnClick.

razor
@* A folder path: tapping a crumb trims the path back to it. No Href, so OnClick handles the
   tap instead of navigating. *@
<IonBreadcrumbs>
    @foreach (var folder in _path)
    {
        var target = folder;
        <IonBreadcrumb OnClick="@(() => Open(target))">@target</IonBreadcrumb>
    }
</IonBreadcrumbs>

@code {
    private List<string> _path = new() { "Documents", "Projects", "Miko", "Docs" };

    private void Open(string folder) => _path = _path.Take(_path.IndexOf(folder) + 1).ToList();
}

Active and disabled ​

Active marks a crumb as the current one; once any crumb is explicitly active, the last crumb is no longer made active automatically. Disabled dims a crumb and blocks pointer input.

razor
<IonBreadcrumbs>
    <IonBreadcrumb Href="#">Home</IonBreadcrumb>
    <IonBreadcrumb Href="#" Active="true">Electronics</IonBreadcrumb>
    <IonBreadcrumb Href="#" Disabled="true">Cameras</IonBreadcrumb>
    <IonBreadcrumb>Film</IonBreadcrumb>
</IonBreadcrumbs>

Icons ​

Start and End place content before and after the label; an IonIcon there is sized to 18px with an 8px gap to the label. When you use a named slot, put the label in <ChildContent>.

razor
<IonBreadcrumbs>
    <IonBreadcrumb Href="/">
        <Start>
            <IonIcon Icon="@Ionicons.Home" />
        </Start>
        <ChildContent>Home</ChildContent>
    </IonBreadcrumb>
    <IonBreadcrumb Href="/files">
        <Start>
            <IonIcon Icon="@Ionicons.Folder" />
        </Start>
        <ChildContent>Files</ChildContent>
    </IonBreadcrumb>
    <IonBreadcrumb>
        <ChildContent>Report.pdf</ChildContent>
        <End>
            <IonIcon Icon="@Ionicons.DocumentText" />
        </End>
    </IonBreadcrumb>
</IonBreadcrumbs>

Custom separator ​

The Separator slot replaces the default glyph for that crumb. It is still removed from the last crumb.

razor
@* Each crumb supplies its own separator; it is still removed from the last one. *@
<IonBreadcrumbs>
    @foreach (var label in new[] { "Home", "Electronics", "Cameras" })
    {
        <IonBreadcrumb Href="#">
            <ChildContent>@label</ChildContent>
            <Separator>
                <IonIcon Icon="@Ionicons.ArrowForwardCircle" />
            </Separator>
        </IonBreadcrumb>
    }
</IonBreadcrumbs>

Collapsing ​

When there are more crumbs than MaxItems, the crumbs between the first ItemsBeforeCollapse (default 1) and the last ItemsAfterCollapse (default 1) are hidden behind a "…" indicator. Nothing collapses when MaxItems is null (the default) or when ItemsBeforeCollapse + ItemsAfterCollapse exceeds MaxItems.

Tapping the indicator raises OnCollapsedClick with the hidden crumbs; the component does not expand by itself. Expand by clearing MaxItems, or show the hidden crumbs elsewhere (Ionic suggests a popover) — the event carries their built Elements, so render such a list from your own crumb data.

razor
@* Six crumbs, MaxItems 4: the middle ones collapse behind "…". Tapping it expands them all. *@
<IonBreadcrumbs MaxItems="@_maxItems" OnCollapsedClick="Expand">
    <IonBreadcrumb Href="#">Home</IonBreadcrumb>
    <IonBreadcrumb Href="#">Electronics</IonBreadcrumb>
    <IonBreadcrumb Href="#">Photography</IonBreadcrumb>
    <IonBreadcrumb Href="#">Cameras</IonBreadcrumb>
    <IonBreadcrumb Href="#">Film</IonBreadcrumb>
    <IonBreadcrumb>35 mm</IonBreadcrumb>
</IonBreadcrumbs>

@code {
    private int? _maxItems = 4;

    private void Expand(IonBreadcrumbCollapsedClickEventArgs args) => _maxItems = null;
}
razor
@* Keep two crumbs before the indicator and two after it. *@
<IonBreadcrumbs MaxItems="4" ItemsBeforeCollapse="2" ItemsAfterCollapse="2">
    <IonBreadcrumb Href="#">Home</IonBreadcrumb>
    <IonBreadcrumb Href="#">Electronics</IonBreadcrumb>
    <IonBreadcrumb Href="#">Photography</IonBreadcrumb>
    <IonBreadcrumb Href="#">Cameras</IonBreadcrumb>
    <IonBreadcrumb Href="#">Film</IonBreadcrumb>
    <IonBreadcrumb>35 mm</IonBreadcrumb>
</IonBreadcrumbs>

With ItemsAfterCollapse="0" the crumb carrying the indicator counts as the last one: it loses its separator and becomes active.

Colors ​

Color on IonBreadcrumbs gives every crumb's label and separator that palette color, overriding the active crumb's color; Color on one IonBreadcrumb colors just that crumb's label. Slotted icons keep the IconColor / IconColorActive token colors either way. See Theming.

razor
@* Color on the container recolors every crumb; on a crumb it recolors only that one. *@
<IonBreadcrumbs Color="primary">
    <IonBreadcrumb Href="#">Home</IonBreadcrumb>
    <IonBreadcrumb Href="#">Electronics</IonBreadcrumb>
    <IonBreadcrumb>Cameras</IonBreadcrumb>
</IonBreadcrumbs>

<IonBreadcrumbs>
    <IonBreadcrumb Href="#">Home</IonBreadcrumb>
    <IonBreadcrumb Href="#" Color="danger">Recalled</IonBreadcrumb>
    <IonBreadcrumb>Cameras</IonBreadcrumb>
</IonBreadcrumbs>

API ​

Every component also accepts Class (extra CSS classes), Style (an inline Style object) and Id (the root element's id) — see Conventions.

IonBreadcrumbs ​

ParameterTypeDefaultDescription
Colorstring?nullNamed palette color (Ionic color) applied to the breadcrumbs.
ItemsAfterCollapseint1The number of breadcrumbs to show after the collapsed indicator (Ionic itemsAfterCollapse).
ItemsBeforeCollapseint1The number of breadcrumbs to show before the collapsed indicator (Ionic itemsBeforeCollapse). If ItemsBeforeCollapse + ItemsAfterCollapse is greater than MaxItems, the breadcrumbs will not be collapsed.
MaxItemsint?nullThe maximum number of breadcrumbs to show before collapsing (Ionic maxItems). When the crumb count exceeds this, the middle crumbs are collapsed behind a "…" indicator. No collapsing when null.
EventTypeDescription
OnCollapsedClickEventCallback<IonBreadcrumbCollapsedClickEventArgs>Raised when the collapsed indicator is clicked (Ionic ionCollapsedClick); carries the collapsed crumbs so the app can reveal them (e.g. in a popover).
SlotTypeDescription
ChildContentRenderFragment?Content placed between the component's tags.

IonBreadcrumb ​

ParameterTypeDefaultDescription
ActiveboolfalseIf true, the breadcrumb takes on the active look. The enclosing IonBreadcrumbs sets this on the last breadcrumb when none is explicitly active.
Colorstring?nullNamed palette color (Ionic color): "primary", "danger", ....
DisabledboolfalseIf true, the breadcrumb is dimmed and non-interactive.
Hrefstring?nullThe route the breadcrumb navigates to (Ionic href). When set the native element is an anchor with the link styling (ion-activatable), and a tap raises OnClick and then navigates through the app's NavigationManager, as Ionic's openURL does.
RouterDirectionstring?nullNavigation direction for Href (Ionic routerDirection): "forward" (default — push with the mode's transition), "back" (pop-style transition), or "root" (clear the history, no transition).
EventTypeDescription
OnClickEventCallbackRaised when the breadcrumb is tapped — before it navigates, when it has an Href. Not raised while Disabled.
SlotTypeDescription
ChildContentRenderFragment?Content placed between the component's tags.
EndRenderFragment?Content shown after the label (Ionic slot="end").
SeparatorRenderFragment?Custom separator content (Ionic slot="separator"). When set it replaces the default separator glyph ("/" on md, a forward chevron on ios). The enclosing IonBreadcrumbs still strips the whole separator from the last crumb.
StartRenderFragment?Content shown before the label (Ionic slot="start").

Types ​

IonBreadcrumbCollapsedClickEventArgs ​

Payload for IonBreadcrumbs.OnCollapsedClick, raised when the collapsed indicator (the "…" button shown when IonBreadcrumbs.MaxItems hides the middle crumbs) is clicked. Mirrors Ionic's ionCollapsedClick event detail (BreadcrumbCollapsedClickEventDetail), which carries the collapsed breadcrumbs so the app can e.g. open them in a popover.

PropertyTypeDefaultDescription
CollapsedBreadcrumbsIReadOnlyList<Element>—The breadcrumb host elements currently hidden by the collapse, in document order (Ionic passes the HTMLIonBreadcrumbElements; Miko passes their built Element subtrees). (read-only)

Styling ​

Theme tokens ​

Theme token IonicTheme.Breadcrumb (BreadcrumbToken). Assign only the values you want to change — the rest keep the mode defaults below. App-wide: builder.AddIonic(o => o.Theme.Breadcrumb = new BreadcrumbToken { … }); for one subtree: a ConfigProvider. See Theming.

TokenTypemdios
ActiveFontWeightFontWeightFontWeight.MediumFontWeight.SemiBold
BorderRadiusfloat04
ColorColor#677483#2d4665
ColorActiveColor#03060b#03060b
FontSizefloat1616
IconColorColor#7d8894#92a0b3
IconColorActiveColor#222d3a#242d39
IconFontSizefloat1818
IconSlotMarginfloat88
IndicatorBackgroundColor#eef1f3#e9edf3
IndicatorBorderRadiusfloat24
IndicatorColorColor#73849a#73849a
IndicatorHeightfloat1818
IndicatorIconSizefloat2222
IndicatorMarginXfloat1414
IndicatorWidthfloat3232
PaddingXfloat1212
PaddingYfloat65
SeparatorColorColor#73849a#73849a
SeparatorMarginXfloat1010

CSS classes ​

App stylesheet rules always win over Ionic's own rules (see Theming), so these classes can be targeted directly from GlobalStyles.cs.

SelectorElement
.ion-breadcrumbsThe container row. Also carries the mode (md / ios).
.ion-breadcrumbOne crumb host.
.ion-breadcrumb .breadcrumb-nativeThe label surface (<a> with Href, otherwise <span>), holding the label and the Start / End content.
.ion-breadcrumb .breadcrumb-separatorThe separator (absent on the last crumb).
.ion-breadcrumb .ion-slot-start, .ion-breadcrumb .ion-slot-endWrappers around Start / End content.
.breadcrumb-active, .breadcrumb-disabledThe active crumb; Disabled.
.ion-activatableA crumb with Href.
.breadcrumb-collapsedA crumb hidden by MaxItems (its .breadcrumb-native is not displayed).
.ion-breadcrumb .breadcrumbs-collapsed-indicatorThe "…" indicator.
.ion-color-{name}Color on the container or a crumb (e.g. .ion-color-primary).
.in-breadcrumbs-colorA crumb inside a colored IonBreadcrumbs.
csharp
// GlobalStyles.cs — a larger, spaced trail: <IonBreadcrumbs Class="trail">…</IonBreadcrumbs>
[".ion-breadcrumbs.trail .ion-breadcrumb"] = new()
{
    FontSize = Length.Px(18),
},
[".ion-breadcrumbs.trail .breadcrumb-separator"] = new()
{
    MarginLeft = Length.Px(12),
    MarginRight = Length.Px(12),
},

Released under the MIT License.