@@ -849,6 +849,59 @@ func TestStyleFuncAppliesAfterBaseStyleAndColStylesAndBeforeRowStyle(t *testing.
849849 assert .Equal (t , expectedTable , rendered )
850850}
851851
852+ func TestStyleFuncAppliesHighlighted (t * testing.T ) {
853+ styleFunc := func (input RowStyleFuncInput ) lipgloss.Style {
854+ if input .IsHighlighted {
855+ return lipgloss .NewStyle ().Align (lipgloss .Center )
856+ }
857+
858+ if input .Index % 2 == 0 {
859+ return lipgloss .NewStyle ().Align (lipgloss .Right )
860+ }
861+
862+ return lipgloss .NewStyle ().Align (lipgloss .Left )
863+ }
864+
865+ model := New ([]Column {
866+ NewColumn ("1" , "1" , 6 ),
867+ NewColumn ("2" , "2" , 6 ),
868+ NewColumn ("3" , "3" , 6 ),
869+ }).
870+ WithRowStyleFunc (styleFunc ).
871+ Focused (true )
872+
873+ rows := []Row {}
874+
875+ for rowIndex := 1 ; rowIndex <= 5 ; rowIndex ++ {
876+ rowData := RowData {}
877+
878+ for columnIndex := 1 ; columnIndex <= 3 ; columnIndex ++ {
879+ id := fmt .Sprintf ("%d" , columnIndex )
880+
881+ rowData [id ] = fmt .Sprintf ("%d,%d" , columnIndex , rowIndex )
882+ }
883+
884+ rows = append (rows , NewRow (rowData ))
885+ }
886+
887+ model = model .WithRows (rows ).
888+ WithHighlightedRow (2 )
889+
890+ const expectedTable = `┏━━━━━━┳━━━━━━┳━━━━━━┓
891+ ┃ 1┃ 2┃ 3┃
892+ ┣━━━━━━╋━━━━━━╋━━━━━━┫
893+ ┃ 1,1┃ 2,1┃ 3,1┃
894+ ┃1,2 ┃2,2 ┃3,2 ┃
895+ ┃ 1,3 ┃ 2,3 ┃ 3,3 ┃
896+ ┃1,4 ┃2,4 ┃3,4 ┃
897+ ┃ 1,5┃ 2,5┃ 3,5┃
898+ ┗━━━━━━┻━━━━━━┻━━━━━━┛`
899+
900+ rendered := model .View ()
901+
902+ assert .Equal (t , expectedTable , rendered )
903+ }
904+
852905// This is a long test due to typing and multiple big table strings, that's okay
853906//
854907//nolint:funlen
0 commit comments