← All 41 libraries

SugarCrumbs

SugarCrumbs

Navigation breadcrumbs for terminal UIs

port of KevM/bubbleo navigationbreadcrumbrouting

SugarCrumbs code coverage

Push / pop navigation items to build breadcrumbs. Track a stack of visited locations — useful for file explorers, menu trees, and shell history.

Install

composer require sugarcraft/sugar-crumbs

Quickstart

use SugarCraft\Crumbs\NavStack;

// NavStack is a mutable stack: push() returns the same stack for chaining.
$nav = NavStack::new()
    ->push('Home', '/')                    // title, then any payload
    ->push('Settings', '/settings')
    ->push('Display', '/settings/display');

echo $nav->view();          // Home > Settings > Display
echo $nav->view(' / ');     // Home / Settings / Display

$top = $nav->pop();         // NavigationItem: title 'Display', data '/settings/display'
$nav->depth();              // 2

What's in the box

NavStackPush / pop navigation stack (mutable, chainable push) with depth, parent and truncation helpers.
Shell integrationDetect directory changes and auto-push.
FilterType-ahead filtering within the breadcrumb bar.

Source & demos

Try the quickstart →

API

ClassMethodDescription
NavStacknew()Create navigation stack
NavStackpush(string $title, mixed $data = null): selfPush a navigation item (mutates; returns the stack)
NavStackpop(): ?NavigationItem / popTo(int) / current() / parent() / depth()Pop and inspect the stack
NavStackview(string $separator = ' > ') / viewHtml()Render breadcrumbs
NavStackfilter(query)Filter breadcrumbs
NavigationItem__construct(string $title, mixed $data = null) / title()One stack entry
BreadcrumbwithZoneManager(?Manager)Attach Manager for mouse-click zone tracking (candy-zone integration)
BreadcrumbsetSeparator(string)Set separator between crumbs
BreadcrumbsetMaxWidth(int)Truncate if total width exceeds limit
Breadcrumbrender(NavStack)Render NavStack as breadcrumb string

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

Push / pop / back

Push / pop / back

NavStack push / pop / back through nested screens.
Basic crumb trail

Basic crumb trail

Render a `/Home > Settings > Account` crumb trail.