{"id":269,"date":"2018-06-15T16:24:28","date_gmt":"2018-06-15T16:24:28","guid":{"rendered":"http:\/\/www.bullcrane.com\/angular\/?p=269"},"modified":"2018-06-15T16:35:09","modified_gmt":"2018-06-15T16:35:09","slug":"styling-mat-menu-items","status":"publish","type":"post","link":"http:\/\/www.bullcrane.com\/angular\/2018\/06\/15\/styling-mat-menu-items\/","title":{"rendered":"Styling mat-menu items"},"content":{"rendered":"<h6>Problem<\/h6>\n<p>I want Angular Material drop-down menu items to go wider before resorting to elipsis.<\/p>\n<p>Here is a simplified example.&nbsp; Angular Material cuts off the item, displaying elipsis<\/p>\n<p>html:<\/p>\n<pre>&lt;mat-menu #playlistMenu=\"matMenu\"&gt;\r\n  &lt;button mat-menu-item&gt;\r\n    aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll\r\n  &lt;\/button&gt;\r\n&lt;\/mat-menu&gt;\r\n&lt;button mat-button class=\"mat-title\" \r\n  [matMenuTriggerFor]=\"playlistMenu\">\r\n  Playlist &lt;i class=\"material-icons\"&gt;arrow_drop_down&lt;\/i&gt;\r\n&lt;\/button&gt;<\/pre>\n<p>Results:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-unstyled.png\" alt=\"\" width=\"305\" height=\"83\" class=\"alignnone size-full wp-image-285\" srcset=\"http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-unstyled.png 305w, http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-unstyled-300x82.png 300w\" sizes=\"(max-width: 305px) 100vw, 305px\" \/><\/p>\n<h6>Solution<\/h6>\n<p>By providing my own class with a selector that is more specific than what Angular Material is using, my style declarations come in as overrides.&nbsp; All other stylings remain in effect.<\/p>\n<p>In styles.css:<\/p>\n<pre>div.plMenuCSS { \r\n  max-width:500px;\r\n  background-color:lightgreen;\r\n  }<\/pre>\n<p>Then in the html:<\/p>\n<pre>&lt;mat-menu #playlistMenu=\"matMenu\"&gt;\r\n  &lt;button mat-menu-item <span style=\"color:red\">class=\"plMenuCSS\"<\/span>&gt;\r\n    aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll\r\n  &lt;\/button&gt;\r\n&lt;\/mat-menu&gt;\r\n&lt;button mat-button class=\"mat-title\" \r\n  [matMenuTriggerFor]=\"playlistMenu\">\r\n  Playlist &lt;i class=\"material-icons\"&gt;arrow_drop_down&lt;\/i&gt;\r\n&lt;\/button&gt;<\/pre>\n<p>Results:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-styled.png\" alt=\"\" width=\"443\" height=\"86\" class=\"alignnone size-full wp-image-286\" srcset=\"http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-styled.png 443w, http:\/\/www.bullcrane.com\/angular\/wp-content\/uploads\/2018\/06\/mat-menu-item-styled-300x58.png 300w\" sizes=\"(max-width: 443px) 100vw, 443px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem I want Angular Material drop-down menu items to go wider before resorting to elipsis. Here is a simplified example.&nbsp; Angular Material cuts off the item, displaying elipsis html: &lt;mat-menu #playlistMenu=&#8221;matMenu&#8221;&gt; &lt;button mat-menu-item&gt; aaaa bbbb cccc dddd eeee ffff gggg hhhh iiii jjjj kkkk llll &lt;\/button&gt; &lt;\/mat-menu&gt; &lt;button mat-button class=&#8221;mat-title&#8221; [matMenuTriggerFor]=&#8221;playlistMenu&#8221;> Playlist &lt;i class=&#8221;material-icons&#8221;&gt;arrow_drop_down&lt;\/i&gt; &lt;\/button&gt; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.bullcrane.com\/angular\/2018\/06\/15\/styling-mat-menu-items\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Styling mat-menu items&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/269"}],"collection":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":17,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"predecessor-version":[{"id":288,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/posts\/269\/revisions\/288"}],"wp:attachment":[{"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bullcrane.com\/angular\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}