breadcrumbs

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package breadcrumbs provides breadcrumb navigation components for the LiveTemplate framework.

Breadcrumbs display the current page location within a navigational hierarchy.

Available Templates

  • lvt:breadcrumbs:default:v1 - Standard breadcrumb navigation

Basic Usage

bc := breadcrumbs.New("nav",
    breadcrumbs.WithItems(
        breadcrumbs.NewItem("home", breadcrumbs.WithItemLabel("Home"), breadcrumbs.WithItemHref("/")),
        breadcrumbs.NewItem("products", breadcrumbs.WithItemLabel("Products"), breadcrumbs.WithItemHref("/products")),
        breadcrumbs.NewItem("current", breadcrumbs.WithItemLabel("Laptop"), breadcrumbs.WithItemCurrent(true)),
    ),
)

{{template "lvt:breadcrumbs:default:v1" .Breadcrumbs}}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Templates

func Templates() *base.TemplateSet

Templates returns the breadcrumbs template set.

Types

type BreadcrumbItem struct {
	base.Base

	// Label is the display text.
	Label string

	// Href is the link URL.
	Href string

	// Icon is an optional icon before the label.
	Icon string

	// Current marks this as the current page.
	Current bool

	// Disabled prevents interaction.
	Disabled bool
}

BreadcrumbItem represents a single breadcrumb item.

func NewItem

func NewItem(id string, opts ...ItemOption) *BreadcrumbItem

NewItem creates a new BreadcrumbItem with the given ID and options.

func (i *BreadcrumbItem) HasHref() bool

HasHref returns true if href is set.

func (i *BreadcrumbItem) HasIcon() bool

HasIcon returns true if icon is set.

func (i *BreadcrumbItem) HasLabel() bool

HasLabel returns true if label is set.

func (i *BreadcrumbItem) IsClickable() bool

IsClickable returns true if item can be clicked.

func (i *BreadcrumbItem) LinkClass() string

LinkClass returns CSS class for link state.

Styles returns the resolved BreadcrumbItemStyles for this item.

type Breadcrumbs struct {
	base.Base

	// Items in the breadcrumb trail.
	Items []*BreadcrumbItem

	// Separator between items.
	Separator Separator

	// Size of the breadcrumb text.
	Size Size

	// ShowHome displays a home icon as the first item.
	ShowHome bool

	// HomeHref is the URL for the home link.
	HomeHref string

	// Collapsible enables collapsing middle items.
	Collapsible bool

	// MaxVisible is the max items to show when collapsed.
	MaxVisible int
}

Breadcrumbs represents a breadcrumb navigation component.

func New

func New(id string, opts ...Option) *Breadcrumbs

New creates a new Breadcrumbs with the given ID and options.

func (bc *Breadcrumbs) AddItem(item *BreadcrumbItem)

AddItem adds an item to the breadcrumbs.

func (bc *Breadcrumbs) HasItems() bool

HasItems returns true if there are items.

func (bc *Breadcrumbs) HiddenCount() int

HiddenCount returns the number of hidden items.

func (bc *Breadcrumbs) IsChevronSeparator() bool

IsChevronSeparator returns true if using chevron separator.

func (bc *Breadcrumbs) IsCollapsed() bool

IsCollapsed returns true if items should be collapsed.

func (bc *Breadcrumbs) ItemCount() int

ItemCount returns the number of items.

func (bc *Breadcrumbs) LastItem() *BreadcrumbItem

LastItem returns the last item or nil.

func (bc *Breadcrumbs) SeparatorSymbol() string

SeparatorSymbol returns the separator character/symbol.

func (bc *Breadcrumbs) SizeClass() string

SizeClass returns CSS class for size.

func (bc *Breadcrumbs) Styles() styles.BreadcrumbsStyles

Styles returns the resolved BreadcrumbsStyles for this component.

func (bc *Breadcrumbs) VisibleItems() []*BreadcrumbItem

VisibleItems returns the items to display when collapsed.

type ItemOption

type ItemOption func(*BreadcrumbItem)

ItemOption configures a BreadcrumbItem.

func WithItemCurrent

func WithItemCurrent(current bool) ItemOption

WithItemCurrent marks the item as current.

func WithItemDisabled

func WithItemDisabled(disabled bool) ItemOption

WithItemDisabled disables the item.

func WithItemHref

func WithItemHref(href string) ItemOption

WithItemHref sets the item href.

func WithItemIcon

func WithItemIcon(icon string) ItemOption

WithItemIcon sets the item icon.

func WithItemLabel

func WithItemLabel(label string) ItemOption

WithItemLabel sets the item label.

func WithItemStyled

func WithItemStyled(styled bool) ItemOption

WithItemStyled sets the item styled mode.

type Option

type Option func(*Breadcrumbs)

Option configures a Breadcrumbs.

func WithCollapsible

func WithCollapsible(collapsible bool) Option

WithCollapsible enables collapsing.

func WithHomeHref

func WithHomeHref(href string) Option

WithHomeHref sets the home link URL.

func WithItems

func WithItems(items ...*BreadcrumbItem) Option

WithItems sets the breadcrumb items.

func WithMaxVisible

func WithMaxVisible(max int) Option

WithMaxVisible sets max visible items when collapsed.

func WithSeparator

func WithSeparator(s Separator) Option

WithSeparator sets the separator style.

func WithShowHome

func WithShowHome(show bool) Option

WithShowHome enables the home icon.

func WithSize

func WithSize(s Size) Option

WithSize sets the text size.

func WithStyled

func WithStyled(styled bool) Option

WithStyled sets the styled mode.

type Separator

type Separator string

Separator defines the visual separator between items.

const (
	// SeparatorSlash uses "/" as separator.
	SeparatorSlash Separator = "slash"
	// SeparatorChevron uses ">" as separator.
	SeparatorChevron Separator = "chevron"
	// SeparatorArrow uses "→" as separator.
	SeparatorArrow Separator = "arrow"
	// SeparatorDot uses "•" as separator.
	SeparatorDot Separator = "dot"
)

type Size

type Size string

Size defines breadcrumb text size.

const (
	SizeSm Size = "sm"
	SizeMd Size = "md"
	SizeLg Size = "lg"
)

Jump to

Keyboard shortcuts

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