Shinydashboard'topbar'

时间:2016-11-03 07:59:09

标签: r filter shiny shinydashboard

是否可以在dashboardHeader旁边的水平栏中放置一些项目?我知道您可以像this example一样将notificationItem放在最右边。但我想使用与dashboardSidebar中相同的选项,例如添加过滤器等。我想在顶部使用这样的过滤器: enter image description here

2 个答案:

答案 0 :(得分:5)

你可以这样做:

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

答案 1 :(得分:4)

根据Pork Chop的回答,您可以简单地使用放在selectInput div float:left的{​​{1}}(或其他闪亮输入)来横向跨越:

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)