简体   繁体   中英

Change Mat Option Font Family for Mat Select - Angular Material

I am attempting to change the font of the options inside mat-select ("In what city were you born", etc).

I noticed if I set ViewEncapsulation to none (eg let styles bleed in from other files), it does allow me to change the font family, but setting this to none causes other unwanted styles to bleed in even though I have these all set to ":host"

在此处输入图像描述

Note: I noticed when I change the font for this class in dev tools that it changes the font successfully:

在此处输入图像描述

However when I add the style to my css file and try it even with ng-deep, it still doesn't change the font.

add this to your styles.css / styles.scss file in your Angular project:

.mat-option-text {
  font-size: 16px !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !important;
}

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