I want to change the colour of rows in a DT when they are selected in my app, from the default blue. I've used this answer and it works, but for some reason it shows the text of the style tag in the app.
I've tried changing to fluidPage()
instead of navbarPage()
and that gets rid of the issue - but I want to use navbarPage for my navigation tabs!
I assume I'm doing something stupid - any ideas?
EXAMPLE CODE:
library(shiny)
library(DT)
library(data.table)
example_data <- data.table(words = c("on", "scone", "wrong", "stone"),
description = c("The word on", "Scone is not on", "Not on either", "Not here at all"))
ui = shinyUI(navbarPage(tags$style(HTML('table.dataTable tr.selected td, table.dataTable td.selected {background-color: cornsilk !important;}')),
title = "Random example",
fluidRow(
dataTableOutput("word_searched")
)
)
)
server = shinyServer(function(input, output, session) {
output$word_searched <- renderDataTable({
datatable(example_data)
})
})
shinyApp(ui = ui, server = server)