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 ¶
- type Model
- func (m Model) BarBackground() lipgloss.TerminalColor
- func (m Model) BarForeground() lipgloss.TerminalColor
- func (m Model) CrumbAt(x, y int) (int, bool)
- func (m Model) Init() tea.Cmd
- func (m Model) Rect() geom.Rect
- func (m *Model) SetCrumbs(c []string)
- func (m *Model) SetRect(r geom.Rect)
- func (m Model) Update(_ tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m Model) Width() int
- type Options
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 (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) CrumbAt ¶ added in v0.18.0
CrumbAt maps a position to an index into the crumbs the breadcrumb was last given, accounting for the bar's padding and for any leading crumbs elided behind the ellipsis. Reports ok=false for the separators, the ellipsis itself, the trailing empty stretch, and any position outside the bar — clicking dead space should do nothing rather than navigate.
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.