![](/img/trans.png)
[英]Hide totally the sidebar when pressing the toggle button in shiny dashboard
[英]Totally hide left sidebar of shiny dashboard by clicking on existing toggle button without affecting the title section
如何完全隐藏 shinydashboard() 的左侧边栏而不影响使用已经存在的切换按钮几乎隐藏标题的 header 部分?
## app.R ##
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
ui <- dashboardPage(
dashboardHeader(title = "dashboard"
),
dashboardSidebar(),
dashboardBody(
useShinyjs(),
tags$hr(),
tabsetPanel(
id ="tabA",
type = "tabs",
tabPanel("Front",icon = icon("accusoft")),
tabPanel("Data", icon = icon("table")
)
)
),
controlbar = dashboardControlbar()
)
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
只需使用shinydashboardPlus::dashboardSidebar()
的minified
参数:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
ui <- dashboardPage(
dashboardHeader(title = "dashboard"),
dashboardSidebar(minified = FALSE),
dashboardBody(
useShinyjs(),
tags$hr(),
tabsetPanel(
id ="tabA",
type = "tabs",
tabPanel("Front",icon = icon("accusoft")),
tabPanel("Data", icon = icon("table")
)
)
),
controlbar = dashboardControlbar()
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)
也许您可以改为调用shinydashboard::dashboardSidebar
:
ui <- dashboardPage(
dashboardHeader(title = "dashboard"),
shinydashboard::dashboardSidebar(collapsed = TRUE,disable =TRUE),
dashboardBody(
useShinyjs(),
tags$hr(),
tabsetPanel(
id ="tabA",
type = "tabs",
tabPanel("Front",icon = icon("accusoft")),
tabPanel("Data", icon = icon("table")
)
)
),controlbar = dashboardControlbar()
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.