About this snippet

Visualize sound or voice activity with this CSS-only animation. The bars oscillate randomly using different animation durations, which creates a convincing audio wave effect perfect for music players or voice note UIs.

Size
1.0 KB
Uses
HTML, CSS
Loads
Nothing external
Views
1,754
<div class="audio-wave">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>
* { box-sizing: border-box; }
body {
  background: #0f172a;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.audio-wave {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 60px;
}

.audio-wave span {
  display: block;
  width: 6px;
  height: 100%;
  background: #3b82f6;
  border-radius: 50px;
  animation: wave 1.2s ease-in-out infinite;
}

/* Vary animation delays and durations for randomness */
.audio-wave span:nth-child(1) { animation-duration: 0.8s; height: 40%; }
.audio-wave span:nth-child(2) { animation-duration: 1.1s; height: 70%; }
.audio-wave span:nth-child(3) { animation-duration: 1.3s; height: 100%; }
.audio-wave span:nth-child(4) { animation-duration: 0.9s; height: 60%; }
.audio-wave span:nth-child(5) { animation-duration: 1.0s; height: 50%; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); background: #3b82f6; }
  50% { transform: scaleY(1); background: #60a5fa; }
}
Esc
↑↓ moveEnter select

Start from a template

Open an .html file, or HTML, CSS, JS, Markdown, Less or TypeScript files. You can also drop them here. Styles and scripts go into their panes.

Share

Source

Keyboard shortcuts

Save