Style the width (Shorter) for mat-option elements
Bug, feature request, or proposal:
Feature Request I am trying to dynamically size (shorten) mat-options within an mat-select. Unfortunately, I always get an extra area of padding. Is there not a designed way for this? Anyone have any experience with this? Here is my StackBlitz, it's very close:
https://stackblitz.com/edit/angular-material-select-custom-options?file=src%2Fapp%2Fdropdown%2Fcustom-dropdown.component.scss
Basically the issue on the StackBlitz is the use of /deep/ which will effect all the rest of the cdk-overlay-pane's which is not desired.
What is the expected behavior?
I would like to be able to size (SHORTEN) the width of the mat-option, without the use of /deep/ *(see stackblitz link)
What is the current behavior?
I need to use /deep/ in order to size the cdk-overlay-pane. without that, the resizing of the mat-options is impossible, as far as I can tell..
What are the steps to reproduce?
https://stackblitz.com/edit/angular-material-select-custom-options?file=src%2Fapp%2Fdropdown%2Fcustom-dropdown.component.scss
What is the use-case or motivation for changing an existing behavior?
We would like to put custom buttons / mat-options of different sizes in the mat-select. Unfortunately, without doing something "hacky" it is difficult, due to the cdk-overlay-pane being outside of the encapsulation of the component. And I would not like to change the behavior of the OTHER cdk-overlay-panes or other mat-selelcts.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
All
Is there anything else we should know?
Thank you for any advice on how to accomplish this!! Preferably with styling only!
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
This doesn't work, because the styles are inside a view-encapsulated component. You can get it to work either with ::ng-deep or by moving the styles into the globals stylesheet. Closing since there isn't anything we can do here.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.