如何在预定义的材料主题之间切换?

huangapple go评论47阅读模式
英文:

How to switch between predefined material themes?

问题

In Angular Material, we have 4 predefined themes:

  • indigo-pink
  • pink-bluegrey
  • purple-green
  • deeppurple-amber

我想要将这四个主题都包含在应用程序中,并提供在运行时切换它们的方式。

Q: 如何在运行时切换预定义的 Material 主题?

注意 - 我不打算创建任何自定义主题,我只想使用预定义的主题。这应该很简单,但我找不到任何做这个的示例。


我正在使用 Angular v16。

英文:

In Angular Material, we have 4 predefined themes:

  • indigo-pink
  • pink-bluegrey
  • purple-green
  • deeppurple-amber

I want to include all 4 of them into them app, and provide a switch between them.

Q: How can we switch between predefined material themes at run-time?

Note - I do not intend to create any custom theme, I just want to use the predefined ones. It's supposed to be very easy, but I cannot find a single example of doing that.


I'm using Angular v16

答案1

得分: 1

以下是翻译好的内容:

你问题的确切答案在 Angular Material 文档中。
他们也在文档网站上使用切换器来切换主题。
你可以查看文档网站的源代码,肯定会找到切换器的逻辑!再见

英文:

The exact answer for your question is on the angular material docs itself.
They too use a switcher to switch between themes on the documentation website.
You can just dig up through the documentation website source code, you will surely find the switcher logic somewhere for sure ! Adios

huangapple
  • 本文由 发表于 2023年5月14日 20:13:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76247422.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定