Word Flip Hero — Animated Cycling Headline HTML CSS JS

Word Flip Hero · Heroes · Plain HTML, CSS & JS · Live preview

Share & Support

What's included

Features

Vertical column word cycling
Words stack in a flex column inside an overflow:hidden clip window. JS sets translateY(-idx * wordHeight) — runtime height measurement means variable word lengths work with zero config.
Gradient text clip
Cycling words use background-clip: text + -webkit-text-fill-color: transparent for an indigo-to-violet gradient sweep — the standard cross-browser gradient typography technique.
Smooth cubic-bezier transition
cubic-bezier(0.77,0,0.18,1) gives the slide an aggressive start and smooth landing — cinematic feel without being distracting during reading.
Pulsing live indicator
A green dot in the eyebrow badge pulses with a box-shadow keyframe animation — a standard "live" or "status" indicator communicating product activity.
Social proof avatar stack
Four overlapping avatar circles with negative margin overlap and a count label — communicates community adoption without requiring actual profile photos.
ARIA live region
The .flip-wrap has aria-live="polite" so screen readers announce each new word after it transitions in — accessible cycling animation.
Gradient CTA buttons
Primary button uses an indigo-violet gradient with box-shadow glow that intensifies on hover. Ghost button uses a glass-style background for hierarchy differentiation.
Responsive flex layout
Content and code window use flex-wrap: wrap and min-width — on narrow screens they stack vertically. The headline uses clamp(36px,6vw,64px) for fluid font sizing.

About this UI Snippet

Word Flip Hero — CSS Transform Word Cycling, Gradient Text Clip & Social Proof Layout

Screenshot of the Word Flip Hero snippet rendered live

The word-flip hero is one of the most recognisable patterns in modern SaaS and startup landing pages — a headline where a single key word cycles through several alternatives, demonstrating the product's versatility without needing multiple pages. This snippet builds a production-quality word-flip hero: a stacked flex column of words animating vertically with translateY, gradient text clipping on the cycled words, a dual-CTA button row, social proof avatars, and a decorative code window — all in pure HTML, CSS, and minimal JavaScript.

The animated headline technique communicates product breadth in a single sentence: "Build Faster / Smarter / Better / Together" — each word reframes the same value proposition for a different user persona. The visual variety keeps the hero from feeling static while the core message stays readable between transitions.

The word column slide mechanism

All words are stacked in a vertical flex column (flex-direction: column) inside a overflow: hidden container sized to exactly one word's line height (1.1em). JavaScript measures one word's actual pixel height and sets translateY(-idx * height) on the column — shifting the visible window to show the current word. The CSS transition: transform .55s cubic-bezier(0.77,0,0.18,1) gives the slide an aggressive ease-in / smooth-out feel that matches the hero's energetic tone.

Unlike CSS @keyframes cycling approaches, this method works with variable-length words because the height is measured at runtime. Adding a new word to the cycle is a pure HTML change — no CSS or JS constants to update.

Gradient text clipping

The cycling words use background: linear-gradient(90deg, #818cf8, #c084fc) clipped to the text via -webkit-background-clip: text and -webkit-text-fill-color: transparent. This is the standard CSS technique for gradient typography — supported in all modern browsers. The gradient sweeps left-to-right from indigo to violet, matching the CTA button gradient for visual coherence.

Social proof avatar stack

Four overlapping avatar circles use negative margin-left: -6px to create the stacked overlap effect. Each avatar is a colour-coded <div> with a letter initial — a practical pattern for user-generated or developer-tool contexts where actual profile photos are rarely available at build time.

Decorative code window

The right side of the hero shows a dark code editor window with syntax-coloured HTML spans, a macOS-style traffic-light dot bar, and a "Copied to clipboard" success indicator. This communicates the product's developer focus without needing a screenshot and remains crisp at all screen densities. Pair with a parallax hero for a more visually dynamic full-screen background effect.

Step by step

How to Use

  1. 1
    Paste the three blocksA dark hero renders with the cycling headline "Build Faster / Smarter / Better / Together", a subheading, two CTA buttons, social proof avatars, and a code window decoration.
  2. 2
    Watch the word cycleEvery 2.2 seconds the highlighted word slides up and the next one appears with a smooth cubic-bezier transition. The gradient text colour adds visual contrast against the white headline.
  3. 3
    Change the word listEdit the WORDS array in JS and the corresponding .flip-word spans in HTML. Add or remove words freely — the height measurement adapts automatically.
  4. 4
    Update the headline textChange "Build" to any verb that matches your product ("Design", "Deploy", "Automate"). The <span class="flip-wrap"> sits inline so the static and dynamic parts flow together.
  5. 5
    Customise CTAsUpdate the button text, href values, and gradient colours to match your brand. The primary button uses an indigo-violet gradient — change via CSS background on .btn-primary.
  6. 6
    Replace the code windowSwap the .code-body content with a screenshot, illustration, or product UI preview. The window frame (traffic-light dots, dark background, border) works as a generic content container.

Real-world uses

Common Use Cases

SaaS and startup landing pages
The primary use case — "Build [Faster/Smarter/Better]" communicates product versatility to multiple personas in one headline. Common in developer tools, productivity apps, and platforms.
Portfolio hero sections
"I design [Interfaces/Experiences/Products]" or "I build [Websites/Apps/APIs]" — the cycling words let freelancers address multiple client types with a single headline.
Agency and studio homepages
"We craft [Brands/Products/Campaigns]" positions the agency across service verticals without separate landing pages per service.
Product feature showcases
Cycle through product benefits: "Automate [Reporting/Billing/Onboarding]". Each word links to a feature section below. Pair with a scroll progress indicator.
Job posting and HR platforms
"Find [Developers/Designers/Marketers]" on a talent platform homepage — cycling words cover all candidate types without separate hero sections per category.
App store and download pages
Mobile app landing pages use word-flip heroes to cycle through user benefits above the download button, covering diverse app store search intents.

Got questions?

Frequently Asked Questions

Change the DURATION constant in the JS (default 2200ms). Also update the CSS transition duration on .flip-track to something shorter than DURATION so the animation completes before the next word arrives.

Replace the translateY approach with CSS animations: set each word to position: absolute in the container, opacity: 0, and apply a @keyframes that fades in, pauses, and fades out. Use animation-delay to stagger each word. The container height should be set to match one word's height.

Store the current index in const [idx, setIdx] = useState(0). The interval becomes useEffect(() => { const t = setInterval(() => setIdx(i => (i+1) % WORDS.length), 2200); return () => clearInterval(t); }, []). Apply style={{ transform: translateY(-${idx * wordHeight}px) }} to the track ref.

Use the Page Visibility API: document.addEventListener('visibilitychange', () => { if (document.hidden) clearInterval(timer); else startCycle(); }). This saves CPU when the user switches tabs.