Reputation: 347
My front end look like this:
I want to display this "Show" button inside my text field but I think due to Form Control, I am unable to do so.
Here is the code from Angular:
Upvotes: 0
Views: 74
Reputation: 461
It's not related to angular.
Just use position: absolute
on your button.
.form-group {
width: 200px;
}
.form-control-wrapper {
position: relative;
}
.show-password-button {
position: absolute;
right: 0;
top: 50%;
transform: translate(0,-50%);
margin-right: 10px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<div class="form-group">
<label>Password</label>
<div class="form-control-wrapper">
<input type="password" formControlName="password" class="form-control">
<button class="show-password-button">Show</button>
</div>
</div>
Upvotes: 1
Reputation: 2604
In order to align the button with the input, you can use flexbox
:
Css:
.container {
display: flex;
justify-content: space-between;
}
HTML:
<div class="form-group">
<label>Password</label>
<div class="container">
<input type="password" class="form-control" />
<button>Show</button>
</div>
</div>
Upvotes: 0