Skip to main content

Breadcrumb partials

These partials follow the shared rules in Server templates. The tabs remember your framework, and a link can choose it with ?server-framework=laravel.

The partial takes the trail as a list of label and URL pairs, ending with the current page, which gets aria-current="page". The element names the landmark "Breadcrumb" unless you pass a name.

app/views/rc/_breadcrumbs.html.erb
<%# locals: (items:, label: nil) -%>
<rc-breadcrumbs>
<nav <%= tag.attributes(aria: { label: label }) %>>
<ol>
<% items.each_with_index do |(text, path), index| -%>
<li><a <%= tag.attributes(href: path, aria: { current: ("page" if index == items.size - 1) }) %>><%= text %></a></li>
<% end -%>
</ol>
</nav>
</rc-breadcrumbs>
<%= render "rc/breadcrumbs", items: [
["Home", root_path],
["Settings", settings_path],
["Members", settings_members_path],
] %>