The collapsible sidebar layout is a variation of the sidebar layout that adds a toggle button to collapse the sidebar.
To install the collapsible sidebar layout, run the following command:
rails g instrumental:layout --collapsible_sidebar
While the collapsible sidebar looks very similar to the sidebar layout (and much of its' structure is the same), there are a few key differences:
collapsible_sidebar_controller.js
Stimulus controller to handle toggling open and collapsed states of the sidebar._nav.html.erb
partial) are quite different, as they are designed to handle both the collapsed and open states.The sidebar can be toggled using the toggle button seen at the top of the sidebar.
The user's collapsed state is "remembered" since the collapsible_sidebar_controller.js
Stimulus controller saves the state to the browser's local storage.
I created Instrumental Components to make designing and building professional apps with Ruby on Rails easy, fast, and fun. I use it on all of my projects and I hope it helps you build something great.