From 4e3b8d35f6118bfb7ca6c9a96004e5c269a31431 Mon Sep 17 00:00:00 2001 From: bashbunni Date: Thu, 18 Jul 2024 13:51:24 -0700 Subject: [PATCH] feat: add Title option for lists --- list/list.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/list/list.go b/list/list.go index 30aa6ed8..ea7c6ba5 100644 --- a/list/list.go +++ b/list/list.go @@ -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. @@ -80,6 +80,12 @@ type Items tree.Children // }) type StyleFunc func(items Items, index int) lipgloss.Style +// Title sets the title of the list. +func (l *List) Title(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()