Tim*_*cht 9 r filter shiny shinydashboard
是否可以在旁边的水平栏中放置一些物品dashboardHeader?我知道你可以notificationItem像这个例子一样放在最右边.但我想使用与dashboardSidebar添加过滤器等相同的选项.我想在顶部使用这样的过滤器:

嗨您可以这样做:
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)
Run Code Online (Sandbox Code Playgroud)
根据 Pork Chop 的答案,您可以简单地使用selectInput(或其他闪亮的输入)放入divwith中float:left以水平跨越:
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)
Run Code Online (Sandbox Code Playgroud)