CLARA RC
CLARA RC

Reputation: 71

DT in R - How to set caption color?

Is it possible to set color in the caption of a DT table in an html document?

I've tried with

datatable(table, caption = paste0('<span style="color:#FF8700">Title one<span style="color:#000000">'), rownames=FALSE)

but without results.

any idea?

Upvotes: 7

Views: 3616

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84599

You can do in this way:

datatable(head(iris), 
          caption = htmltools::tags$caption("hello", style="color:red"),
          rownames=FALSE)

If you want to mix several styles:

datatable(head(iris), 
          caption = htmltools::tags$caption(htmltools::tags$span("hello", style="color:red;"), htmltools::tags$span("how are you", style="color:blue;")),
          rownames=FALSE)

enter image description here

Upvotes: 9

Related Questions