'Modify imported angular material theme from within main angular application

I'm trying to get my head around a solution to alter an imported meterial theme.

So I have a widget library which exports my components which also transports and exports a material theme with it.

This is a dependency of my main application. Now I want to use this transported material theme and apply it to the angular material installation within the main application.

And also want to be able to change/overload certain variables/colors/typography etc. of the imported theme.

Would something like this somehow be possible?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source