Change table background color for selected rows

Is it possible change the background color of the selected rows in the table?

Yes, you can do this with custom css @ckissi! Add this to a text component and toggle on the option for "render as HTML":

  ._retool-table1 .table-widget .table-row.selected {
    background-color: rgba(25,25,255,.1);

More info on this post too: How to write custom CSS in Retool!

For this to work, there needs to be an * between .table-row.selected and {:

Note that it seems to work better using a solid RGB color (just choose a light shade) rather than relying on transparency via RGBA.


1 Like

Thanks for the update here @gsanders! :sparkles:

This does not work:

  ._retool-table1 .table-widget .table-row.selected * {
    background-color: rgba(25,25,255,.1);

I have been using this which mostly works:

    .table-widget .table-row.selected, .table-widget .table-row:hover * {
        background-color: deepskyblue !important;

However it does not change the color of any frozen columns:

Can't seem to find the right CSS to fix it.

Hey @bradlymathews!

Great question! I was able to change the color of the selected row by using the following in each rows Background color settings:

{{i==table.selectedRow.index? "green": "white"}}

This will check the rows index "i" vs the tables selected row, any matches will be changed to green.

Screen Recording 2021-07-23 at 4.16.16

Hope this helps, let me know if you have any questions! :slight_smile:


I assume you mean column background color- I don't know of and can't find anything for row. am not aware of any row setting for this, where is it? I am familiar with this technique, but changing the CSS was far easier.

I also use multi-select tables a lot and I think I would need a transformer to hold the proper logic, making CSS even more advantageous.


Sorry for the confusion here, this would be added to each columns "background-color" input here:

To get this to work for a table with "Allow selecting multiple rows" toggled on you can change this code to something like:
{{table2.selectedRow.index.includes(i) ? "green": "white"}}

Screen Recording 2021-07-23 at 5.30.37

Do you think this could work for your use case here?

1 Like

Tested it and that does fix the problem with frozen columns. But with more code to run it is a lot slower than the CSS route. If I click a row, it is the new CSS background color instantly. The column I set up to calculate the background color lags behind about 300ms which is very noticeable. Nice thing is it does not get any slower when adding more columns to the calculated background.

Also, custom columns do not have a background color option and are also subject to the same issue with frozen columns.

No CSS workaround here?


No worries, it looks like the following custom CSS

.table-row.selected div{
  background: honeydew !important;

works. Ideally this would be a style feature of the table so I will write up a quick feature request and add this thread to it so we can update this thread once this is added! :slight_smile:

Any updates on changing row backgrounds as an official thing? I don't think the approaches on this thread work with the current components any longer.

FYI, if you want to change the background color for a multi-select table

{{table1.selectedRow.index.includes(i)? "green": "white"}}