Tim_Utrecht Tim_Utrecht - 27 days ago 6
R Question

Shinydashboard 'topbar'

Is it possible to place some items in the horizontal bar next to the

dashboardHeader
? I know you can place
notificationItem
on the far right like in this example. But I would like to use the same options as in
dashboardSidebar
like adding filters etc. I want such a filter on top:
enter image description here

Answer

Based on Pork Chop answer, you can simply use selectInput (or other shiny inputs) that you put in a div with float:left to span horizontally:

CustomHeader <- dashboardHeader()
CustomHeader$children[[3]]$children <- list(
  div(style="float:left;height:50px",selectInput("select1", NULL, c("a","b","c"))),
  div(style="float:left;height:50px",selectInput("select2", NULL, c("d","e","f"))))

ui <- dashboardPage(
  CustomHeader,
  dashboardSidebar(),
  dashboardBody(textOutput("text1"),textOutput("text2"))
)

server <- function(input, output, session) {
  output$text1 <- renderText({input$select1})
  output$text2 <- renderText({input$select2})
}

shinyApp(ui, server)
Comments