carousel

package
v0.10.13 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package carousel renders a horizontal strip of labels with one active, and wraps navigation around the ends. It drives both the top-level section tabs and the per-issue detail sub-tabs, so the same selection behavior is shared.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {

	// Separator sits between items (default two spaces).
	Separator string
	// ActiveStyle / InactiveStyle style the labels. Zero values render plainly.
	ActiveStyle   lipgloss.Style
	InactiveStyle lipgloss.Style
	// contains filtered or unexported fields
}

Model is a wrapping tab strip.

func New

func New(items ...string) *Model

New returns a carousel over the given items with the first active. It returns a pointer because every mutating method has a pointer receiver.

func (*Model) Active

func (m *Model) Active() int

Active returns the active index, or -1 when empty.

func (*Model) ActiveItem

func (m *Model) ActiveItem() string

ActiveItem returns the active label, or "" when empty.

func (*Model) Items

func (m *Model) Items() []string

Items returns a copy of the current labels so external mutation cannot bypass SetItems and corrupt the active index.

func (*Model) Next

func (m *Model) Next()

Next moves to the following item, wrapping to the first after the last.

func (*Model) Prev

func (m *Model) Prev()

Prev moves to the previous item, wrapping to the last before the first.

func (*Model) SetActive

func (m *Model) SetActive(i int)

SetActive selects index i, clamping into range.

func (*Model) SetItems

func (m *Model) SetItems(items []string)

SetItems replaces the items, clamping the active index into range.

func (*Model) View

func (m *Model) View() string

View renders the strip with the active label emphasized.

Jump to

Keyboard shortcuts

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