是否可以在dashboardHeader
旁边的水平栏中放置一些项目?我知道您可以像this example一样将notificationItem
放在最右边。但我想使用与dashboardSidebar
中相同的选项,例如添加过滤器等。我想在顶部使用这样的过滤器:
答案 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)
答案 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)