Underline Sweep
Minimal underline-style input. The bottom border draws outward from the centre on focus — a subtle, premium touch driven by `:focus-within`.
Underline Sweep the 2nd of 28 designs in the 28 CSS Input Field Designs collection. The design is implemented in pure CSS — no JavaScript required. Copy the HTML and CSS panels below into your project. Because the demo is pure CSS, it works in any framework or templating engine you happen to use. The design honours prefers-reduced-motion and uses real semantic markup, so it ships accessibility-ready out of the box.
Live preview
The code
<label class="if-line">
<span class="if-line-label">Username</span>
<span class="if-line-wrap">
<input type="text" name="username" autocomplete="username" placeholder="@codefronts" required />
</span>
</label> .if-line {
display: grid;
gap: 6px;
width: 100%;
max-width: 280px;
font-size: 11px;
color: #b8b6d4;
text-transform: uppercase;
letter-spacing: 0.08em;
}
.if-line-wrap {
position: relative;
display: block;
border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.if-line-wrap::after {
content: "";
position: absolute;
left: 50%;
right: 50%;
bottom: -1px;
height: 2px;
background: linear-gradient(90deg, #ff6c8a, #ff9a76);
transition:
left 0.3s ease,
right 0.3s ease;
}
.if-line-wrap:focus-within::after {
left: 0;
right: 0;
}
.if-line input {
width: 100%;
box-sizing: border-box;
padding: 8px 0 9px;
background: transparent;
border: 0;
outline: none;
color: #f0eeff;
font-size: 14px;
letter-spacing: 0;
text-transform: none;
}
.if-line input::placeholder {
color: #b8b6d4;
}