Components: mat-form-field width specifity

Created on 22 Sep 2017  路  5Comments  路  Source: angular/components

Bug, feature request, or proposal:

The current solution with defined width on .mat-form-field class makes it harder to style components. E.g. I cannot use bootstrap way to specify width with selectors like "col-xs-14" on components, because it has the same level of specificity.

What is the expected behavior?

Leave the decision about components width to developers and remove the width property on the .mat-form-field class

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

angular: 4.4.3
material: 2.0.0-beta.11

has pr

Most helpful comment

Just Add this , it works for me
::ng-deep .mat-form-fiel .mat-form-field-infix

All 5 comments

Just Add this , it works for me
::ng-deep .mat-form-fiel .mat-form-field-infix

Just Add this , it works for me
::ng-deep .mat-form-fiel .mat-form-field-infix

We have used this in the past, but ::ng-deep is being deprecated. I am also running into an issue where the style rules stick around after I navigate off the component using the router's navigate command and go to a previous component and it messes up form fields on that component. Landed here looking for a solution or replacement for the ::ng-deep

Just Add this , it works for me
::ng-deep .mat-form-fiel .mat-form-field-infix

We have used this in the past, but ::ng-deep is being deprecated. I am also running into an issue where the style rules stick around after I navigate off the component using the router's navigate command and go to a previous component and it messes up form fields on that component. Landed here looking for a solution or replacement for the ::ng-deep

When you use ng-deep, the final css rule will not include the component encapsulation selector (the attribute selector added to each component).

The easy fix is to define your own specific selector. for example:

.my-selector ::ng-deep {
[your style here]
}

This way it will not affect other pages (unless you also use the same selector in them).

You can also wrap it with the :host selector:

:host ::ng-deep {
[your style 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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelb-01 picture michaelb-01  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

alanpurple picture alanpurple  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

RoxKilly picture RoxKilly  路  3Comments