Addressing the Issue
Given that /deep/
, >>>
, and ::ng-deep
are no longer recommended, what is the appropriate approach to reduce the width of mat-tab-label
which has a minimum width of 160px on desktop devices?
- Is there a way to achieve this without directly overriding it in the main
styles.css
file? - I aim to keep this customized styling of Material Tabs contained within the parent component.
Guidelines from Material Design
Fixed tabs display all tabs on one screen, with each tab at a fixed width.
The width of each tab is determined by dividing the number of tabs by the screen width.
They don’t scroll to reveal more tabs; the visible tab set represents the only tabs available.
In my scenario, however, the max-width
of my parent component is restricted to 320px, giving approximately 106px for each mat-tab-label
.
Update 1
The Angular Material documentation suggests to
Add the overriding style to your global stylesheet. Scope the selectors so that it only affects the specific elements you need it to.
. However, I prefer to avoid this for better separation of concerns.