๐ tui-breadcrumb
A customizable, responsive, and interactive hierarchical navigation trail widget for Ratatui.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Home โฏ ๐ Projects โฏ ๐ฆ ratatui โพ โฏ ๐ sparkline.rs โ
โ โฒ โฒ โฒ โฒ โ
โ Root Parent Ancestor with Active โ
โ Segment Segment Dropdown Item โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Overview
Terminal user interfacesโsuch as file managers, cloud resource consoles, database browsers, and nested configuration screensโfrequently require breadcrumb navigation paths. Without a dedicated widget, developers often manually assemble Line and Span collections and write custom string truncations that break on Unicode characters or fail to support mouse interaction.
tui-breadcrumb solves this by providing:
- Built-in Separator Presets: Slash (
/), Chevron (โฏ), Angle (โบ), Arrow (โ), Pipe (|), Backslash (\\), Double Angle (ยป), or custom glyphs. - Smart Responsive Truncation: Intelligently fits breadcrumbs to any terminal column width using strategies like
Middle,Start,ShortenNames,End, orNone. - Full Interactivity (
BreadcrumbState): Keyboard focus navigation (Left/Rightarrows) and pixel-accurate mouse hit testing for segment clicks and ancestor dropdown triggers (โพ). - Filesystem Path Integration: Seamless conversions from standard
std::path::Path. - Zero Panics & Unicode Safe: Built with
unicode-widthto prevent column drift across emojis, CJK characters, and combining glyphs.
๐ฆ Installation
Add tui-breadcrumb to your Cargo.toml:
Or manually:
[]
= "0.1.0"
= "0.30"
๐ Quick Start
1. Simple Stateless Breadcrumb
use *;
use ;
2. Interactive Stateful Breadcrumb (Keyboard & Mouse Support)
use *;
use ;
use ;
๐ Truncation Strategies
When a breadcrumb trail exceeds available terminal width, [TruncateStrategy] determines how segments are condensed:
| Strategy | Output Pattern | Description |
|---|---|---|
Middle (Default) |
Home โฏ ... โฏ src โฏ sparkline.rs |
Preserves root context and active leaf; collapses intermediate segments into .... |
Start |
... โฏ tui-breadcrumb โฏ src โฏ sparkline.rs |
Preserves deepest active leaf and immediate parents; collapses leftmost ancestors. |
ShortenNames |
H โฏ P โฏ ratatui โฏ src โฏ sparkline.rs |
Progressively abbreviates ancestor segment labels to single characters before collapsing. |
End |
Home โฏ Projects โฏ ratatui โฏ ... |
Left-to-right priority; preserves root ancestors and collapses leaf segments. |
None |
Home โฏ Projects โฏ ratatui โฏ src |
Strict clipping at the boundary without ellipsis substitution. |
// Examples of configuring strategies:
let middle = middle_with;
let start = start_with;
let shorten = shorten_names_with;
๐จ Separator Presets
BreadcrumbSeparator includes built-in glyph presets with configurable spacing and styling:
| Preset Constructor | Symbol | Visual Preview (Spacing = 1) |
|---|---|---|
BreadcrumbSeparator::chevron() |
โฏ |
Home โฏ Projects โฏ ratatui |
BreadcrumbSeparator::slash() |
/ |
Home / Projects / ratatui |
BreadcrumbSeparator::angle() |
โบ |
Home โบ Projects โบ ratatui |
BreadcrumbSeparator::arrow() |
โ |
Home โ Projects โ ratatui |
BreadcrumbSeparator::pipe() |
| |
Home | Projects | ratatui |
BreadcrumbSeparator::backslash() |
\\ |
Home \\ Projects \\ ratatui |
BreadcrumbSeparator::double_angle() |
ยป |
Home ยป Projects ยป ratatui |
BreadcrumbSeparator::custom(sym) |
* |
Home * Projects * ratatui |
// Customize separator styling and spacing:
let sep = chevron
.spacing
.style;
๐ Filesystem Path Integration
Easily initialize a breadcrumb navigation trail directly from a [std::path::Path]:
use Path;
use Breadcrumb;
let path = new;
let widget = from_path;
๐ฎ Examples & Demos
The examples/ directory includes multiple practical applications showcasing different integration patterns:
| Example | Command | Description |
|---|---|---|
| Interactive Demo | cargo run --example demo |
Full-featured demo with keyboard navigation, strategy switching, and mouse clicks. |
| Minimal Quickstart | cargo run --example simple |
Minimal zero-config ~25 line getting started example. |
| File Explorer | cargo run --example file_explorer |
Two-pane directory browser with live from_path updates and click-to-jump. |
| Custom Styling Gallery | cargo run --example custom_styling |
Side-by-side gallery of Powerline pills, CI badges, Retro amber/green, and Minimal dots. |
| Dropdown Popovers | cargo run --example dropdown_menus |
Deep resource hierarchy with floating sibling branch selection modals. |
| Responsive Truncation Lab | cargo run --example responsive_resize |
Interactive width caliper and live comparator across all 5 truncation strategies. |
Example Highlights:
- Interactive Showcase (
demo.rs): Navigate crumbs withโ/โ/h/l, cycle separators withTab, toggle strategies with1โ5, and clickโพdropdown triggers. - Minimal Quickstart (
simple.rs): Minimal template for quick integration into existing projects. - Filesystem Navigation (
file_explorer.rs): Browse directories withEnter/Backspace, or click any parent breadcrumb segment to jump immediately to that directory. - Theming & Powerline Gallery (
custom_styling.rs): Inspect 4 visual themes: Powerline pill styling (๎ฐ), CI/CD status badges ([โ Build] โฏ [โก Tests]), Retro green phosphor (//), and Minimal dots (โข). - Deep Hierarchies & Dropdowns (
dropdown_menus.rs): Clickโพon any resource level to open a floating modal of alternate sibling branches. - Truncation & Width Caliper (
responsive_resize.rs): Adjust container width in real time ([/]or arrow keys) to observe and compare all 5 truncation strategies on emoji-rich paths.
๐งช Testing & Verification
tui-breadcrumb includes a comprehensive verification suite:
# Run unit tests
# Run documentation tests
# Run property-based invariant tests (QuickCheck)
# Run visual regression snapshot tests (Insta)
# Run linter and formatting checks
๐ค Contributing
Contributions are welcome! Please check out CONTRIBUTING.md for guidelines on development setup, running tests, code standards, and submitting pull requests.
๐ License
This project is dual-licensed under:
- MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
You may choose either license at your option.