I'm having trouble creating an input label similar to the new Google style. However, when the label moves up, it gets cut in the middle as shown here.
Despite trying to adjust the margin, padding, and Z-index, none of these solutions have resolved my issue.
I am not utilizing the default ionic classes because they do not align well with my design preferences.
How can I achieve a label display similar to Google's input style?
Here is my SCSS code:
.invalid {
border: 2px solid #f53d3d !important;
}
.danger {
color: #f53d3d;
}
.item-input {
margin-top: 5px;
&.invalid {
color: red;
}
}
ion-label.google-label {
color: #fff;
background-color: #3880ff;
font-size: 12px;
margin-left: 10px !important;
padding-left: 4px !important;
padding-right: 4px !important;
position: absolute !important;
margin-bottom: 5px !important;
z-index: 9;
}
ion-input.google-input {
padding-top: 10px !important;
color: white;
border: 2px solid white;
width: 100%;
max-width: 100%;
padding-left: 10px !important;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
item-label-floating {
&.ion-invalid.ion-touched {
.google-label {
color: #f53d3d !important;
}
}
...
<p>And here is my HTML code:</p>
<pre><code><ion-item lines="none">
<ion-label class="google-label" position="floating" [class.danger]="showErrors('email')">
E-Mail
</ion-label>
<ion-input formControlName="email" class="google-input" [class.invalid]="showErrors('email')" type="text">
</ion-input>
</ion-item>
I expected the label to appear like this: