Back to CSS Search Boxes Border Trace Pure CSS
Share
HTML
<form class="csb-trace" role="search">
  <label class="csb-sr" for="csb-trace-i">Search</label>
  <input id="csb-trace-i" type="search" name="q" placeholder="Search..." />
  <span class="csb-trace-tl"></span>
  <span class="csb-trace-br"></span>
</form>
CSS
.csb-trace {
  position: relative; display: inline-block;
  padding: 0;
}
.csb-trace input {
  width: 240px; padding: 11px 14px;
  background: #1a1a28;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: #f0eeff; font: 500 14px/1 system-ui, sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.csb-trace:focus-within input { border-color: transparent; }
.csb-trace input::placeholder { color: #b8b6d4; }
.csb-trace-tl, .csb-trace-br {
  position: absolute; pointer-events: none;
  border-color: #7c6cff;
  border-radius: 8px;
}
.csb-trace-tl {
  top: 0; left: 0;
  width: 0; height: 0;
  border-top: 1.5px solid transparent;
  border-left: 1.5px solid transparent;
}
.csb-trace-br {
  bottom: 0; right: 0;
  width: 0; height: 0;
  border-bottom: 1.5px solid transparent;
  border-right: 1.5px solid transparent;
}
.csb-trace:focus-within .csb-trace-tl {
  width: 100%; height: 100%;
  border-top-color: #7c6cff;
  border-left-color: #7c6cff;
  transition: width 0.25s ease, height 0.25s ease 0.25s;
}
.csb-trace:focus-within .csb-trace-br {
  width: 100%; height: 100%;
  border-bottom-color: #7c6cff;
  border-right-color: #7c6cff;
  transition: width 0.25s ease 0.5s, height 0.25s ease 0.25s;
}

.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;
}