gpt4 book ai didi

angular - 如何在 ngx-admin 主题中使用主题颜色

转载 作者:行者123 更新时间:2023-12-05 01:00:04 25 4
gpt4 key购买 nike

我是 Angular 的新手,我正在尝试通过使用 ngx-admin 来学习它主题。它使用 Sass 进行样式设置,并且在我的一个组件中,我想设置 div 的背景颜色。但是我想使用主题提供的一种颜色,这样如果用户切换主题,颜色就可以改变。我无法弄清楚如何在组件的 scss 文件中使用主题的全局颜色。

这就是我想要的

.product-container{
background:#3d3780; // Instead of using a hard coded color, I want to use theme color here
}

最佳答案

好的,我知道了如何使用主题全局颜色。

首先你需要通过导入来导入全局主题样式

@import '~@nebular/theme/styles/theming';
@import '~@nebular/theme/styles/themes';

然后我可以这样设置颜色

@include nb-install-component() {
.product-container{
background:nb-theme(color-bg);
}
}

我们需要在 @include nb-install-component() 调用中包装我们的样式,以便在用户更改主题时刷新样式。

对于任何有兴趣进一步阅读的人,here是主题的官方文档。

关于angular - 如何在 ngx-admin 主题中使用主题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50734138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com