breadcrumb

package
v0.33.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2026 License: MIT Imports: 3 Imported by: 0

README

Breadcrumb

A path-style trail with custom separators, optional icons, and middle-collapse for long paths.

breadcrumb preview

Install

glyph add breadcrumb

This copies breadcrumb.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no breadcrumb library to keep in sync.

Hello, world

package main

import (
	"fmt"

	"github.com/truffle-dev/glyph/components/breadcrumb"
)

func main() {
	fmt.Println(breadcrumb.RenderPath("project/src/cmd/main.go", breadcrumb.Options{}))
	fmt.Println(breadcrumb.Render([]breadcrumb.Crumb{
		{Icon: "📁", Label: "project"},
		{Icon: "📄", Label: "main.go"},
	}, breadcrumb.Options{}))
}

API surface

Package: breadcrumb

Types

  • Crumb
  • Options
  • Style

Constants

  • DefaultSeparator

Functions

  • Render
  • RenderPath

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/bubbletea@v1.3.10
  • github.com/charmbracelet/lipgloss@v1.1.0

Notes

Stateless render. Build a []breadcrumb.Crumb or call RenderPath with a slash-joined string. The last crumb renders bold as the current location; intermediate crumbs render muted. Set Options.MaxItems to cap a long trail — the middle collapses into while the root and the last few crumbs remain visible.

Typical placement is the top of a navigator pane or a content surface that needs to advertise the location: project › src › cmd › main.go.

See also

License

MIT, same as the rest of glyph.

Documentation

Overview

Package breadcrumb renders a path-style breadcrumb trail.

The package is stateless: callers build a slice of Crumbs, call Render, and place the result inside their own View(). Long trails collapse with an ellipsis crumb that hides the middle of the path while keeping the root and the last few segments visible.

Typical use is the top of a navigator pane: project / src / cmd / main.go with the trailing crumb tinted as the current location.

Index

Constants

View Source
const DefaultSeparator = " › "

DefaultSeparator is the glyph between crumbs.

Variables

This section is empty.

Functions

func Render

func Render(crumbs []Crumb, opts Options) string

Render produces the breadcrumb line. Empty input returns "".

func RenderPath

func RenderPath(path string, opts Options) string

RenderPath splits "a/b/c" on slashes and renders the resulting crumbs. Handy when the source data is already a slash-joined path.

Types

type Crumb

type Crumb struct {
	Label string
	// Icon is rendered before the label; optional.
	Icon string
}

Crumb is one segment in the trail.

type Options

type Options struct {
	Separator string
	// MaxItems caps the number of crumbs rendered. When the trail is
	// longer, the first crumb (root) and the last MaxItems-2 are kept
	// and the middle collapses into a "…" crumb. Zero means no cap.
	MaxItems int
	Style    Style
}

Options control rendering behavior.

type Style

type Style struct {
	Foreground       lipgloss.Color
	ForegroundActive lipgloss.Color
	Separator        lipgloss.Color
	Background       lipgloss.Color
}

Style overrides the per-crumb colors. Zero values fall back to the theme palette.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL