角质材料19-不适用于自定义主题的MAT型图

问题描述 投票:0回答:1
i我建立了一个新的角度项目,其中有Angular 19,并遇到了标题中提到的问题。 使用ng添加CLI命令添加材料,如果我想使用版式,请在提示符中选择“是”。到目前为止,我的身体元素现在具有Mattypography类。

next,我根据文档设置了一个自定义主题,我的主题声明看起来像:

@use "@angular/material" as mat; html { @include mat.theme( ( color: ( theme-type: light, primary: mat.$spring-green-palette, ), typography: Roboto, density: 0, ) ); }

也遵循材料文档,将机器人字体添加到我的元素中。之后,材料组件具有正确的字体和版式,但是“普通”的html标签(如
<h1>

<p>
,等等)也没有。搜索了应应用的规则的预定义主题,如果我将其复制到我的主样式表,它们可以正常工作,但是即使在主题中设置了“ Typograpy”部分,自定义主题似乎也不包括在内config.
screenshots显示了两种情况之间的差异:

typography not applying to h1 and p

typography applied correctly有人遇到了这个问题,如果是的话,找到了任何解决方案?

类似这样的方法(

mat.theme(

)没有设置字体(因为没有主题返回到变量中),您可以尝试此快捷方式,该快捷方式存在于角/材料中:
angular angular-material
1个回答
0
投票
@use '@angular/material' as mat; body { font-family: Roboto, 'Helvetica Neue', sans-serif; @include mat.theme( ( color: ( theme-type: light, primary: mat.$spring-green-palette, ), typography: Roboto, density: 0, ) ); } html { height: 100%; }

stackblitzdemo

    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.