![](/img/trans.png)
[英]How to use ngx-Admin components, without using ngx-Admin Starter Kit?
[英]How to use theme colors in ngx-admin theme
我是 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() 調用中,以便在用戶更改主題時刷新樣式。
對於任何有興趣進一步閱讀的人, 這里是該主題的官方文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.