Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Title option for lists #338

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
// List represents a list of items that can be displayed. Lists can contain
// lists as items, they will be rendered as nested (sub)lists.
//
// In fact, lists can contain anything as items, like lipgloss.Table or lipgloss.Tree.
// In fact, lists can contain anything as items, like lipgloss.Table.
type List struct{ tree *tree.Tree }

// New returns a new list with the given items.
Expand Down Expand Up @@ -80,6 +80,13 @@ type Items tree.Children
// })
type StyleFunc func(items Items, index int) lipgloss.Style

// Root sets the title of the list. For the best results, use this for the
// outermost list.
func (l *List) Root(title string) *List {
l.tree.Root(title)
return l
}

// Hidden returns whether this list is hidden.
func (l *List) Hidden() bool {
return l.tree.Hidden()
Expand Down
Loading