Skip to content

Breadcrumbs

Avo has a pretty advanced breadcrumbs system.

It will use the resource avatar or initials to display the breadcrumb and context.

Breadcrumbs

It has minimal configuration options but you will have the oportunity to interact with it in a few places like the avo.rb config file or in the controller actions when you want to add breadcrumbs to a custom tool.

API

add_breadcrumb

This method is used to add a breadcrumb to the stack. It takes the following arguments:

Options

title

Sets the title of the breadcrumb.

ruby
add_breadcrumb title: "Home"
add_breadcrumb title: "Details"
OptionValue
Requiredtrue
Default valuenil
Possible valuesStrings

path

This sets the link of the breadcrumb.

ruby
add_breadcrumb title: "Posts", path: avo.posts_path
add_breadcrumb title: "Custom tool", path: avo.custom_tool_path

WARNING

You're most probably linking to an internal Avo page, so you need to prefix the path using the avo dot as per Rails' engine rules. See Rails engines and path helpers for a full guide.

OptionValue
Requiredfalse
Default valuenil
Possible valuesStrings

icon

Sets the icon of the breadcrumb.

ruby
add_breadcrumb title: "Home", icon: "heroicons/outline/home"
add_breadcrumb title: "Details", icon: "heroicons/outline/information-circle"
OptionValue
Requiredfalse
Default valuenil
Possible valuesIcon strings (e.g. "heroicons/outline/home")

initials

Sets the initials displayed in the breadcrumb avatar when no icon is present. Useful for resource records where you want to show abbreviated identifiers (e.g. "JD" for a user named John Doe).

ruby
add_breadcrumb title: "John Doe", initials: "JD", path: user_path(@user)
add_breadcrumb title: "Post #123", initials: "P123", path: post_path(@post)
OptionValue
Requiredfalse
Default valuenil
Possible valuesStrings

It returns the breadcrumb object.

ruby
add_breadcrumb title: "Home", path: root_path

You can add breadcrumbs to custom pages in the controller action.

ruby
class Avo::ToolsController < Avo::ApplicationController
  def custom_tool
    add_breadcrumb title: "Custom tool", path: avo.custom_tool_path
  end
end