23

This is the code example being used in angular Material for Sidenav. Im using this very same example on my page. However, I could find any instructions how to open the sidenav from left to right from the right side of the screen. Anybody knows how to ?

<mat-sidenav-container class="example-container">
  <mat-sidenav #sidenav mode="side" [(opened)]="opened" (opened)="events.push('open!')"
               (closed)="events.push('close!')">
    Sidenav content
  </mat-sidenav>

  <mat-sidenav-content>
    <p><mat-checkbox [(ngModel)]="opened">sidenav.opened</mat-checkbox></p>
    <p><button mat-button (click)="sidenav.toggle()">sidenav.toggle()</button></p>
    <p>Events:</p>
    <div class="example-events">
      <div *ngFor="let e of events">{{e}}</div>
    </div>
  </mat-sidenav-content>
</mat-sidenav-container>
dota2pro
  • 7,220
  • 7
  • 44
  • 79
Carl.G
  • 257
  • 1
  • 3
  • 6

3 Answers3

54

If you look to the API tab there is an input directive position for you to define.

position: 'start' | 'end'

The side that the drawer is attached to.

<mat-drawer-container class="example-container">
  <mat-drawer #sideNav mode="side" opened="true" position="end">
    Right drawer
  </mat-drawer>
  <mat-drawer-content>
    Main content
  </mat-drawer-content>
</mat-drawer-container>

DEMO

Shift 'n Tab
  • 8,808
  • 12
  • 73
  • 117
0

You can use input directive position="end" for opening from the right side in mat-drawer.

For instance:

<mat-drawer position="end">

https://material.angular.io/components/sidenav/overview

RobC
  • 22,977
  • 20
  • 73
  • 80
Ahmer Shahid
  • 107
  • 1
  • 4
0

I have tried adding position="end" to make it work but it didn't.

For any lost desperate souls, try adding style.position="absolute" and set your .sidenav to have left: calc(100% - 200px);

taylorswiftfan
  • 1,371
  • 21
  • 35