Skip to content

Feature Request: Ability to change the highlighted row color! #190

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

Open
WhipMeHarder opened this issue Feb 2, 2025 · 1 comment
Open

Comments

@WhipMeHarder
Copy link

WhipMeHarder commented Feb 2, 2025

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,

@flippedcracker
Copy link

flippedcracker commented May 14, 2025

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))
	}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants