简体   繁体   中英

text in material icons in mat-toolbar alignment

I am using angular material, mat-toolbar to create a toolbar. I need to mat-icon and the related text to align one another (in two rows and center aligned)

Code:

<mat-toolbar class="secondary-toolbar">
  <button mat-icon-button>
    <mat-icon>apps</mat-icon>
    Dashboard
  </button>
</mat-toolbar>

This code shows the image as below:

在此处输入图片说明

However, I require it to be something like this:

在此处输入图片说明

Add to the dashboard span identifier such as class or id .

<span id="Dashboard">Dashboard</span>

Than, Add display flex styling .

#Dashboard
{
 display: flex;
 } 

Stackblitz Example .

You can do this using flex display.

css

.secondary-toolbar button{
  display: flex;
  flex-direction: column;
}

Try this

.button-icon-text {
    width: unset;
}

<button mat-icon-button class="button-icon-text" aria-label="Example icon-button with menu icon and text">
    <mat-icon>menu</mat-icon>
    <span>Menu</span>
</button>      

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM