Navigation

Breadcrumb

Simple breadcrumb

Try it yourself on the playground

Playground

Long breadcrumb

When there are more than 3 items, the breadcrumb should be collapsed by default and items should be displayed if there's enough space.

The first item and the last 2 items should always be visible.

Try it yourself on the playground

Playground

JS behaviour

Auto initialisation

In order to automatically initalise the JS behaviour, add data-ecl-auto-init="Breadcrumb" to your component's markup:

<nav
  class="ecl-breadcrumb"
  aria-label="You are here:"
  data-ecl-breadcrumb
  data-ecl-auto-init="Breadcrumb"
>
  ...
</nav>

Don't forget to call ECL.autoInit() when your page is ready!

Manual initialisation

When the document is ready, query the element. For example, you can use document.querySelector('[data-ecl-breadcrumb]') if you only have 1 breadcrumb in the page.

Then, instantiate the Breadcrumb component and call init():

var elt = document.querySelector('[data-ecl-breadcrumb]');
var breadcrumb = new ECL.Breadcrumb(elt);
breadcrumb.init();