breadcrumb

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package breadcrumb renders a single-line breadcrumb trail like "Root › Modules › dev" for use as a TUI header bar. It is a pure view component — feed it []string and it returns a styled line.

The convention is: all crumbs except the last are "past" (drawn with the crumb style); the last is "current" (drawn with the current style, usually bold). When the rendered line exceeds width, leftmost crumbs are replaced with an ellipsis so the current crumb is always visible.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model is a breadcrumb bar. Call SetCrumbs when the navigation stack changes and SetWidth on window resize.

func New

func New(opts Options) Model

New constructs a breadcrumb bar.

func (Model) BarBackground

func (m Model) BarBackground() lipgloss.TerminalColor

BarBackground reports the bar's base background, useful if you're matching another component (e.g. a footer) to the same color.

func (Model) BarForeground

func (m Model) BarForeground() lipgloss.TerminalColor

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) SetCrumbs

func (m *Model) SetCrumbs(c []string)

func (*Model) SetWidth

func (m *Model) SetWidth(w int)

func (Model) Update

func (m Model) Update(_ tea.Msg) (Model, tea.Cmd)

func (Model) View

func (m Model) View() string

View renders the breadcrumb as a single line, padded and styled to Width.

func (Model) Width

func (m Model) Width() int

type Options

type Options struct {
	Width  int
	Crumbs []string

	// Separator is rendered between crumbs. Defaults to " › ".
	Separator string
	// Ellipsis is substituted for truncated leading crumbs. Defaults to "…".
	Ellipsis string

	// BarBackground / BarForeground set the single color pair used for the
	// whole strip; default styles derive from them so the bar reads as one
	// continuous band. Defaults: bg=236, fg=252.
	BarBackground lipgloss.TerminalColor
	BarForeground lipgloss.TerminalColor

	// Style overrides. nil = use defaults derived from BarBackground /
	// BarForeground.
	BarStyle       *lipgloss.Style // outer padding + bg
	CrumbStyle     *lipgloss.Style // past crumbs
	CurrentStyle   *lipgloss.Style // last crumb
	SeparatorStyle *lipgloss.Style // between-crumb separator
}

Options configures a breadcrumb bar. Style fields are pointers; pass nil to accept the default.

Jump to

Keyboard shortcuts

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