Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 276
Tim_Utrecht Avatar asked Nov 03 '16 07:11

Tim_Utrecht


People also ask

What is Shinydashboard?

shinydashboard: Create Dashboards with 'Shiny' Create dashboards with 'Shiny'. This package provides a theme on top of 'Shiny', making it easy to create attractive dashboards.

How do you make a box shiny in R?

A basic box can be created with the box() function, and the contents of the box can be (most) any Shiny UI content. Boxes can have titles and header bar colors with the title and status options. The different possible statuses are shown. Finally, it's also possible to have a solid background, with the background option ...


2 Answers

Hi You can do something like this:

library(shiny)
library(shinydashboard)

CustomHeader <- dashboardHeader()
CustomHeader$children[[3]]$children <-  div(style="min-width:200px;",tags$input(id="searchbox",placeholder = "  Search...",type="text",class="chooser-input-search",style="width:200px;height:50px;"))

ui <- dashboardPage(
  CustomHeader,
  dashboardSidebar(),
  dashboardBody()
)
server <- function(input, output, session) {}
shinyApp(ui, server)

enter image description here

like image 143
Pork Chop Avatar answered Nov 15 '22 13:11

Pork Chop


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)
like image 26
HubertL Avatar answered Nov 15 '22 13:11

HubertL