background color in data table

Hi!! I'm trying to make my DT background more transparent. I've my colours in hexadecimal, for example "@FF8700". I've read that in R we can set the alpha value for opacity with two more digits, for example : "@FF870099". If I try this with barplot, it works:


But when I try it with DT it doesn't work

rownames= FALSE,
options = list(paging=FALSE, dom = 'tip',
columnDefs = list(list(visible=FALSE, targets=2))))%>%formatStyle(
target = "row",
backgroundColor =styleEqual(c("bas","esp","atr","opc"),c("#FF870099","#FF9C00","#FFB200","#FFC700"))

1 Like

DT is an R interface to the DataTables javascript library, so for more advanced styling the DT documentation directs you to the DataTables API (the table is ultimately rendered in HTML and CSS).

That said, it's hard to reproduce what you're describing right now. Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.


If you've never heard of a reprex before, you might want to start by reading the help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "")

For pointers specific to the community site, check out the reprex FAQ, linked to below.


I've noticed that opening with the R-studio browser the color doesn't appears, but opening it whit a browser i.e. chrome the colors are well showed.

1 Like

I wonder if translucency support in the Viewer pane might be improved with the RStudio 1.2 Preview? It's got a new Chromium-based rendering engine, so CSS rendering would hopefully be closer to Chrome's.

1 Like