Ionic4.x Theming(主题) 增长内置主题 颜色 修改内置组件默认样式 修改底部 Tabs 背景颜色以及按钮颜色

1Ionic4.x Theming(主题)
css

 

Ionic4.x 修改主题颜色的话须要在 src/theme/variables.scss 文件中修改。 api

 

https://ionicframework.com/docs/theming/advanced

 

2Ionic4.x 增长内置主题颜色 app

 

找到 src/theme/variables.scss 文件,以下代码新增 favorite 颜色 ionic

 

.ion-color-favorite {
--ion-color-base: #69bb7b; 
--ion-color-base-rgb: 105,187,123;
 --ion-color-contrast: #ffffff; 
--ion-color-contrast-rgb: 255,255,255;
--ion-color-shade: #5ca56c;
--ion-color-tint: #78c288; 
}

 

用法spa

<ion-button color="favorite">
自定义颜色
</ion-button>

3、修改内置组件默认样式 code

官方文档:https://ionicframework.com/docs/api/button blog

ionic4.x 组件中有 CSS Custom Properties。咱们能够经过 CSS Custom Properties 提供的样式 来修改 ionic4.x 内置组件的默认样式。 文档

找到 src/theme/variables.scss 文件修改 ion-button 的默认样式。 scss

ion-button {
--color: #222; --background:red;
}

4、修改底部 Tabs 背景颜色以及按钮颜色 flash

<ion-tabs>
<ion-tab-bar slot="bottom" color="favorite">
<ion-tab-button tab="tab1">
<ion-icon name="flash"></ion-icon> <ion-label>Tab One</ion-label>
</ion-tab-button> <ion-tab-button tab="tab2">
<ion-icon name="apps"></ion-icon>
<ion-label>Tab Two</ion-label> </ion-tab-button>
</ion-tab-bar> </ion-tabs>
.ion-color-favorite {
--ion-color-base: #69bb7b; 
--ion-color-base-rgb: 105,187,123;
--ion-color-contrast: #ffffff;
--ion-color-contrast-rgb: 255,255,255;
--ion-color-shade: #5ca56c;
--ion-color-tint: #78c288; }

 

contrast 对比色,好比底部 tabs 的颜色是#69bb7b 则里面按钮的颜色是#ffffff

相关文章
相关标签/搜索