widgets

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderBadge

func RenderBadge(count int32, style lipgloss.Style) string

RenderBadge renders an unread count badge.

func RenderOnlineDot

func RenderOnlineDot(online bool, style lipgloss.Style) string

RenderOnlineDot renders a small online status indicator.

func RenderQRCode

func RenderQRCode(content string, size int) string

RenderQRCode generates an ASCII QR code using Unicode block characters. Uses U+2580 (upper half block) and U+2584 (lower half block) to pack two rows of QR modules into one terminal row.

Types

type List

type List struct {
	Items   []ListItem
	Cursor  int
	Offset  int
	Width   int
	Height  int
	Focused bool

	StyleNormal lipgloss.Style
	StyleActive lipgloss.Style
	StyleTitle  lipgloss.Style
	StyleSub    lipgloss.Style
	StyleMeta   lipgloss.Style
	StyleBadge  lipgloss.Style
	StyleOnline lipgloss.Style
	// contains filtered or unexported fields
}

List is a generic scrollable list widget with vim-style navigation.

func NewList

func NewList() List

NewList creates a new list widget.

func (*List) ItemAtRow

func (l *List) ItemAtRow(row int) int

ItemAtRow returns the index of the item displayed at the given local row (0-based, relative to the top of the list's visible area), or -1.

func (*List) ScrollBy

func (l *List) ScrollBy(n int)

ScrollBy moves the cursor by n items (negative scrolls up).

func (*List) SelectIndex

func (l *List) SelectIndex(i int) bool

SelectIndex moves the cursor to the given item index. Returns false if the index is out of bounds.

func (*List) SelectedID

func (l *List) SelectedID() string

SelectedID returns the ID of the currently selected item.

func (*List) SelectedItem

func (l *List) SelectedItem() *ListItem

SelectedItem returns the currently selected item, or nil.

func (*List) SetItems

func (l *List) SetItems(items []ListItem)

SetItems replaces all items, keeping cursor in bounds.

func (*List) Update

func (l *List) Update(msg tea.Msg) (selected bool)

Update handles key events for navigation.

func (*List) View

func (l *List) View() string

View renders the list.

type ListItem

type ListItem struct {
	ID       string
	Title    string
	Subtitle string
	Badge    string
	Meta     string
	Online   bool
	Avatar   string // 2-line rendered avatar (half-block image or initials)
}

ListItem represents a single item in a scrollable list.

type ProgressBar

type ProgressBar struct {
	Progress float64 // 0.0 to 1.0
	Width    int
	Label    string

	StyleBar  lipgloss.Style
	StyleFill lipgloss.Style
}

ProgressBar renders a download/upload progress bar.

func NewProgressBar

func NewProgressBar(width int) ProgressBar

NewProgressBar creates a new progress bar.

func (*ProgressBar) View

func (p *ProgressBar) View() string

View renders the progress bar.

type Spinner

type Spinner struct {
	Frame  int
	Label  string
	Style  lipgloss.Style
	Active bool
}

Spinner is a loading spinner widget.

func NewSpinner

func NewSpinner(label string) Spinner

NewSpinner creates a new spinner.

func (Spinner) Tick

func (s Spinner) Tick() tea.Cmd

Tick returns a command that triggers the next spinner frame.

func (*Spinner) Update

func (s *Spinner) Update(msg tea.Msg) tea.Cmd

Update advances the spinner frame.

func (*Spinner) View

func (s *Spinner) View() string

View renders the spinner.

type SpinnerTickMsg

type SpinnerTickMsg struct{}

SpinnerTickMsg triggers the next spinner frame.

type Tabs

type Tabs struct {
	Labels []string
	Active int
	Width  int

	StyleTab       lipgloss.Style
	StyleTabActive lipgloss.Style
}

Tabs is a tab bar widget for switching between views.

func NewTabs

func NewTabs(labels []string) Tabs

NewTabs creates a new tab bar.

func (*Tabs) Update

func (t *Tabs) Update(msg tea.Msg) bool

Update handles tab switching via left/right keys or number keys.

func (*Tabs) View

func (t *Tabs) View() string

View renders the tab bar.

type TextArea

type TextArea struct {
	Value       string
	Cursor      int
	Width       int
	Height      int
	Focused     bool
	Placeholder string
	Style       lipgloss.Style
}

func NewTextArea

func NewTextArea() TextArea

func (*TextArea) Reset

func (t *TextArea) Reset()

func (*TextArea) Update

func (t *TextArea) Update(msg tea.Msg) (submitted bool)

func (*TextArea) View

func (t *TextArea) View() string

Jump to

Keyboard shortcuts

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