How to change color of the focused list item (title and description)? #111
-
Hi, Can you tell me, how I can change the color of a list item (title and description) that is currently in focus? Can you please give me a hint? 😉 |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Funny enough I just came here too see if I’m missing something/ someone else has asked this. First issue up top it is 😆 Within the styles which can be set on a list I cannot see one that applies to the list items… |
Beta Was this translation helpful? Give feedback.
-
Hi! Rendering (and behavior) for If you just want to alter the default style you could do something like: import "github.com/charmbracelet/bubbles/list"
// Create a new default delegate
d := list.NewDefaultDelegate()
// Change colors
c := lipgloss.Color("#6f03fc")
d.Styles.SelectedTitle = d.Styles.SelectedTitle.Foreground(c).BorderLeftForeground(c)
d.Styles.SelectedDesc = d.Styles.SelectedTitle.Copy() // reuse the title style here
// Initailize the list model with our delegate
width, height := 80, 40
l := list.New(listItems, d, width, height)
// You can also change the delegate on the fly
l.SetDelegate(d) This code would replace this line in the For full control over the way list items are rendered you can also define your own |
Beta Was this translation helpful? Give feedback.
-
Ahh alright, thank you! Cheers! |
Beta Was this translation helpful? Give feedback.
-
OMG! Well, of course this is not done in the Thanks, @meowgorithm |
Beta Was this translation helpful? Give feedback.
Hi! Rendering (and behavior) for
list
items is done via theItemDelegate
interface. It can be a little confusing at first, but it allows the list to be very flexible and powerful.If you just want to alter the default style you could do something like: