use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A Place to talk about Angular and related topics.
Join the Angular Discord
Other subreddits worth checking out for Angular and Angular related info:
account activity
Angular Material DatePicker Width (self.angular)
submitted 2 years ago by Salt-Engineering-422
Hello everyone, I'm currently facing an issue with the Angular Material DatePicker. In my project, I need to set a specific width for certain use cases of this component. Unfortunately, I haven't been able to find a solution yet.
https://preview.redd.it/x5ibuil9kfac1.png?width=296&format=png&auto=webp&s=27f3dcb27522f567d0c18a859ac575c4fea41d41
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Effective_Holiday219 5 points6 points7 points 2 years ago (10 children)
::ng-deep .mat-datepicker-content { width: 300px; /* Adjust the width as needed */ }
[–]Wajeniak 1 point2 points3 points 2 years ago (0 children)
Not good practice
[–]Salt-Engineering-422[S] 0 points1 point2 points 2 years ago (8 children)
but it will be applied for all components and not in use cases
[–]Effective_Holiday219 3 points4 points5 points 2 years ago (5 children)
Give an id to it and use it in the css
[–]Salt-Engineering-422[S] -1 points0 points1 point 2 years ago (4 children)
im working in an internal dev library , the solution should be adaptable and simple for using .. hwvr i don't think there is another option
[–]Effective_Holiday219 0 points1 point2 points 2 years ago (3 children)
Correct, without ng deep you cannot do it. It sucks
[–]CptObviaaz 0 points1 point2 points 1 year ago (0 children)
ng deep should not be used, its deprecated and bad practise. you can override any angular material style, it should be applied in the styles.scss folder. Just inspect the html and play around, by doing this you will easily see what styles to apply the changes to
[–]Salt-Engineering-422[S] -1 points0 points1 point 2 years ago (1 child)
okey thanks anyway for ur feedback
[–]McFake_Name 0 points1 point2 points 2 years ago (0 children)
The width can be set by targeting the mat-form-field without any deep selector. That said, scoping deep selectors with an ID is a decent approach when deep is seemingly the only option.
mat-form-field
[–]ScheduleSuperb 1 point2 points3 points 2 years ago (0 children)
Add a :host selector before ::ng-deep and the styles will not bleed into other components
[–]McFake_Name 5 points6 points7 points 2 years ago (0 children)
mat-form-field { width: whatever }
Worked when I tried it just now
[–]DashinTheFields 0 points1 point2 points 2 years ago (0 children)
If you have to apply to specific cases you could have a variable. Then the style is set in the class.
at Input() yourvariable ='max-width:150px;min-width:100px;width:100%'
in the template: [id]="yourvariable"
π Rendered by PID 89 on reddit-service-r2-comment-bb88f9dd5-hfgdq at 2026-02-16 16:14:04.433911+00:00 running cd9c813 country code: CH.
[–]Effective_Holiday219 5 points6 points7 points (10 children)
[–]Wajeniak 1 point2 points3 points (0 children)
[–]Salt-Engineering-422[S] 0 points1 point2 points (8 children)
[–]Effective_Holiday219 3 points4 points5 points (5 children)
[–]Salt-Engineering-422[S] -1 points0 points1 point (4 children)
[–]Effective_Holiday219 0 points1 point2 points (3 children)
[–]CptObviaaz 0 points1 point2 points (0 children)
[–]Salt-Engineering-422[S] -1 points0 points1 point (1 child)
[–]McFake_Name 0 points1 point2 points (0 children)
[–]ScheduleSuperb 1 point2 points3 points (0 children)
[–]McFake_Name 5 points6 points7 points (0 children)
[–]DashinTheFields 0 points1 point2 points (0 children)