iced-cube

Navigation

Breadcrumb

Shows where the current view sits in a hierarchy, with a link to each level above it.

use iced_cube::{breadcrumb, crumb, lucide};
use iced_cube::navigation::breadcrumb::Separator;
API reference
Default: A folder path with a home icon. Clicking a level opens it and trims the trail.Default: A folder path with a home icon. Clicking a level opens it and trims the trail.
Static preview
Default. A folder path with a home icon. Clicking a level opens it and trims the trail.

Usage

The app holds the path and builds the trail from it on every view, giving each level above the current one a message that opens it. The breadcrumb only draws the trail, so the levels can be folders, settings sections or records.

On a narrow screen the trail stays on one line by hiding more of its middle behind the ellipsis, down to the root and the current view, and only wraps if even that does not fit. Labels are never squeezed. Once someone expands the trail, .collapse_to_fit(false) shows every crumb and lets it wrap instead. For deep hierarchies, .max_items keeps the root and the levels nearest the current view, which are the ones people go back to most, and .on_expand lets them see the rest.

The keymap’s actions return an index rather than an event, because the app owns the path: action.target(len) says which crumb to open, as the keyboard example shows.

Examples

Collapsed

A long trail with slash separators keeps its first and last levels. The ellipsis shows the rest.

Collapsed: A long trail with slash separators keeps its first and last levels. The ellipsis shows the rest.Collapsed: A long trail with slash separators keeps its first and last levels. The ellipsis shows the rest.
Static preview

Keyboard shortcuts

Alt+Up goes to the parent level and Alt+Shift+Up to the root, through the default keymap.

Keyboard shortcuts: Alt+Up goes to the parent level and Alt+Shift+Up to the root, through the default keymap.Keyboard shortcuts: Alt+Up goes to the parent level and Alt+Shift+Up to the root, through the default keymap.
Static preview

API

ItemDescription
breadcrumb(crumbs)Creates a trail from the root to the current view. The last crumb is the current view and never responds to clicks.
crumb(label)Creates a crumb. It is plain text until it has a message.
.on_press(message) / .on_press_maybe(option)Makes a crumb a link that sends the message.
.icon(glyph)Adds a Lucide icon before a crumb's label, such as a house for the root.
.separator(Separator)Chevron or Slash between crumbs. Defaults to Chevron.
.max_items(n)Shows at most n crumbs: the first and the last n - 1, with an ellipsis for the rest. n is at least 2.
.on_expand(message)Makes the ellipsis a button that sends the message, such as one that shows the whole trail.
.collapse_to_fit(bool)Whether a trail too wide for one line hides more of its middle until it fits. Defaults to true. Turn it off to show every crumb, wrapping onto more lines.
breadcrumb::fit_limits(len, max)The crumb limits a trail tries, longest first, when collapsing to fit.
breadcrumb::slots(len, max)The crumbs and ellipsis a trail of len shows for a limit, for custom layouts.
breadcrumb::default_keymap()The default shortcuts as a Keymap<Action>. Bind, unbind or clear chords to change them.
action.target(len)The index of the crumb a resolved Action (Parent or Root) goes to in a trail of len, or None at the top.

Keyboard

Default shortcuts. Every one can be changed or removed with a keymap; see Keyboard shortcuts.

KeysAction
Alt+ArrowUpParent Goes up one level, to the crumb before the current one.
Alt+Shift+ArrowUpRoot Goes to the first crumb.
Esc