PhiaUi.Components.Breadcrumb (phia_ui v0.1.17)

Copy Markdown View Source

Breadcrumb navigation component following the shadcn/ui Breadcrumb anatomy.

Breadcrumbs communicate the current page's location within the site hierarchy and allow users to navigate upward. This implementation is purely HEEx with no JavaScript required. Full WAI-ARIA support is included out of the box.

Sub-components

ComponentElementPurpose
breadcrumb/1<nav>Landmark wrapper with aria-label="breadcrumb"
breadcrumb_list/1<ol>Ordered flex container for items
breadcrumb_item/1<li>Individual item wrapper
breadcrumb_link/1<a>Navigable ancestor link
breadcrumb_page/1<span>Current page label (aria-current="page")
breadcrumb_separator/1<li>Visual separator (default: /)
breadcrumb_ellipsis/1<span>Collapsed path indicator ()

Basic usage

<.breadcrumb>
  <.breadcrumb_list>
    <.breadcrumb_item>
      <.breadcrumb_link href="/">Home</.breadcrumb_link>
    </.breadcrumb_item>
    <.breadcrumb_separator />
    <.breadcrumb_item>
      <.breadcrumb_link href="/settings">Settings</.breadcrumb_link>
    </.breadcrumb_item>
    <.breadcrumb_separator />
    <.breadcrumb_item>
      <.breadcrumb_page>Profile</.breadcrumb_page>
    </.breadcrumb_item>
  </.breadcrumb_list>
</.breadcrumb>

Nested resource navigation

Useful when displaying a deeply-nested record in an admin panel, e.g. Organizations > Acme Corp > Teams > Engineering > Members > Jane:

<.breadcrumb>
  <.breadcrumb_list>
    <.breadcrumb_item>
      <.breadcrumb_link navigate={~p"/organizations"}>Organizations</.breadcrumb_link>
    </.breadcrumb_item>
    <.breadcrumb_separator />
    <.breadcrumb_item>
      <.breadcrumb_link navigate="/organizations/acme">
        Acme Corp
      </.breadcrumb_link>
    </.breadcrumb_item>
    <.breadcrumb_separator />
    <%!-- Collapse intermediate levels on small viewports --%>
    <.breadcrumb_item>
      <.breadcrumb_ellipsis />
    </.breadcrumb_item>
    <.breadcrumb_separator />
    <.breadcrumb_item>
      <.breadcrumb_page>{@member.name}</.breadcrumb_page>
    </.breadcrumb_item>
  </.breadcrumb_list>
</.breadcrumb>

Custom separator

Replace the default / with any icon or character:

<.breadcrumb_separator>
  <.icon name="chevron-right" size={:xs} />
</.breadcrumb_separator>

Accessibility

  • The <nav> root carries aria-label="breadcrumb" so screen readers announce it as a distinct landmark.
  • The current page <span> carries aria-current="page" so screen readers convey that the user is viewing this item.
  • Separators carry aria-hidden="true" to avoid cluttering screen reader output with decorative punctuation.
  • The <ol> element communicates order semantics to assistive technologies.

Summary

Functions

Renders the <nav aria-label="breadcrumb"> landmark wrapper.

Renders a ellipsis to indicate that intermediate path segments have been collapsed.

Renders a <li> wrapper for a single breadcrumb entry.

Renders a navigable ancestor link in the breadcrumb trail.

Renders the <ol> flex container that holds all breadcrumb items.

Renders the current page label — the last and non-interactive crumb.

Renders a breadcrumb separator between two items.

Functions