webdevpuneet.com

Shiny Text — Free HTML CSS Animated Shimmer Text Snippet

Shiny Text · Text Animation · Plain HTML, CSS & JS · Live preview

Copy & paste

Source Code

<div class="st-stage">
  <a href="#" class="st-badge"><span class="st-shiny">✨ Introducing v2.0</span><span class="st-arrow">→</span></a>
  <h1 class="st-shiny st-big">Shimmer that sweeps</h1>
  <p class="st-sub">A muted sheen glides across the text on a loop — no JS required for the shine.</p>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

background-clip shine
A gradient painted into the letters.
Moving highlight band
background-position sweeps the sheen.
Seamless loop
Matching gray ends hide the restart.
No pseudo or overlay
Pure color and background, no extra DOM.
Drop-in class
Works on badges, headings, and links.
Reduced-motion safe
Falls back to solid color when requested.
Runtime speed API
Retune the sweep on the fly.
Multi-line friendly
Follows the exact glyph shapes.

About this UI Snippet

Shiny Text — A Sheen That Sweeps Across Muted Text

Screenshot of the Shiny Text snippet rendered live

Shiny text is the subtle shimmer seen on "Introducing" badges and premium headlines: the text sits in a muted gray, and a soft band of light glides across it repeatedly, like a sheen catching the letters. This snippet builds it with pure CSS — no pseudo-elements, no JavaScript for the shine — plus a small script for accessibility and runtime tuning.

A gradient clipped to the text

The shine is a single trick: the text color is set to transparent and filled with a linear-gradient via background-clip: text, so the gradient shows through the letter shapes. The gradient is mostly the muted base gray with a bright white band in the middle, and it is sized at 220% width so there is room to slide. Because background-clip: text paints the gradient into the glyphs, the bright band only appears where there are letters — exactly the sheen effect.

Animating the sweep

The stShine keyframe animates background-position from one side to the other, dragging the bright band across the text on a 3-second linear loop. Since the rest of the gradient is the same muted gray on both ends, the band slides in from one edge and out the other with no visible seam — it reads as a continuous, repeating glint. This is far cheaper than a masked overlay or a JavaScript animation, because only background-position changes and the browser composites it efficiently.

Reusable on any text

The effect is a single class, .st-shiny, applied to whatever you want to shimmer — here both a pill badge and a large headline. Because it only touches color and background, you can drop it onto links, buttons, headings, or inline spans without changing their layout. The demo badge also nudges its arrow on hover, a common pattern for "new feature" announcement chips.

Respecting reduced motion

Continuous shimmer can be distracting, so the script checks prefers-reduced-motion via matchMedia and, when set, removes the animation and restores a solid readable color on every shiny element. This keeps the text legible and calm for users who have asked for less motion — the accessible default for any looping decorative effect.

Runtime control

A tiny window.shinyText.speed(seconds) helper lets you retune the sweep speed at runtime by updating the animation duration on all shiny elements. It is optional — the effect works without any JavaScript — but it is handy if you want the shimmer to speed up on interaction or differ between elements.

Why background-clip over a mask

Some shimmer effects use a moving highlight with mix-blend-mode or a clipped overlay element. Clipping a gradient to the text is simpler and more robust: it needs no extra DOM, automatically follows the exact letter shapes including descenders and serifs, and works on multi-line text. The only caveat is that the text must be transparent, so provide a solid fallback color (as the reduced-motion branch does) for contexts where the clip is unsupported.

Customizing it

Adjust the gradient stops to widen or sharpen the bright band, change the 220% size and the keyframe range to alter how far it travels, retime the loop, or recolor the base and highlight (a gold base with a white band reads as metallic). Pair it with a retro grid hero or a border beam card for a polished announcement.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA badge and headline render in muted gray.
  2. 2
    Watch the shineA band of light sweeps across the text on a loop.
  3. 3
    Hover the badgeThe arrow nudges right like a feature chip.
  4. 4
    Apply it anywhereAdd the st-shiny class to any text.
  5. 5
    Check reduced motionEnable the OS setting and the shimmer turns off.
  6. 6
    Tune the speedCall window.shinyText.speed(seconds).

Real-world uses

Common Use Cases

Announcement badges
Introduce a release near a shimmer button, with muted text and a light band sweeping across it on a loop.
Premium headlines
Shine a title over a retro grid hero, using a clipped gradient painted into the letters with no pseudo-element.
Pricing highlights
Mark a popular tier on a pricing card with a quiet sheen that draws the eye without shouting.
Beta and new chips
Pair with a sticky promo bar so a small label gently animates, with matching grey ends hiding the loop restart.
Calm loading labels
Offer a gentler cousin of an AI thinking loader for labels, respecting reduced-motion preferences by holding perfectly still.

Got questions?

Frequently Asked Questions

The text color is set to transparent and filled with a linear-gradient via background-clip: text, so the gradient only shows through the letter shapes. The gradient is mostly the muted base gray with a bright band in the middle, so the highlight appears only where there are glyphs — that is the sheen.

The stShine keyframe animates background-position across an oversized gradient. Because both ends of the gradient are the same muted gray, the bright band slides in from one edge and out the other with no visible jump, reading as a continuous repeating glint. Only background-position changes, so it composites cheaply.

Clipping a gradient to the text needs no extra DOM, automatically follows the exact letter shapes including descenders, and works across multiple lines. A masked highlight overlay is more elements and harder to align. The one caveat is the text must be transparent, so provide a solid fallback color where the clip is unsupported.

Yes. The script checks prefers-reduced-motion with matchMedia and, when set, removes the animation and restores a solid readable color on every shiny element. Honoring that media query is the accessible default for any looping decorative animation, and it keeps the text legible for users who want less motion.

Make a small ShinyText component that applies the class to its children, and read prefers-reduced-motion in a mount effect to disable the animation when requested. Expose a speed prop that sets animation-duration via inline style. The shine itself is pure CSS. In Tailwind, define the shimmer keyframe in the config and use bg-clip-text with text-transparent and an arbitrary gradient.

Design your website