Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular material sidenav and fixed toolbar

I copied this sidenav demo from the angular material docs. https://material.angularjs.org/latest/demo/sidenav

And added the first toolbar demo to it from https://material.angularjs.org/latest/demo/toolbar

What I want is the toolbar to be fixed.

Codepen demo: http://codepen.io/gvorster/pen/BzWvGe

When adding this style the toolbar is fixed.

<md-toolbar class="md-hue-2" style="position:fixed !important">

But the icons on the right are gone.

enter image description here

Resizing the screen until the sidenav is hidden will show the right side icons.

enter image description here

Removing the style shows the right side icons but the toolbar is not fixed:

enter image description here

Is there a way to get a sticky toolbar and have the rigth side icons shown.

like image 810
August Avatar asked Jun 29 '16 12:06

August


People also ask

How do I use Sidenav in angular materials?

To set up a sidenav we use three components: <mat-sidenav-container> which acts as a structural container for our content and sidenav, <mat-sidenav-content> which represents the main content, and <mat-sidenav> which represents the added side content.

Can we use bootstrap and angular material together?

Yes, you can use parts of Angular Material and Bootstrap together in the same web or mobile project. Developers need to be careful not to use the same components, which can clash. Angular Material and Bootstrap offer a variety of unique components for great website design.

How do I know if my Sidenav mat is open?

From the docs: A mat-sidenav can be opened or closed using the open(), close() and toggle() methods. Each of these methods returns a Promise that will be resolved with true when the sidenav finishes opening or false when it finishes closing.


1 Answers

You have to use md-sidenav inside the md-content container. Plus try to use md-content instead of div tag. In your example you gave wrong values to layout-align attribute. Please check the appropriate values in the Docs.

Here is the basic structure for your requirement.

<md-content flex>
    <md-toolbar>
    </md-toolbar>

    <md-content layout="column" layout-fill>
        <!-- content -->

        <md-sidenav>
        </md-sidenav>
    </md-content>
</md-content>

here is the working pen. http://codepen.io/next1/pen/xOqMjy

like image 116
nextt1 Avatar answered Oct 05 '22 19:10

nextt1