Search code examples
cssrshinyshinydashboard

How to apply border to a box() in R shiny?


I am trying to assign border to a box() in shinyApp. I have two boxes in shinyApp. I want to assign border to 1st box() only. How to do it? Here is my code:

library(shiny)
library(shinydashboard)

ui <- shinyUI(dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    tags$style(HTML( ".box {border: 5px solid #3DA0D1;}")),
  box("border", 123,background = 'navy'),
  box("line", 123,background = 'navy'))))
server <- function(input,output){

}
shinyApp(ui, server)

Any help, would be appreciable. Thank you.


Solution

  • library(shiny)
    library(shinydashboard)
    
    ui <- shinyUI(dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(
        box("border", 123, background = 'navy'),
        box("line", 123, background = 'navy'),
        tags$script(HTML("$('.box').eq(0).css('border', '5px solid #3DA0D1');"))
      )
    ))
    server <- function(input,output){}
    shinyApp(ui, server)