32 CSS Search Box & Search Bar Designs
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.
Caret Highlight the 6th of 32 designs in the 32 CSS Search Box & Search Bar 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
<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;
}
}