mui
mui copied to clipboard
How to set Example Layouts : Responsive Side Menu hide the sidebar as default
In that example, the sidebar is show as default, how to set hide as default.
To hide the sidebar by default you can comment out the media query: https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L74 https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L106
then remove this element: https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L266
then remove the mui--visible-xs-inline-block mui--visible-sm-inline-block
classes from the other toggle element:
https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L265
thanks! It works. It hides the sidebar as default now, but does not show as it did before, and the hiding animation is gone.
by the way, I recommend that it would be better to make an easy way to let the user to choose it show or hide as default
What do you mean by "does not show as it did before"? Can you describe the behavior you're looking for in more detail? The behavior with the modifications should be:
- Side drawer is hidden by default at all screen widths
- Clicking on the hamburger icon in the header will dim the main content and the side drawer will slide in from the left
- Clicking anywhere inside the overlay will hide the side drawer
BTW, great GitHub avatar!
sorry for that I did not describe it clear. I mean when I click the icon to let the sidebar show, it does not push the main content to the right side as it did before, and when I want it to hide, instead of slide and hide to the left like before, it just disappear immediately
The sliding is controlled by the hide-sidedrawer
class on the <body>
tag:
https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L91-L105
One way to modify the code to behave like you want it to is to add the hide-sidedrawer
class to the <body>
tag on load and modify the behavior of the hamburger icon to toggle the class:
https://github.com/muicss/mui/blob/master/examples/layouts/sidedrawer.html#L208-L214