Reputation: 11793
I want to put my data table in a box in my shiny dashboard. I set my box background color as green. However, I found my data table content does not display in the box. Does anyone know how to fix this issue? thanks.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "example"),
dashboardSidebar(),
dashboardBody(
box(width=6, background = 'green',
DT::dataTableOutput('table')
)
)
)
server <- function(input, output, session) {
output$table <- DT::renderDataTable({
DT::datatable(iris)
})
}
shinyApp(ui, server)
Upvotes: 1
Views: 1191
Reputation: 6956
It is just a matter of your font color:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "example"),
dashboardSidebar(),
dashboardBody(
box(width=6, background = 'green',
DT::dataTableOutput('table')
)
)
)
server <- function(input, output, session) {
output$table <- DT::renderDataTable({
df <- iris
DT::datatable(df) %>%
# rowid is a column as well, therefore zero to nrow()
DT::formatStyle(0:nrow(df), color = "black")
})
}
shinyApp(ui, server)
Upvotes: 2