Totally hide left sidebar of shiny dashboard by clicking on existing toggle button without affecting the title section

Viewed 32

How is it possible to hide the left sidebar of a shinydashboard() totally without also affecting the header section that almost hides the title by using the toggle button that is already there?

## 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)
1 Answers

Maybe you can call the shinydashboard::dashboardSidebar instead:

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()
)
Related