Material components not using color accent declared in theme

angular material theme colors
mat-palette custom color
angular material background color
angular material theme generator
material themes
angular material multiple themes
material theme css
angular material theme not working

My main app theme parent is MaterialComponents theme. I changed the colors, but material components (MaterialButton, InputLayout, EditText) are not using my accent color (they are using some blue color, my declared Accent color is Teal) What is the issue? How is the best way to deal with theming Material Components?

My main theme:

    <style name="AppTheme" parent="Theme.MaterialComponents">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

Edit: Changing theme to Theme.MaterialComponents.Bridge is not solving that problem.

Maybe you should try to use colorSecondary insteat of colorAccent

 <style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
    <!-- Original AppCompat attributes. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorSecondary">@color/colorAccent</item>
</style>

This works for me

colorAccent or colorSecondary with Material Component theme , MaterialComponents uses the colorSecondary as described in the All the components defined in the library uses this attribute. between colorSecondary and the colorAccent for these themes. Not sure if this is correct. This will bring up color palette definition for Material Theme. Copy the definition and paste it in styles. scss file. Make sure that you repeat the same step for both primary and accent color. Configure Theme. We are almost done with the code, the only thing remaining is to use a default material theme and pass the color palettes we have created.

Inherit your app theme from Theme.AppCompat like:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    ...
</style>

Note that dark or light theme is upon you but you need to extend Theme.AppCompat.

How to change Angular material theme in just 5 minutes!, it's very easy to create a custom angular material theme. accent and warning colors that will be used on Angular Material components. Next, you'll declare variables for your primary, accent and warning colors using the mat-palette function  What you shouldn’t do: My first attempt was to create the color variables in the theme.scss directly.That’s wrong because it would @include mat-core and angular-material-theme every time we

Try changing your styles.xml like this :

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

If this works, let me know

Edit : Try following this link for setting up material components https://medium.com/@pedromassango/android-material-design-components-setup-google-i-o18-part-1-8894f315b5e

How to use the Angular Material's theme colors in your components , When using Material 2, It can be a little tricky to figure out how to use the $primary​, $accent and $warn colors in our components's Sass files. This is the easiest  In our introduction to Angular Material 2, we showed how to use one of the pre-built themes, but it’s just as easy to create a custom theme.This will allow you to specify primary, accent and warning colors that will be used on Angular Material components.

The issue in my case was a different styles xml declared for specific API. I made a mistake in it, and when testing, that other styles-v21.xml was applied before styles.xml. So long story short, check if the mistake is not present in other variants. I declared that variant wrong.

Theming your own components, In order to style your own components with Angular Material's tooling, the component's styles must be defined with Sass. link 1. Define all color and typography styles in a "theme file" for the component $primary: map-get($​theme, primary); $accent: map-get($theme, accent); // Define any styles affected by the theme. The Material Design color system helps you apply color to your UI in a meaningful way. In this system, you select a primary and a secondary color to represent your brand. Dark and light variants of each color can then be applied to your UI in different ways. Material Theme Editor. The Material Theme Editor helps you make your own branded symbol

[SwitchMaterial] Allow theme override · Issue #930 · material , TextInputLayout allows to override color attributes of theme by setting a theme If you are using one of the (non-bridge) MaterialComponents themes, or colorAccent , changing colorOnSecondary will not change your switch color. base theme (it does not need to be declared in the switch styleable). #05 – Create Alternative Themes in Angular Material 8. Creating an alternate theme in angular material 8 is not that difficult. All you have to do just declared the alternate theme in your theme.scss file like given below. The my-alternate-theme class name should be defined within a class element in the HTML template. You can check out in the example below how we have defined the class name in the parent HTML element, and the alternate theme is working fine.

Styles and Themes, A style can specify attributes such as font color, font size, background color, and Styles and themes are declared in a style resource file in res/values/ it applies a material design theme to your app by default, as defined in Note: Attribute names from the support library do not use the android: prefix. Setting up a Material Components theme for Android brand color of your app, used mostly as an accent for certain widgets appearance of primary/secondary colors is to use the Material Color

Custom Theme for Angular Material Components Series: Part 3 , Apply Theme to Angular Material and its different Components. For each themed toolbar, they are creating classes .mat-primary , .mat-accent and .mat-​warn . are calling a mixin _mat-toolbar_color (which is defined at lines 6–9). supports color attribute or not, you can try by adding color="primary" in  Some use cases in Material Design can benefit from using select dark theme elements. Large surfaces. Components that use a large portion of a screen, such as an app bar or a backdrop, can use the dark theme for their component's surface color.

Comments
  • is your @color/colorPrimary & @color/colorPrimaryDark are blue?
  • When using MaterialComponents shouldn't you use MaterialButton, MaterialXxx insteadof Button, Xxx?
  • Sory, I wasn't clear. My Color Accent is Teal. I am using Material Components: Material Buttons
  • Do You mean that I should use that theme and declare missing attributes? Because that theme don't have all attributes for Material Components.
  • Yes, all material components use the colors declared in your app theme but it need to be inherited from Theme.AppCompat where Android is looking for the theme colors like colorAccent or colorPrimary. But don't forget to use your declared theme in AndroidManifest like: <application android:theme="@style/AppTheme">
  • Okay, I will try this approach and give feedback :)
  • It is not working, I was trying few variants, as well as Bridge variants. I think I need to override more attributes