Breadcrumb element
When generating a breadcrumb an <ol>
element containing all necessary menu items is written to the output.
Element and builder
The BreadcrumbNavComponentBuilder
is provided to easily build breadcrumbs.
A builder can be created using BootstrapUiBuilders.breadcrumb()
factory methods which takes in a Menu
as parameter.
BreadcrumbNavComponentBuilder attributes
Attribute | Description | Default |
---|---|---|
|
Set the number of levels (breadcrumb segments) for which the icon will be rendered if there is one. |
By default all items will have their icons rendered. |
|
Set the number of levels (breadcrumb segments) that will be rendered as just the icon if NavComponentBuilder#ATTR_ICON_ONLY}` is |
By default all segments might be rendered this way. |
Breadcrumb items
The first step in building a breadcrumb is determining the menu items that will be used. When a menu item is disabled or filtered out, it will not be used to render the breadcrumb items. All menuItems that should be visible as breadcrumb items in the breadcrumb are build and the last item will be set active.
Attribute | Description | Default |
---|---|---|
|
When set a |
Not set by default |
|
If set to |
Not set by default |
For all the attributes consult the javadoc of NavComponentBuilder
.
Examples
Creating a simple breadcrumb navigation
Given the following builder configuration
Menu menu = new PathBasedMenuBuilder()
.item( "components", "Components" ).and()
.item( "components/breadcrumb", "Breadcrumb example" ).and().build();
menu.select( MenuSelector.byTitle( "Breadcrumb example" ) );
menu.setTitle( "Bootstrap UI Module" );
NodeViewElement breadcrumbNav = BootstrapUiBuilders.breadcrumb( menu ).build();
The following markup would be rendered:
<ol class="breadcrumb">
<li><a href="/" title="Bootstrap UI Module">Bootstrap UI Module</a></li>
<li><a href="/components" title="Components">Components</a></li>
<li class="active">Breadcrumb example</li>
</ol>
Creating a breadcrumb navigation with icons
Given the following builder configuration
Menu menu = new PathBasedMenuBuilder()
.item( "components", "Components" )
.attribute( NavComponentBuilder.ATTR_ICON, new GlyphIcon( GlyphIcon.HOME ) )
.attribute( NavComponentBuilder.ATTR_ICON_ONLY, true ).and()
.item( "components/breadcrumb", "Breadcrumb example" )
.attribute( NavComponentBuilder.ATTR_ICON, new GlyphIcon( GlyphIcon.HOURGLASS ) )
.and().build();
menu.select( MenuSelector.byTitle( "Breadcrumb example" ) );
menu.setTitle( "Bootstrap Ui Module" );
NodeViewElement breadcrumbNav = BootstrapUiBuilders.breadcrumb( menu ).build();
The following markup would be rendered:
<ol class="breadcrumb">
<li><a href="/" title="Bootstrap Ui Module">Bootstrap Ui Module</a></li>
<li><a href="/components" title="Components"><span aria-hidden="true" class="glyphicon glyphicon-home"></span> <span class="nav-item-title">Components</span></a></li>
<li class="active"><span aria-hidden="true" class="glyphicon glyphicon-hourglass"></span> Breadcrumb example</li>
</ol>