Simple breadcrumb
<nav class="ecl-breadcrumb" aria-label="You are here:" data-ecl-breadcrumb="true">
<ol class="ecl-breadcrumb__container">
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="static" aria-hidden="false"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">Home</a><svg focusable="false" aria-hidden="true"
role="presentation" class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="static" aria-hidden="false"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">About the European Commission</a><svg
focusable="false" aria-hidden="true" role="presentation"
class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment ecl-breadcrumb__current-page" aria-current="page"
data-ecl-breadcrumb-item="static" aria-hidden="false">News</li>
</ol>
</nav>
Try it yourself on the playground
PlaygroundLong 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.
<nav class="ecl-breadcrumb" aria-label="You are here:" data-ecl-breadcrumb="true">
<ol class="ecl-breadcrumb__container">
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="static" aria-hidden="false"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">Home</a><svg focusable="false" aria-hidden="true"
role="presentation" class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment ecl-breadcrumb__segment--ellipsis" aria-hidden="false"
data-ecl-breadcrumb-ellipsis="true"><button type="button" class="ecl-breadcrumb__ellipsis"
aria-label="Click to expand" data-ecl-breadcrumb-ellipsis-button="true">…</button><svg focusable="false"
aria-hidden="true" role="presentation" class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="expandable" aria-hidden="false"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">About the European Commission</a><svg
focusable="false" aria-hidden="true" role="presentation"
class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="expandable" aria-hidden="true"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">Organisational structure</a><svg focusable="false"
aria-hidden="true" role="presentation" class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment" data-ecl-breadcrumb-item="static" aria-hidden="false"><a href="/example"
class="ecl-breadcrumb__link ecl-link ecl-link--standalone">How the Commission is organised</a><svg
focusable="false" aria-hidden="true" role="presentation"
class="ecl-breadcrumb__icon ecl-icon ecl-icon--xs ecl-icon--rotate-90">
<use xlink:href="/dist/media/icons.db866e2e.svg#ui--corner-arrow"></use>
</svg></li>
<li class="ecl-breadcrumb__segment ecl-breadcrumb__current-page" aria-current="page"
data-ecl-breadcrumb-item="static" aria-hidden="false">News</li>
</ol>
</nav>
Try it yourself on the playground
PlaygroundJS 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();