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

时间:2018-06-07 06:17:47

标签: angular sass

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

这就是我想要的

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

1 个答案:

答案 0 :(得分:3)

好的,我能够找到如何使用主题全局颜色。

首先,你需要通过导入

导入全局主题样式
@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是该主题的官方文件。

相关问题