32 CSS Search Box & Search Bar Designs 06 / 32
Caret Highlight
On focus, a single accent line sweeps left-to-right across the bottom of the input — a one-shot reveal that signals "this field is active" without any perpetual motion.
The code
<form class="csb-caret" role="search"> <label class="csb-sr" for="csb-caret-i">Search</label> <input id="csb-caret-i" type="search" name="q" placeholder="Search collections..." /> </form>
<form class="csb-caret" role="search">
<label class="csb-sr" for="csb-caret-i">Search</label>
<input id="csb-caret-i" type="search" name="q" placeholder="Search collections..." />
</form>.csb-caret {
position: relative; display: inline-block;
overflow: hidden;
border-radius: 10px;
}
.csb-caret input {
display: block; width: 240px;
padding: 11px 14px;
background: #1a1a28;
border: 1px solid rgba(255,255,255,0.08);
border-radius: 10px;
color: #f0eeff; font: 500 14px/1 system-ui, sans-serif;
outline: none;
transition: border-color 0.2s;
}
.csb-caret input::placeholder { color: #b8b6d4; }
.csb-caret:focus-within input { border-color: #7c6cff; }
.csb-caret::after {
content: ''; position: absolute;
left: 0; bottom: 0;
height: 2px; width: 100%;
background: linear-gradient(90deg, transparent, #7c6cff 40%, #ff6c8a 60%, transparent);
transform: translateX(-100%);
pointer-events: none;
}
.csb-caret:focus-within::after {
animation: csb-caret-sweep 0.7s cubic-bezier(0.65,0,0.35,1) forwards;
}
@keyframes csb-caret-sweep {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
.csb-sr {
position: absolute !important;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (prefers-reduced-motion: reduce) {
.csb-caret,
.csb-caret * {
animation: none !important;
}
}
.csb-caret {
position: relative; display: inline-block;
overflow: hidden;
border-radius: 10px;
}
.csb-caret input {
display: block; width: 240px;
padding: 11px 14px;
background: #1a1a28;
border: 1px solid rgba(255,255,255,0.08);
border-radius: 10px;
color: #f0eeff; font: 500 14px/1 system-ui, sans-serif;
outline: none;
transition: border-color 0.2s;
}
.csb-caret input::placeholder { color: #b8b6d4; }
.csb-caret:focus-within input { border-color: #7c6cff; }
.csb-caret::after {
content: ''; position: absolute;
left: 0; bottom: 0;
height: 2px; width: 100%;
background: linear-gradient(90deg, transparent, #7c6cff 40%, #ff6c8a 60%, transparent);
transform: translateX(-100%);
pointer-events: none;
}
.csb-caret:focus-within::after {
animation: csb-caret-sweep 0.7s cubic-bezier(0.65,0,0.35,1) forwards;
}
@keyframes csb-caret-sweep {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
.csb-sr {
position: absolute !important;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
@media (prefers-reduced-motion: reduce) {
.csb-caret,
.csb-caret * {
animation: none !important;
}
}