Search code examples
cssrshinyshinydashboard

Rshiny: Reduce bottom padding shiny dashboard box


Attached is shiny::selectInput within a shinydashboard::box, the following is the code in Rshiny:

box(selectInput(inputId = "test", label = "Normalization", choices = 'RSEM: FPKM'), width = 3, background = 'navy') 

How do I change the box padding such that the bottom navy blue portion is reduced?

enter image description here

I tried increasing it using the css:

.box {
  padding-bottom: 50%;
}

and it increase the bottom to this:

enter image description here

But when I try to decrease it, it doesn't change a bit:

.box {
  padding-bottom: 1%;
}

Solution

  • The form-group and selectize-control both have bottom margins that you can remove. If you want to completely get rid of the box padding, you can also remove the bottom padding of the box-body.

    Here's an example:

    library(shiny)
    library(shinydashboard)
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody( tags$head(tags$style(HTML('
          .form-group, .selectize-control {
               margin-bottom: 0px;
          }
          .box-body {
              padding-bottom: 0px;
          }'))),
          box(selectInput(inputId = "test", label = "Normalization", choices = 'RSEM: FPKM'), width = 3, background = 'navy') )
    )
    
    server <- shinyServer(function(input, output) {
    })
    
    shinyApp(ui,server)