Skip to content

Instantly share code, notes, and snippets.

@unqownexe
Created November 17, 2022 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unqownexe/2ac48611a3ba25f03180f41c0037d743 to your computer and use it in GitHub Desktop.
Save unqownexe/2ac48611a3ba25f03180f41c0037d743 to your computer and use it in GitHub Desktop.
Input Text Material with Gradient
<div class="form__group field">
<input type="input" class="form__field" placeholder="Name" name="name" id='name' required />
<label for="name" class="form__label">Name</label>
</div>
$primary: #11998e;
$secondary: #38ef7d;
$white: #fff;
$gray: #9b9b9b;
.form__group {
position: relative;
padding: 15px 0 0;
margin-top: 10px;
width: 50%;
}
.form__field {
font-family: inherit;
width: 100%;
border: 0;
border-bottom: 2px solid $gray;
outline: 0;
font-size: 1.3rem;
color: $white;
padding: 7px 0;
background: transparent;
transition: border-color 0.2s;
&::placeholder {
color: transparent;
}
&:placeholder-shown ~ .form__label {
font-size: 1.3rem;
cursor: text;
top: 20px;
}
}
.form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: $gray;
}
.form__field:focus {
~ .form__label {
position: absolute;
top: 0;
display: block;
transition: 0.2s;
font-size: 1rem;
color: $primary;
font-weight:700;
}
padding-bottom: 6px;
font-weight: 700;
border-width: 3px;
border-image: linear-gradient(to right, $primary,$secondary);
border-image-slice: 1;
}
/* reset input */
.form__field{
&:required,&:invalid { box-shadow:none; }
}
/* demo */
body {
font-family: 'Poppins', sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
font-size: 1.5rem;
background-color:#222222;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment