R Shiny: How to change background color of a table

后端 未结 1 1593
失恋的感觉
失恋的感觉 2021-02-04 05:27

I found how to change the background color of the User Interface in Shiny. The withdraw I found is that it also colors the background of the tables i\'m showing with table

相关标签:
1条回答
  • 2021-02-04 05:49

    A solution has been given on the shiny google group:

    runApp(
      list(ui = bootstrapPage(pageWithSidebar(
        headerPanel("Rummy"),
        sidebarPanel( tags$hr() ),
    
        mainPanel(
    
          tableOutput("dummy"),
          # change style:    
          tags$head(tags$style("#dummy table {background-color: red; }", media="screen", type="text/css"))
        )
    
      )
      )
    
      ,
      server = function(input, output) {
        output$dummy <- renderTable({ data.frame(A=1:4,B=2:5,C=rep("aaa",4)) }) 
      }
    
      )
    )
    

    I also invite you to read this discussion on the shiny google group, which shows how to use the pander package to generate html tables and insert them in a shiny app. This allows a more flexible control of the style.

    0 讨论(0)
提交回复
热议问题