HTML
<form class="csb-voice" role="search">
<label class="csb-sr" for="csb-voice-i">Search by voice</label>
<input id="csb-voice-i" type="search" name="q" placeholder="Speak to search..." />
<button type="button" class="csb-voice-mic" aria-label="Start voice input" aria-pressed="false">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="9" y="3" width="6" height="11" rx="3" />
<path d="M5 11a7 7 0 0 0 14 0M12 18v3" />
</svg>
</button>
</form> CSS
.csb-voice {
display: inline-flex; align-items: center;
background: #1a1a28;
border: 1px solid rgba(255,255,255,0.08);
border-radius: 10px;
padding: 4px;
}
.csb-voice:focus-within { border-color: #7c6cff; }
.csb-voice input {
flex: 1; min-width: 180px; padding: 8px 12px;
border: 0; outline: none; background: transparent;
color: #f0eeff; font: 500 13px/1 system-ui, sans-serif;
}
.csb-voice input::placeholder { color: #b8b6d4; }
.csb-voice-mic {
width: 34px; height: 34px;
border: 0; cursor: pointer;
background: transparent;
border-radius: 8px;
display: flex; align-items: center; justify-content: center;
position: relative;
transition: background 0.2s;
}
.csb-voice-mic:hover { background: rgba(124,108,255,0.08); }
.csb-voice-mic svg { width: 16px; height: 16px; fill: none; stroke: #a78bfa; stroke-width: 2; stroke-linecap: round; }
.csb-voice-mic[aria-pressed="true"] svg { stroke: #ff6c8a; }
.csb-voice-mic[aria-pressed="true"]::after {
content: ''; position: absolute; inset: 4px;
border-radius: 6px; border: 1.5px solid #ff6c8a;
animation: csb-voice-pulse 1.2s ease-out infinite;
}
@keyframes csb-voice-pulse {
0% { transform: scale(0.8); opacity: 1; }
100% { transform: scale(1.4); opacity: 0; }
}
.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-voice,
.csb-voice * {
animation: none !important;
}
}
JS
document.querySelectorAll('.csb-voice-mic').forEach(function(btn) {
btn.addEventListener('click', function() {
var on = btn.getAttribute('aria-pressed') === 'true';
btn.setAttribute('aria-pressed', on ? 'false' : 'true');
});
});