I'm trying to change default Angular Material styles of md-menu
. The problem is the Angular Material generates elements dynamically and I can't get access to them from my HTML.
Here is my DOM:
And here is my component HTML (md-menu
generates that DOM):
<md-toolbar color="primary">
<h1>Logo</h1>
<span class="spacer"></span>
<img src="../../../images/avatar-default.png" class="avatar" [mdMenuTriggerFor]="userMenu" />
<md-menu #userMenu="mdMenu">
<button md-menu-item>{{username}}</button>
<button md-menu-item>Log Out</button>
</md-menu>
</md-toolbar>
I know that I can get access to that div
(selected on the picture) from global styles using .mat-menu-content {...}
, but it will affect other elements with such classes. And I'm unable to set styles to this div from component CSS, because the element is outside component scope. So I'm trying to find the way to change styles of this element from component CSS and without affecting other elements with such style.
If there is a way to implement it, please, let me know.
Described in the picture below,Maybe this doc would help
Check if using
/deep/
is an option for you.Doc
component.css:
demo