2

I have a basic shiny app in which I want to be able to set the height of the Navbar menu named Navnar! I do not see any choice for setting its height.

#ui.r
library(markdown)

navbarPage("Navbar!",
           tabPanel("Plot",
                    sidebarLayout(
                      sidebarPanel(

                      ),
                      mainPanel(

                      )
                    )
           ),
           tabPanel("Summary"

           ),
           navbarMenu("More",
                      tabPanel("Table"
                      )

           )
)
#server.r
function(input, output, session) {

}
firmo23
  • 7,490
  • 2
  • 38
  • 114

1 Answers1

10

To adjust the height of the navbar menu, you have to differentiate between bootstrap versions. Probably in your shiny application bootstrap version 3.3.4 is used. Then you can use:

tags$style(HTML('.navbar-nav > li > a, .navbar-brand {
                   padding-top:4px !important; 
                   padding-bottom:0 !important;
                   height: 25px;
                 }
                 .navbar {min-height:25px !important;}'))

see Decreasing height of bootstrap 3.0 navbar.

To modify the height you can modify this CSS code adjust the numbers within height: 25px and min-height:25px.

Reproducbile example:

library(shinydashboard)
library(shiny)

ui <- navbarPage("Navbar!",
         tags$head(
           tags$style(HTML('.navbar-nav > li > a, .navbar-brand {
                            padding-top:4px !important; 
                            padding-bottom:0 !important;
                            height: 25px;
                            }
                           .navbar {min-height:25px !important;}'))
         ),
           tabPanel("Plot",
                    sidebarLayout(
                      sidebarPanel(

                      ),
                      mainPanel(

                      )
                    )
           ),
           tabPanel("Summary"

           ),
           navbarMenu("More",
                      tabPanel("Table"
                      )

           )
)

server <- function(input, output, session) {}

shinyApp(ui, server)
Tonio Liebrand
  • 17,189
  • 4
  • 39
  • 59