How to change the colour of placeholder and input field of matInput field using of Angular material

How to change the colour of placeholder and input field of matInput field using of Angular material



In my code (see below) I want to set the colour of placeholder i.e Username and Password and a margin below it to white.



Means the Username and password text should be of white colour and border below it should also be of white colour as i am using a dark back-ground colour.



How can I achieve that?



Html


<mat-card class="login">
<form >
<mat-form-field color="accent" autocomplete="off" class="form">
<input class="inputField" maxlength="10" matInput [placeholder][1]="Enter Username" [formControl]="">
</mat-form-field>
<br>
<mat-form-field color="accent" autocomplete="off" class="form">
<input class="inputField" maxlength="10" type="password" matInput placeholder="Enter Password" [formControl]="">
</mat-form-field>
<div>
<button mat-button class="otp-btn" type="submit">Login</button>
</div>
<br>
</form>
</mat-card>



CSS


.example-container
display: flex;
flex-direction: column;


.login
margin-top: 80px;
height: 450px;
max-width: 600px;
margin-left: auto;
margin-right: auto;
background-color: #274c7c

.material-icons
margin-left: 2%;
margin-bottom: 10px;

.otp-btn
margin: 30px 30px 30px 30px;
margin-left: 10%;
width: 80%;
font-size:30px;
height: 55px;
color:white;
border-radius: 10px;
background-color: #f6b319;


:host
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;

img
height: 16%;
width: 174px;
margin-left: 15%;
margin-right: auto;
padding: 10px;

div.input
position: relative;

.form
display: block;
position: relative;
flex: auto;
min-width: 0;
width: 245px !important;
margin-left:15px;

.inputField

width: 90%;
font-size: 20px;


div.input label
position: absolute;
top: 0;
transform: translateY(-50%);
left: 10px;
background: white;
padding: 5px 2px;
color: white;


div.input input
padding: 10px 20px;
font-size: 25px;
outline: 0;
color: white;


div.input
margin-top: 20px;
color: white;



.example-container > *
width: 100%;



See stackBliz for more details.





Possible of duplicate: [stackoverflow.com/questions/41205931/…
– jaydeep patel
Aug 23 at 10:45





Tried to make the question easier to read by moving text before code. Please review my changes and see if further adjustments are necessary.
– GhostCat
Aug 23 at 11:28




1 Answer
1



Add this to css


::ng-deep .mat-form-field-underline, ::ng-deep .mat-form-field-ripple
background-color: white !important;
color: white !important


::ng-deep .mat-form-field-empty.mat-form-field-label
color: white;





How can i able to change the colour of text after animation
– Arpit Aggarwal
Aug 23 at 11:43





Would you change yellow color?
– RikG93
Aug 23 at 13:17





yes i want to make them yellow.
– Arpit Aggarwal
Aug 24 at 4:27





First of all: delete from html color="accent", next add in css ::ng-deep .mat-form-field-ripple background-color: yourcolor;
– RikG93
Aug 24 at 10:07






how to remove html color="accent"
– Arpit Aggarwal
Aug 24 at 12:23







By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)