Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
README.md
app.R
shinydashboard-sidebar-hide.gif

README.md

Hide/show shinydashboard sidebar programmatically

A common question regarding shinydashboard is how to programmatically hide/show the sidebar.

To solve this problem, I first looked at the HTML and tried to see what happens when the button to toggle the sidebar is clicked. It seems like the <body> HTML tag gains and loses a CSS class "sidebar-collapse" when the toggle button is clicked. Therefore, all we have to do to show/hide the sidebar is simply remove/add that class to the document's body tag. This can easily be done using the shinyjs package.


Demo