Breadcrumb

Description

Show hierarchies of navigation paths, also display the current location within a website's structure.

FREE
This component is available for free. It implements the Bootstrap Breadcrumb component. See the installation instructions below for more details.

Arguments

Name Default Type Description
wrapper_attributes {} Hash Any attributes for the outer list element
html_attributes {} Hash Any attributes for the used html wrapper tag

Examples

Default

<%= render Railsboot::BreadcrumbComponent.new do |breadcrumb| %>
  <% breadcrumb.with_item(text: "Item 1", href: "#") %>
  <% breadcrumb.with_item(text: "Item 2", href: "#") %>
  <% breadcrumb.with_item(text: "Item 3", href: "#") %>
<% end %>
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">
      <a href="#">Item 1</a>
    </li>
    <li class="breadcrumb-item">
      <a href="#">Item 2</a>
    </li>
    <li class="breadcrumb-item">
      <a href="#">Item 3</a>
    </li>
  </ol>
</nav>

With active item

<%= render Railsboot::BreadcrumbComponent.new do |breadcrumb| %>
  <% breadcrumb.with_item(text: "Item 1", href: "#") %>
  <% breadcrumb.with_item(text: "Item 2", href: "#") %>
  <% breadcrumb.with_item(text: "Item 3", href: "#", active: true) %>
<% end %>
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">
      <a href="#">Item 1</a>
    </li>
    <li class="breadcrumb-item">
      <a href="#">Item 2</a>
    </li>
    <li class="breadcrumb-item active" aria-current="page">
      Item 3
    </li>
  </ol>
</nav>

Slots

item Railsboot::Breadcrumb::ItemComponent Allows many

An item represents an individual link within the breadcrumb hierarchy.

Name Default Type Description
text String The text of the item
href String the href of the item
active Boolean Defines if the item is currently active or not
html_attributes {} Hash Any attributes for the used html wrapper tag

Installation

Simply download this component with all its related files and assets. Unpackage the downloaded ZIP-file, copy all relevant files into your app and adapt the things you need. The ZIP-folder contains:

  • A parent component class (app/components/railsboot/component.rb) of which all components inherit from.
  • A base component class (app/components/railsboot/base_component.rb) which is used for rendering internally.
  • The desired component itself (app/components/railsboot/breadcrumb_component.rb).
  • A view template (app/components/railsboot/breadcrumb_component.html.erb) for the component unless it's rendered inline.
  • Any other dependent components such as Slots (just if the component needs those)
  • Any dependent assets (JS-Files, CSS-Files) (just if the component needs those)
  • A test file for the components (test/components/railsboot/breadcrumb_component_test.rb) including potential slot or dependency tests.

For more information please refer to the installation section.

Download

Download the component and its related files (e.g. templates, assets, slots etc.), unpackage the zip file and adapt the things you need.