All effectsPlay & loop

Equalizer Bars

律动频谱柱

Bars rise and fall at different heights in a beat-like rhythm.

Play or pause the demo

Where to use it

Indicate that an audio preview is playing or visualize a simple beat. Keep the bars tied to the active player and use measured audio levels when the columns are meant to represent sound.

Practical example

In a podcast inbox, tapping a voice excerpt makes a few bars beside that clip rise with its audio level. The bars settle when the listener pauses, making it easy to spot the active clip in a long list.

AI prompt

Create Equalizer Bars for [target audio indicator]. Use transform scaleY with bottom origin. Assign each bar a phase and a different range, and drive it from sampled levels for accurate playback. Pause when audio stops and show stable bars with reduced motion.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Equalizer Bars</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .meter-bars { width: 133px; height: 78px; display: flex; justify-content: center; align-items: end; gap: 5px; padding-bottom: 5px; border-bottom: 1px solid #63d9b88c; }
    .meter-bars i {
      width: 9px; height: 61px; transform: scaleY(var(--rest, .54)); transform-origin: bottom;
      background: linear-gradient(#dbf8ad, #64caad); border-radius: 3px;
      animation: equalize .92s ease-in-out infinite alternate;
    }
    .meter-bars i:nth-child(2n) { --rest: .32; --high: .83; animation-delay: -.47s; }
    .meter-bars i:nth-child(3n) { --rest: .77; --high: 1; animation-delay: -.73s; }
    .meter-bars i:nth-child(4n) { --rest: .44; --high: .67; animation-duration: .68s; }
    @keyframes equalize { 0% { transform: scaleY(var(--rest, .54)); } 100% { transform: scaleY(var(--high, .96)); } }

    .motion-example { display: grid; justify-items: center; width: 100%; gap: 10px; }
    .motion-specimen {
      display: grid;
      place-items: center;
      width: min(100%, 295px);
      height: 108px;
      position: relative;
      isolation: isolate;
    }
    .motion-example [data-motion] { animation-play-state: paused; }
    .motion-example[data-playing] [data-motion] { animation-play-state: running; }
    @media (prefers-reduced-motion: reduce) {
      .motion-example [data-motion] { animation: none; }
      .motion-example [data-loop-toggle] { display: none; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="motion-example">
      <div class="motion-specimen" aria-hidden="true"><div class="meter-bars"><i data-motion></i><i data-motion></i><i data-motion></i><i data-motion></i><i data-motion></i><i data-motion></i><i data-motion></i></div></div>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">Play demo</button>
    </div>
  </main>
  <script>
    const example = document.querySelector('.motion-example');
    const toggle = example.querySelector('[data-loop-toggle]');

    toggle.addEventListener('click', () => {
      const playing = example.toggleAttribute('data-playing');
      toggle.textContent = playing ? "Pause demo" : "Play demo";
    });
  </script>
</body>
</html>

Original example by UI Skills