New Google Floating Style

Hello Everyone I’m desperated, my client asks me for a new input style as the google style I’m almos there, but I’m with a big problem on the overflow as you can see:

All the colors are changing correctly, but the label is being cutted in the middle. Can anyone help me please? I’ve tryed to use overflow: visible; padding-top, margin and nothing :confused:

Thats My SCSS:

* {
  --background-focused: transparent;
}
ion-toolbar {
  --background: #3880ff !important;
  --color: #fff !important;
}

#menu_header {
  --background: #3880ff !important;
  --color: #fff !important;
}
#avatar_menu {
  margin-right: 10px !important;
}

.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;
    }
    .google-input {
      border: 2px solid #f53d3d !important;
    }
  }
  &.item-has-value {
    .google-label {
      padding-left: 4px !important;
      padding-right: 4px !important;
      color: #062f77 !important;
      -webkit-transform: translate3d(0, -50%, 0) !important;
      transform: translate3d(0, -50%, 0) !important;
      -webkit-transform-origin: left top;
      transform-origin: left top;
      -webkit-transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      &.invalid {
        .google-label {
          color: #f53d3d !important;
        }
        .google-input {
          border: 2px solid #f53d3d !important;
        }
      }
    }

    &.ion-valid.ion-touched {
      .google-label {
        color: #fff !important;
      }
    }
  }
  &.item-has-focus {
    .google-label {
      padding-left: 4px !important;
      padding-right: 4px !important;
      color: #062f77 !important;
      -webkit-transform: translate3d(0, -50%, 0) !important;
      transform: translate3d(0, -50%, 0) !important;
      -webkit-transform-origin: left top;
      transform-origin: left top;
      -webkit-transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
      transition: color 0.15s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        -webkit-transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .google-input {
      border: 2px solid #062f77;
    }
    &.invalid {
      .google-label {
        color: #f53d3d !important;
      }
      .google-input {
        border: 2px solid #f53d3d !important;
      }
    }

    &.ion-valid.ion-touched {
      .google-label {
        color: #062f77 !important;
      }
    }
  }
}
        <ion-item lines="none" [class.invalid]="showErrors('email')">
          <ion-label class="google-label" position="floating">
            E-Mail
          </ion-label>
          <ion-input formControlName="email" class="google-input" type="text">
          </ion-input>
        </ion-item>

I’ve solved it using this

.label-float {
  position: relative;
  padding-top: 13px;
  &.invalid {
    label {
      color: #f53d3d !important;
    }
    input {
      border: 2px solid #f53d3d !important;
    }
  }

  input {
    background-color: transparent;
    border: 2px solid #fff;
    border-radius: 5px;
    outline: none;
    min-width: 250px;
    padding: 15px 20px;
    font-size: 16px;
    transition: all 0.1s linear;
    -webkit-transition: all 0.1s linear;
    -moz-transition: all 0.1s linear;
    -webkit-appearance: none;
    &:focus {
      border: 2px solid #3951b2;
    }
    &::placeholder {
      color: transparent;
    }
  }
  label {
    color: #fff;
    pointer-events: none;
    position: absolute;
    top: calc(50% - 8px);
    left: 20px;
    transition: all 0.1s linear;
    -webkit-transition: all 0.1s linear;
    -moz-transition: all 0.1s linear;
    background-color: #3880ff;
    padding-top: 5px;
    margin-left: 10px;
    padding-left: 4px;
    padding-right: 4px;
    box-sizing: border-box;
  }
}

.label-float input:focus + label,
input:not(:placeholder-shown):not(.invalid) + label {
  font-size: 13px;
  top: 0;
  color: #3951b2;
}
.label-float input:not(:focus):not(:placeholder-shown):not(.invalid) + label {
  font-size: 13px;
  top: 0;
  color: #fff;
}
 <div class="label-float" [class.invalid]="showErrors('email')">
              <input type="text" formControlName="email" placeholder=" " />
              <label>E-Mail</label>
            </div>
2 Likes

awesome. thanks so much for posting! works great