All effectsPlay & loop

Neon Flicker

霓虹闪烁

Glowing tube letters briefly dim and relight at irregular intervals like an old neon sign.

Play the demo to see the sign flicker

Where to use it

Style short headlines for nightlife, event, or retro-themed pages. Keep the outline readable through each dip in brightness and let the sign settle between brief, low-frequency flickers.

Practical example

A late-night cinema adds a pink tube glow to its “Now Showing” headline. One small section occasionally dims while the screening times stay steady.

Also called

  • Neon Sign

AI prompt

Style [headline] as Neon Flicker. Give the letters a tube glow that dims briefly and returns at irregular intervals. Keep the flashes subtle and sparse. Provide a steady glow for 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>Neon Flicker</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;
    }

    .demo { position: relative; padding: 0; }
    .showcase { position: absolute; inset: 0; isolation: isolate; overflow: hidden; }
    .showcase .demo-button {
      position: absolute;
      z-index: 3;
      bottom: 10px;
      left: 50%;
      transform: translateX(-50%);
      border-radius: 999px;
      background: #101026d9;
      color: #f1efff;
      white-space: nowrap;
    }
    .showcase :is(h1, p) { margin: 0; }
    .scene-copy {
      position: absolute;
      z-index: 1;
      inset: 0;
      display: grid;
      place-content: center;
      padding: 14px;
      text-align: center;
      pointer-events: none;
    }
    .scene-copy h1 {
      font-size: clamp(25px, 8vw, 62px);
      line-height: 1;
      letter-spacing: -.045em;
    }
    .showcase [data-motion] { animation-play-state: paused; }
    .showcase[data-playing] [data-motion] { animation-play-state: running; }
    @media (prefers-reduced-motion: reduce) {
      .showcase [data-motion] { animation: none; }
      .showcase [data-loop-toggle] { display: none; }
    }

    .showcase {
      background:
        radial-gradient(ellipse at center, #462331, transparent 74%),
        repeating-linear-gradient(0deg, #1f1a25 0 2px, transparent 2px 28px),
        repeating-linear-gradient(90deg, #261f2a 0 2px, transparent 2px 54px), #181720;
    }
    .neon-sign {
      position: absolute;
      inset: 50% auto auto 50%;
      transform: translate(-50%, -50%) rotate(-4deg);
      width: max-content;
      max-width: calc(100% - 42px);
      padding: clamp(10px, 3vw, 22px) clamp(17px, 6vw, 40px);
      border: 2px solid #ffba99;
      border-radius: clamp(13px, 4vw, 25px);
      box-shadow: 0 0 6px #ff845e, 0 0 26px #fc4f547d, inset 0 0 16px #fa625a60;
      color: #fff2dd;
      text-shadow: 0 0 4px #fbb495, 0 0 11px #ff9360, 0 0 24px #df5946, 0 0 42px #e56351;
      animation: uneven-power 8.7s linear infinite;
      animation-delay: -.65s;
    }
    .neon-sign h1 {
      font-family: Georgia, "Times New Roman", serif;
      font-size: clamp(26px, 10vw, 71px);
      font-weight: 400;
      font-style: italic;
      letter-spacing: -.022em;
      white-space: nowrap;
    }
    .neon-sign h1:lang(zh) { font-size: clamp(23px, 8vw, 56px); font-family: serif; }
    @keyframes uneven-power {
      0%, 22%, 24%, 66%, 69%, 100% { opacity: 1; }
      22.4%, 66.8% { opacity: .29; }
      23.2% { opacity: .76; }
      68.2% { opacity: .59; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="showcase">
      <div class="neon-sign" data-motion>
      <h1>Open late</h1>
    </div>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">Play demo</button>
    </div>
  </main>
  <script>
    const showcase = document.querySelector('.showcase');
    const toggle = showcase.querySelector('[data-loop-toggle]');
    const preference = matchMedia('(prefers-reduced-motion: reduce)');
    let playing = false;



    function syncPlayback() {
      if (preference.matches) playing = false;
      const active = playing && !document.hidden;
      showcase.toggleAttribute('data-playing', active);
      toggle.textContent = playing ? "Pause demo" : "Play demo";
      
    }

    toggle.addEventListener('click', () => {
      playing = !playing;
      syncPlayback();
    });
    preference.addEventListener('change', syncPlayback);
    document.addEventListener('visibilitychange', syncPlayback);
  </script>
</body>
</html>

Original example by UI Skills