I am currently building a shiny dashboard with the skin "midnight" from shinydashboardPlus. In this app, I would like to show the data table. However, the default settings of the datatable do not seem to work with a dark background.
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(DT)
data('mtcars')
# User Interface
ui <- dashboardPage(skin = "midnight",
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(background = 'gray', DT::dataTableOutput('items_dt'))
)
)
server <- function(input, output, session) {
output$items_dt = DT::renderDataTable(
mtcars,
filter = 'bottom',
options = list(scrollX = TRUE)
)
}
shinyApp(ui, server)
Furthermore, I have the issue that the original data has rather long entries for some string variables. Is there a way to scale down the size of the table?
I tried to fix both issues with formatStyle. Unfortunately, I could not resolve the issues. Below is an example for trying to set the background color to white.
output$items_dt = DT::renderDataTable({
DT::datatable(
mtcars,
filter = 'bottom',
options = list(scrollX = TRUE)
) %>% formatStyle(items_dt, target = 'row', backgroundColor = 'white')
}, server = FALSE)
Does anyone have experiences with including datatables in an shiny app using the "midnight" skin?
Thank you very much in advance!