Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Breadcrumb

Layer: molecule · Path: src/molecules/breadcrumb.rs · Exports: breadcrumb::Breadcrumb

A horizontal path trail. Every item except the last renders as a link-style Button separated by caret icons; the last item is plain strong text (the current location). show reports which crumb was clicked this frame. Analogous to the shadcn Breadcrumb.

Design

  • Purpose / when to use — Show hierarchical location (asset path, navigation trail) and let the user jump back to an ancestor.
  • Anatomyui.horizontal row of: per non-last item a small link Button followed by a muted CARET_RIGHT Icon; the final item a body_strong Text.
  • Tokens / layout consumed — none directly; relies on atom sizing (Button::sm, Icon::sm). See tokens.

API

MethodEffect
Breadcrumb::new() -> SelfEmpty trail. (Default also available.)
.items<S: Into<String>>(items: impl IntoIterator<Item = S>) -> SelfSet the ordered crumbs.
.show(self, ui: &mut Ui) -> Option<usize>Render; returns Some(i) for the crumb clicked this frame, else None.

Usage

#![allow(unused)]
fn main() {
use ouroboros_ui::molecules::Breadcrumb;

// minimal
Breadcrumb::new().items(["Home", "Library"]).show(ui);
}
#![allow(unused)]
fn main() {
use ouroboros_ui::molecules::Breadcrumb;

// realistic — react to a click
if let Some(i) = Breadcrumb::new()
    .items(["Assets", "Models", "Characters", "hero.fbx"])
    .show(ui)
{
    navigate_to_depth(i);
}
}

Composition

Composes Button (ButtonVariant::Link), Icon, and Text. It never paints — see the guards.

Notes

  • Returns Option<usize> rather than a Response — the index is the actionable signal.
  • Per-crumb button ids are derived via .id_source(("crumb", i)), so multiple breadcrumbs in one frame are safe.
  • The last crumb is non-interactive by design (it’s the current node).