Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mat-Toolbar Align Items (left, center and right)

I developed a toolbar but I can't align elements on the same line, left, center and right.

Does anyone know how I can align these elements?

I notice that the elements with the name Align left are aligned to the left, the align center aligned to the center and the align right aligned to the right.

Thanks

Demo

Code

  <mat-sidenav-content fxFlexFill>  
      <mat-toolbar color="primary">
    <mat-toolbar-row>
      <button mat-icon-button (click)="sidenav.toggle()" fxShow="true" fxHide.gt-sm>
        <mat-icon>menu</mat-icon>
      </button>

      <div fxShow="true" fxHide.lt-md>
        <a href="#" mat-button>Align left</a>
        <a href="#" mat-button>Align left</a>
        <a href="#" mat-button>Align center</a>
        <a href="#" mat-button>Align center</a>
        <a href="#" mat-button>Align right</a>
        <a href="#" mat-button>Align right</a>
      </div>
    </mat-toolbar-row>
  </mat-toolbar>
like image 871
Paul Th. Avatar asked Feb 28 '20 15:02

Paul Th.


1 Answers

css. This expands to occupy max available space.

.flexExpand {
    flex: 1 1 auto;
}

in your template use flexExpand utility to separate the items

<mat-toolbar>
<mat-toolbar-row>
 <div >
      <a mat-button [routerLink]="'/accounts'"> Accounts </a>
      <a mat-button [routerLink]="'/create-account'"> Create Account </a>
    </div>
    <span class="flexExpand"></span>
    <div >
      <a mat-button [routerLink]="'/logout'"> Logout </a>
    </div>
    <mat-toolbar-row>
</mat-toolbar>
like image 177
NANDWERE Avatar answered Sep 18 '22 07:09

NANDWERE