Ok, this sounds weird even to me but, it seems that styling ActionBar element from within the app.css file doesn't take effect. Styling other custom elements (StackLayout, ListView, ecc..) does work, but not ActionBar. The same CSS placed in a page component style (I'm using Angular Nativescript) does take effect.
All NativeScript components versions information
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ Component โ Current version โ Latest version โ Information โ
โ nativescript โ 3.1.1 โ 3.1.1 โ Up to date โ
โ tns-core-modules โ 3.1.0 โ 3.1.0 โ Up to date โ
โ tns-android โ 3.1.1 โ 3.1.1 โ Up to date โ
โ tns-ios โ โ 3.1.0 โ Not installed โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
@marco-gagliardi I have tested the described scenario and the styles are applied successfully in this test project.
However one reason for your issue might be if there are another CSS styles that are applied on your ActionBar. By default when you craete new Angular porject the template is using a set of pre-defined CSS themes delivered with nativescript-theme-core.
Also by default, the template is applying a CSS class to your automatically generated ActionBar.
e.g.
<ActionBar title="My App" class="action-bar">
</ActionBar>
So to resolve you issue and to make the global styles from your app.css to be respected you ahve two options.
<ActionBar title="My App">
</ActionBar>
and when this is done the style applied on your element Actionbar in app.css will be respected.
ActionBar {
background-color: red;
color: white;
}
<ActionBar title="My App" class="action-bar priority-style">
</ActionBar>
and in your app.css (imports should always be first.. all CSS classess below will take priority)
@import 'nativescript-theme-core/css/core.light.css';
.priority-style {
background-color: blue;
color: white;
}
Use one of the two options depending on your style but keep in mind that CSS classes will have greater priority than element styling. In the same time, same styles applied by different CSS classes will be respected by their structural order in the CSS file.
Hi @NickIliev you are totally right, applying a more specific selector (as in your second option) I could successfully overwrite the default stile for ActionBar element. Thank you!
any possibility of making this work with iOS <ActionBar :class="appcolo + ' c-white'"> it works with Android
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
@marco-gagliardi I have tested the described scenario and the styles are applied successfully in this test project.
However one reason for your issue might be if there are another CSS styles that are applied on your ActionBar. By default when you craete new Angular porject the template is using a set of pre-defined CSS themes delivered with nativescript-theme-core.
Also by default, the template is applying a CSS class to your automatically generated ActionBar.
e.g.
So to resolve you issue and to make the global styles from your
app.cssto be respected you ahve two options.and when this is done the style applied on your element Actionbar in app.css will be respected.
e.g.
and in your app.css (imports should always be first.. all CSS classess below will take priority)
Use one of the two options depending on your style but keep in mind that CSS classes will have greater priority than element styling. In the same time, same styles applied by different CSS classes will be respected by their structural order in the CSS file.