Hide default sidebar in shinydashboard

I used shinydashboard to create my application. I would like to hide a third-party user by default in a desktop environment (e.g. windows), but not disable it. On the mobile device, the sidebar is hidden by default. I think I need to change the css class, but don't know how to do it.

Thanks for any suggestions.

These are my game codes:

 library(shiny) library(shinydashboard) ui <- shinyUI(dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody() )) server <- shinyServer(function(input, output, session) { }) shinyApp(ui = ui, server = server) 
+5
source share
2 answers

This is very similar to my answer from another SO thread: "disable / enable sidebar on server side"

Here's a code that can do what you want by hiding the sidebar when starting the application (using shinyjs package)

 library(shiny) library(shinydashboard) library(shinyjs) ui <- shinyUI(dashboardPage( dashboardHeader(), dashboardSidebar(), dashboardBody( useShinyjs() ) )) server <- shinyServer(function(input, output, session) { addClass(selector = "body", class = "sidebar-collapse") }) shinyApp(ui = ui, server = server) 
+12
source

if you execute ?dashboardSidebar , you are likely to see this use, for example

dashboardSidebar (..., disable = FALSE, width = NULL, collapsed = FALSE)

So this should work

 sidebar <- dashboardSidebar( collapsed = TRUE, sidebarMenu() ) 

I'm not sure if this depends on your version of shinydashboard, but you can check and change this.

+6
source

Source: https://habr.com/ru/post/1242156/


All Articles