Shinydashboard 'topbar'

给你一囗甜甜゛ 提交于 2019-12-09 15:50:14

问题


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:


回答1:


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)



回答2:


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)



来源:https://stackoverflow.com/questions/40396410/shinydashboard-topbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!