bubble-table icon indicating copy to clipboard operation
bubble-table copied to clipboard

Feature Request: Ability to change the highlighted row color!

Open WhipMeHarder opened this issue 10 months ago • 1 comments

Hello, It would be wonderful if we could change the table's highlighted row color. At the moment, there only seems to be one color, a very light mauve. If we could change the color with code such as:

Example One:

    highlightStyle := lipgloss.NewStyle().

    Foreground(lipgloss.Color("7")).
    Background(lipgloss.Color("2")).
    Bold(true)

    WithRowHighlightedStyle(highlightStyle)

Or, Example Two:

     tableModel: table.New(rows).
     WithRowHighlightedStyle(lipgloss.NewStyle().Foreground(lipgloss.Color("7")).Background(lipgloss.Color("2"))),
         }),
    }

Probably, there should be a,

   WithRowHighlightedStyle(), .... and a,
   WithColumnsHighlightedStyle(),

Many thanks,

WhipMeHarder avatar Feb 02 '25 16:02 WhipMeHarder

This is super old, but this is possible.

WithRowStyleFunc(rowStyleFunc).

func rowStyleFunc(input table.RowStyleFuncInput) lipgloss.Style {
	// Check if this row is highlighted.
	if input.IsHighlighted { // or input.Highlighted depending on your library version
		// Return the highlight style.
		return lipgloss.NewStyle().
			Background(lipgloss.Color(styles.White)).
			Foreground(lipgloss.Color(styles.Black))
	}
}`

flippedcracker avatar May 14 '25 20:05 flippedcracker