You can fetch Trowel Breadcrumbs with npm, yarn or bower.
# With bower
$ bower install --save trowel-breadcrumbs
# With npm
$ npm install --save trowel-breadcrumbs
# With yarn
$ yarn add trowel-breadcrumbs
You can also download a zip archive right here.
The main scss file to include to your main .scss
file is located at the ./src/scss/breadcrumbs.scss
. As a Trowel Component, it also requires two dependencies to compile the scss code. Here an scss installation snippet.
// Trowel core (need to be imported first)
@import './path/to/dependencies/trowel-core/src/trowel';
// Trowel Breadcrumbs
@import './path/to/dependencies/trowel-breadcrumbs/src/scss/breadcrumbs';
You have several javascript files for different use cases :
./dest/javascript/breadcrumbs.js
(a minified version exists at dest/javascript/breadcrumbs.min.js
)import
is available at ./src/javascript/breadcrumbs.js
<nav class="breadcrumb" data-flag="breadcrumb">
<div class="breadcrumb__header">
<button class="breadcrumb__toggle" data-breadcrumb="toggle">Previous pages</button>
<a class="breadcrumb__back" onclick="history.go(-1)">Back</a>
</div>
<ul class="breadcrumb__list" data-breadcrumb="list" data-state="hidden">
<li class="breadcrumb__list-item">
<a class="breadcrumb__item" href="#">item 1</a>
</li>
<li class="breadcrumb__list-item">
<a class="breadcrumb__item" href="#">item 2</a>
</li>
<li class="breadcrumb__list-item">
<span class="breadcrumb__item breadcrumb__item--active">item 3</span>
</li>
</ul>
</nav>
You can with the variable $breadcrumbs--responsive-breakpoint
setup the breakpoint where starts the “desktop” layout. Then you need to setup some javascript to work on small devices. You can do it into the html directly or with an import following es6 syntax :
<!-- As close of the </body> tag as possible -->
<script src="./path/to/trowel-breadcrumbs/dest/javascript/breadcrumbs.js"></script>
<script type="text/javascript">
var breadcrumbs = new TrowelBreadcrumbs(document.querySelectorAll('[data-flag="breadcrumb"]'));
</script>
import TrowelBreadcrumbs from './path/to/trowel-breadcrumbs/src/javascript/breadcrumbs';
const breadcrumbs = new TrowelBreadcrumbs(document.querySelectorAll('[data-flag="breadcrumb"]'));
Instead of writing html, you can include
the twig template :
{% include "path/to/trowel-breadcrumbs/src/twig/breadcrumb.html.twig" with {
"items": [{
"href": "#",
"label": "item 1",
}, {
"href": "#",
"label": "item 2",
}, {
"label": "item 3",
"active": true,
}]
} %}
If you want to add some modifiers on the block selector (.breadcrumb
), you can set the array modifiers
with as many modifiers as you need :
{% include "path/to/trowel-breadcrumbs/src/twig/breadcrumb.html.twig" with {
"modifiers": ['primary', 'lg'],
"items": [{
"href": "#",
"label": "item 1",
}, {
"href": "#",
"label": "item 2",
}, {
"label": "item 3",
"active": true,
}]
} %}
If you setted some syntax config, you will have to pass it to the include
:
{% include "path/to/trowel-breadcrumbs/src/twig/breadcrumb.html.twig" with {
"syntax": {
"prefix": "c",
"separator": {
"prefix": "-",
"element": "-",
"modifier": "-",
},
},
"items": [{
"href": "#",
"label": "item 1",
}, {
"href": "#",
"label": "item 2",
}, {
"label": "item 3",
"active": true,
}]
} %}
For changing the back and toggle buttons label, replace the include
statement by embed
and overwrite the blocks toggle_label
and back_label
:
{% embed "path/to/trowel-breadcrumbs/src/twig/breadcrumb.html.twig" with {
"items": [{
"href": "#",
"label": "item 1",
}, {
"href": "#",
"label": "item 2",
}, {
"label": "item 3",
"active": true,
}]
} %}
{% block toggle_label %}Previous{% endblock %}
{% block back_label %}Go back{% endblock %}
{% endembed %}
You can override the global syntax config for a specific component with the following variables
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$breadcrumbs--syntax |
null |
syntax config for .breadcrumb |
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$breadcrumbs--responsive-breakpoint |
'@sm' |
not a trowel variable |
$breadcrumbs--font-size |
( |
sets the font-size property on .breadcrumb |
$breadcrumbs--font-family |
null |
sets the font-family property on .breadcrumb |
$breadcrumbs--font-weight |
null |
sets the font-weight property on .breadcrumb |
$breadcrumbs--text-transform |
null |
sets the text-transform property on .breadcrumb |
$breadcrumbs--letter-spacing |
null |
sets the letter-spacing property on .breadcrumb |
$breadcrumbs--line-height |
null |
sets the line-height property on .breadcrumb |
$breadcrumbs--text-align |
null |
sets the text-align property on .breadcrumb |
$breadcrumbs--text-decoration |
null |
sets the text-decoration property on .breadcrumb |
$breadcrumbs--margin |
0 0 1em |
sets the margin property on .breadcrumb |
$breadcrumbs--padding |
0.65em 1.65em |
sets the padding property on .breadcrumb |
$breadcrumbs--border-width |
null |
sets the border-width property on .breadcrumb |
$breadcrumbs--border-style |
null |
sets the border-style property on .breadcrumb |
$breadcrumbs--border-color |
null |
sets the border-color property on .breadcrumb |
$breadcrumbs--border-radius |
null |
sets the border-radius property on .breadcrumb |
$breadcrumbs--color |
rgb(255, 255, 255) |
sets the color property on .breadcrumb |
$breadcrumbs--box-shadow |
null |
sets the box-shadow property on .breadcrumb |
$breadcrumbs--background |
null |
sets the background property on .breadcrumb |
$breadcrumbs--background-color |
rgb(31, 13, 51) |
sets the background-color property on .breadcrumb |
Toggle | ||
VARIABLE | DEFAULT VALUE | DESCRIPTION |
$breadcrumbs-toggle--padding |
0.65em 1.65em |
sets the padding property on .breadcrumb__toggle |
$breadcrumbs-toggle--font-weight |
null |
sets the font-weight property on .breadcrumb__toggle |
$breadcrumbs-toggle--line-height |
1.2 |
sets the line-height property on .breadcrumb__toggle |
$breadcrumbs-toggle--border |
0 |
sets the border property on .breadcrumb__toggle |
$breadcrumbs-toggle--padding |
null |
sets the padding property on .breadcrumb__toggle |
$breadcrumbs-toggle--border-radius |
0.2em |
sets the border-radius property on .breadcrumb__toggle |
$breadcrumbs-toggle--font-size |
1em |
sets the font-size property on .breadcrumb__toggle |
$breadcrumbs-toggle--border-radius |
null |
sets the border-radius property on .breadcrumb__toggle |
$breadcrumbs-toggle--transition |
null |
sets the transition property on .breadcrumb__toggle |
$breadcrumbs-toggle--background-color |
( |
sets the background-color property on .breadcrumb__toggle |
$breadcrumbs-toggle--color |
rgb(255, 255, 255) |
sets the color property on .breadcrumb__toggle |
$breadcrumbs-toggle--letter-spacing |
null |
sets the letter-spacing property on .breadcrumb__toggle |
$breadcrumbs-toggle--font-style |
null |
sets the font-style property on .breadcrumb__toggle |
$breadcrumbs-toggle--text-transform |
null |
sets the text-transform property on .breadcrumb__toggle |
$breadcrumbs-toggle--text-decoration |
null |
sets the text-decoration property on .breadcrumb__toggle |
$breadcrumbs-toggle--box-shadow |
null |
sets the box-shadow property on .breadcrumb__toggle |
Back | ||
VARIABLE | DEFAULT VALUE | DESCRIPTION |
$breadcrumbs-back--padding |
null |
sets the padding property on .breadcrumb__back |
$breadcrumbs-back--font-weight |
null |
sets the font-weight property on .breadcrumb__back |
$breadcrumbs-back--line-height |
1.2 |
sets the line-height property on .breadcrumb__back |
$breadcrumbs-back--border |
null |
sets the border property on .breadcrumb__back |
$breadcrumbs-back--border-radius |
null |
sets the border-radius property on .breadcrumb__back |
$breadcrumbs-back--font-size |
1em |
sets the font-size property on .breadcrumb__back |
$breadcrumbs-back--border-radius |
null |
sets the border-radius property on .breadcrumb__back |
$breadcrumbs-back--transition |
null |
sets the transition property on .breadcrumb__back |
$breadcrumbs-back--background-color |
null |
sets the background-color property on .breadcrumb__back |
$breadcrumbs-back--color |
rgb(255, 255, 255) |
sets the color property on .breadcrumb__back |
$breadcrumbs-back--letter-spacing |
null |
sets the letter-spacing property on .breadcrumb__back |
$breadcrumbs-back--font-style |
null |
sets the font-style property on .breadcrumb__back |
$breadcrumbs-back--text-transform |
null |
sets the text-transform property on .breadcrumb__back |
$breadcrumbs-back--text-decoration |
( |
sets the text-decoration property on .breadcrumb__back |
$breadcrumbs-back--box-shadow |
null |
sets the box-shadow property on .breadcrumb__back |
List | ||
VARIABLE | DEFAULT VALUE | DESCRIPTION |
$breadcrumbs-list--background-color |
$breadcrumbs--background-color |
sets the background-color property on .breadcrumb__list |
$breadcrumbs-list--transition |
all 300ms ease-in-out |
sets the transition property on .breadcrumb__list |
$breadcrumbs-list--hidden-transform |
translateY(-25%) |
sets the transform property on .breadcrumb__list when the list is hidden |
Separator | ||
VARIABLE | DEFAULT VALUE | DESCRIPTION |
$breadcrumbs-separator--content |
'>' |
sets the separator content between to list items when the device resolution is higher than responsive breakpoint |
$breadcrumbs-separator--margin-x |
0.5em |
sets the left and right margin |
Item | ||
VARIABLE | DEFAULT VALUE | DESCRIPTION |
$breadcrumbs-item--color |
inherit |
sets the color property on .breadcrumb__item |
$breadcrumbs-item--text-decoration |
( |
sets the text-decoration property on .breadcrumb__item |
$breadcrumbs-item--font-style |
( |
sets the font-style property on .breadcrumb__item |
$breadcrumbs-item--padding |
( |
sets the padding property on .breadcrumb__item |
$background-coloradcrumbs-item--background-color |
( |
sets the color property on .breadcrumb__item |
$breadcrumbs-item--font-size |
null |
sets the font-size property on .breadcrumb__item |
$breadcrumbs-item--text-transform |
null |
sets the text-transform property on .breadcrumb__item |
$breadcrumbs-item--font-weight |
null |
sets the font-weight property on .breadcrumb__item |
$breadcrumbs-item--line-height |
null |
sets the line-height property on .breadcrumb__item |
$breadcrumbs-item--font-family |
null |
sets the font-family property on .breadcrumb__item |
$breadcrumbs-item--text-shadow |
null |
sets the text-shadow property on .breadcrumb__item |
$breadcrumbs-item--opacity |
( |
sets the opacity property on .breadcrumb__item |