Documentation
¶
Overview ¶
Package list renders a vertical list of items with a single selected cursor. It's the navigation primitive most agent UIs reach for after tabs: a sidebar of conversations, a queue of jobs, a result set, a settings index.
A list owns the cursor and the visible window; it does not own the items' detail view. The parent reads Selected() and renders the detail panel itself.
Index ¶
- type Item
- type List
- func (l List) Cursor() int
- func (l List) Selected() (Item, int, bool)
- func (l List) Update(msg tea.Msg) (List, tea.Cmd)
- func (l List) View() string
- func (l List) WithCursor(glyph string) List
- func (l List) WithHeight(h int) List
- func (l List) WithItems(items []Item) List
- func (l List) WithWidth(w int) List
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item struct {
// Label is the visible text.
Label string
// Hint is optional secondary text rendered after the label in a muted color.
Hint string
// Disabled rows render dimmed and can't be selected.
Disabled bool
// Value is opaque payload the parent can pull off Selected().
Value any
}
Item is one row in the list.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a vertical selectable list.
func (List) Selected ¶
Selected returns the currently highlighted item along with its index. The bool is false on an empty list.
func (List) Update ¶
Update handles cursor movement keys. Up/down arrows and j/k step by one; Home/g goes to the first enabled item, End/G to the last.
func (List) View ¶
View renders the list, including only the window of items visible at this scroll offset.
func (List) WithCursor ¶
WithCursor sets the cursor glyph. Default is ›.
func (List) WithHeight ¶
WithHeight sets the maximum visible rows. The list scrolls internally when items exceed the height. Minimum 1.
