简体   繁体   中英

Customize Angular Material component dimensions

I am trying to customize the sizing of Angular Material buttons (ie padding). The definition of these values comes from a variable called $mat-button-padding in _button-base.scss . However, it is directly included in the button.ts . Is there a possibility to adjust this value?

I already tried overriding it before including the material theme (as the variable is defined using !default ), but it has no effect since the styles are directly included in the button component. Are there any other options except overriding it by hand and generating duplicate styles (basically an additional css definition that overrides the button styles)?

Any idea is highly appreciated.

You can add own class in "mat-button" element like below and you can apply your own css.

<button mat-stroked-button 
color="primary" 
class="common-button">Button</button>

.common-button {
  border-radius: 4px;
  line-height: 2.5;
  height: 80px;
}

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