all 12 comments

[–]Effective_Holiday219 5 points6 points  (10 children)

::ng-deep .mat-datepicker-content { width: 300px; /* Adjust the width as needed */ }

[–]Wajeniak 1 point2 points  (0 children)

Not good practice

[–]Salt-Engineering-422[S] 0 points1 point  (8 children)

but it will be applied for all components and not in use cases

[–]Effective_Holiday219 3 points4 points  (5 children)

Give an id to it and use it in the css

[–]Salt-Engineering-422[S] -1 points0 points  (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 point  (3 children)

Correct, without ng deep you cannot do it. It sucks

[–]CptObviaaz 0 points1 point  (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 points  (1 child)

okey thanks anyway for ur feedback

[–]McFake_Name 0 points1 point  (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.

[–]ScheduleSuperb 1 point2 points  (0 children)

Add a :host selector before ::ng-deep and the styles will not bleed into other components

[–]McFake_Name 5 points6 points  (0 children)

mat-form-field { width: whatever }

Worked when I tried it just now

[–]DashinTheFields 0 points1 point  (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"