简体   繁体   中英

Separate the title from the tabPanels in navbarPage

Is it possible to put all tabPanel s in a row below the title of a navbarPage ? In other words, I would like to keep the appearance of the navbarPage but on two rows: the title on the first one, and the tabPanel s on the second. This would allow to "isolate" the title by keeping it on a single row.

library(shiny)

ui <- navbarPage(
  title = "some title",
  tabPanel("first tab"),
  tabPanel("second tab")
)

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

shinyApp(ui, server)

Note that this doesn't have to be a navbarPage . Any UI that could do that is accepted but it has to have the appearance of a navbarPage (no space between the rows, etc.). Hope this is clear enough.

Also asked on RStudio Community

You can force the title to have 100% width via CSS, thereby moving the tabPanel s below it:

library(shiny)

ui <- navbarPage(
  title = "some title",
  tabPanel("first tab"),
  tabPanel("second tab"),
  tags$style(HTML(".navbar-header { width:100% }
                   .navbar-brand { width: 100%; text-align: center }")) # center text
)

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

shinyApp(ui, server)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM