187

Redacted Text Reveal

£7
or the whole Vault, £99

A redacted text effect for any paragraph, headline, list or table: chosen words sit under hand-drawn marker bars that lift away with a real stroke on hover, drag, tap, keyboard or scroll, revealing the text underneath, or go on as you watch.

advanced
10 more details
text-animationmask-revealhover-effectclick-togglescroll-revealscrubstaggerkeyboard-navigationreduced-motionprogressive-enhancement

Released

About this effect

Ordinary copy with marker redactions, like a declassified document. You choose the words, phrases or whole lines; each one sits under a black bar that looks drawn with a broad chisel-tip marker, and the text under it is real, so it is there to read the moment the bar comes off.

Read the full effect overview

Run the pointer across a bar and the ink lifts away from the side you came in, following your hand; the dry top and bottom edges clear first and the wetter middle lingers for a moment before it goes. Tap or click to toggle one bar, drag across a line to wipe several, sweep the whole page clear or black from a button, or let the bars lift in reading order as the block scrolls into view, scrubbed to the scroll position if you like. Run it the other way and visible text is redacted as you watch, the stroke travelling across each target at the uneven pace of a hand.

Redacted Text Reveal - GSAP animation effect preview

What's included

12 items
  • Hand-drawn bars: chisel-cut ends on a shared slant, wandering edges, a slight tilt, a little overshoot past the word and heavier ink where the stroke starts, different for every bar
  • Long runs show a darker overlap where the stroke doubled back, plus faint dry streaks along its length
  • Ink lifts unevenly along the stroke, dry edges first, and can leave a faint grey ghost on the paper that fades
  • Hover or drag across a bar to wipe it from the side the pointer entered; it stays clear or re-inks when you leave
  • Click, tap, Enter or Space toggles one redaction; Declassify all and Redact all run a staggered sweep
  • Scroll trigger that lifts the bars in reading order, played once or scrubbed to the scroll position
  • Reverse mode that redacts visible text with a travelling marker stroke
  • Spoiler mode hides the text from view, selection, copying and screen readers until revealed; decorative mode keeps it readable to assistive tech
  • One bar per line fragment, rebuilt on resize and after web fonts load
  • Works on spans, paragraphs, headlines, list items and table cells you already have
  • reveal(), redact(), toggle(), setProgress(), refresh() and revert() per instance, with reveal, hide and complete events
  • Native buttons with spoken labels, a polite announcement of the revealed text, cross-fades for reduced motion and full text without JavaScript

Perfect for

4 use cases
  • Quiz answers, puzzle solutions and spoilers that readers uncover one at a time
  • Launch and teaser pages that tease the product name, price or date before revealing it
  • Case studies and editorial features styled as declassified files or leaked memos
  • Pricing or offer copy that reveals the real number with a satisfying wipe

How it works

2 sections

Your text stays in the page exactly as you wrote it. The script measures where each marked passage falls on its lines and draws one ink bar per line fragment into a single overlay for the block, generating every bar's outline, ink density, overlap and edge texture once from a seed, so a resize redraws the same bars in their new places. While a bar is intact its text is not painted, cannot be selected and, in spoiler mode, is hidden from assistive technology.

GSAP drives a single progress value per stroke. As it moves, a ragged lifting edge or a rounded nib edge slides across the bar, which is the only thing that changes while it animates; nothing is blurred or filtered. Pointer input feeds that progress directly, so the ink follows your hand, and the scroll trigger, sweeps and toggles all move the same value. Reduced motion swaps every stroke for a short cross-fade, and one teardown call restores your original markup.

Difficulty Advanced
Includes HTML + JS + CSS source, documentation, AI setup prompt, lifetime updates

Lighthouse, as measured

Google Lighthouse on this effect's demo, from the latest scan. A measurement of the demo as shipped, not a promise for your page.

Accessibility
100
Best practices
100

No performance score, on purpose. That figure depends on how you deploy: your server's compression and caching, your CDN, the connection and the device doing the test, none of which the code controls. The same page can score very differently on two consecutive runs, so measure it where it will live.

The Vault opens this source and the whole library.

Each product gives you the HTML, CSS and JavaScript source, the full documentation and an AI setup prompt, licensed for unlimited personal and commercial projects. Every paid product is tested for desktop and mobile layouts, reduced-motion handling, animation cleanup and keyboard controls wherever there is something to operate.

One payment, over 350 products, and future additions to the library.

Documentation

Quick Start

1. Add to your HTML <head>:

In your downloadThe working code for this step, in index.html.

2. Add before the closing </body> tag:

In your downloadThe working code for this step, in index.html.

3. Mark the words to redact inside a [data-redact-root] container:

In your downloadThe working code for this step, in index.html.

That is all the setup. Hover or drag across a bar to wipe it, click or tap to toggle it, or Tab to it and press Enter.

Using It With Your Own Design

What the effect needs from your markup: one container with data-redact-root, and inside it an element with data-redact around each passage. Use an inline <span data-redact> for a word or phrase, or put data-redact="line" (any value works) on a block such as a <p>, <li> or <td> to redact all of its text. A redacted block should hold inline content only (text, <strong>, <em>, <a>), because the script wraps its children in a span. The container may be any element; if it is position: static the script sets it to relative while it runs and restores it afterwards. Nested redactions are ignored; the outer one wins.

What is only the demo's styling: everything under DEMO in style.css: the memo sheet, Courier Prime and Inter, the meta grid, the classification tag, the cue line and the button styles. Delete it and the bars still draw over your own type at whatever size and line height you use.

CSS the effect depends on (the EFFECT block at the top of style.css):

  • .rdx-layer positions the ink overlay over the container and sets pointer-events: none, so revealed text stays selectable. Its color is the bar colour (--redact-ink).
  • .rdx-target.is-redacted .rdx-text makes text under an intact bar transparent and unselectable. Remove it and text can show through a bar's lighter streaks.
  • .rdx-btn visually hides the button that each redaction gets for keyboard and screen readers; .rdx-focus draws its focus ring around the bar instead.
  • The .has-js ... :not(.rdx-ready) pre-state paints flat bars on spans (and blanks redacted blocks) until fonts have loaded and the real bars are drawn, so the secret text never flashes. It is gated on .has-js, so readers without JavaScript see the full text.
  • Keep an opaque background behind the container (the demo's paper). The bars are drawn in ink only; the ghost and dry streaks assume a light ground.

Options

Set defaults on the container. data-redact-mode and data-redact-label can also go on an individual [data-redact].

Attribute Values Default Description
data-trigger hover, click, scroll, manual hover hover: pointer wipes plus click, tap and keyboard toggles. click: click, tap and keyboard only. scroll: bars move as the container scrolls into view (toggles still work). manual: no input at all, only the API
data-direction reveal, redact reveal reveal starts with bars on and takes them off. redact starts with plain text and draws the bars on
data-scrub true, false, or a number false Scroll trigger only. Ties each stroke to the scroll position in reading order; a number smooths it by that many seconds
data-start / data-end ScrollTrigger positions top 75% / bottom 40% Scroll trigger only. Where the sequence starts and, when scrubbed, ends
data-stagger Seconds 0.09 Delay between redactions in a sweep or scroll sequence
data-duration Seconds 0.6 Length of one average stroke; longer bars take a little longer
data-roughness 0 to 1 0.5 How hand-made the bars look: edge wander, tilt, overshoot, dry streaks and the raggedness of the lifting edge
data-persist true, false true false re-inks a bar shortly after the pointer leaves it (hover), or plays the scroll sequence back when you scroll up past it
data-ghost true, false true A faint grey residue that stays on the paper for a moment after the ink lifts
data-ink Any CSS colour --redact-ink Bar colour for this container (or set --redact-ink in CSS)
data-redact-mode spoiler, decorative spoiler spoiler hides the text from screen readers while it is redacted. decorative keeps it readable to assistive tech regardless
data-redact-label Text text The noun in the button's spoken name: data-redact-label="date" gives "Redacted date, activate to reveal"
data-seed Integer 1 Changes every bar's shape; the same seed draws the same bars after a resize
data-announce true, false true Announce revealed text to screen readers
data-enabled true, false true Skip this container entirely

Static redactions without JavaScript

The class .redact-static paints a CSS-only bar over a span: no motion, no interaction, slightly irregular corners.

In your downloadThe working code for this step, in index.html.

It is purely visual. The text is still in your page source, in search results and, unless you add aria-hidden, read by screen readers, so never use it for anything that must stay secret. The same is true of the animated bars: they hide text from view, not from the HTML. For real secrets, leave the text out of the page.

Accessibility

  • Keyboard: every redaction (except with data-trigger="manual") gets a native <button> in reading order. Tab to it, press Enter or Space to toggle. The focus ring is drawn around the bar itself.
  • Screen readers: the button is named "Redacted text, activate to reveal" (or "Redacted date..." with data-redact-label), then "Revealed text, activate to redact again". In spoiler mode the hidden text is aria-hidden until revealed; a polite live region then reads it out ("Revealed: Tuesday 3 March"). Sweeps announce one summary instead of every word.
  • Selection and copying: text under an intact bar cannot be selected or copied.
  • Touch: tap a bar to toggle it, drag across a line to wipe several. Hit areas are padded beyond the visible bar on touch screens; vertical drags still scroll the page.
  • Reduced motion: with prefers-reduced-motion: reduce every stroke becomes a short cross-fade; hover, tap, keyboard, sweeps and the scroll trigger still work (scrubbing becomes a simple trigger). Changing the preference while the page is open keeps each bar's state.
  • No JavaScript: the full text shows with no bars. That is the deliberate trade-off: without the script nothing could reveal a bar, so hiding text would lose it. Use .redact-static if you want bars regardless.

Dependencies

Required:

  • GSAP 3.12+ (the demo is pinned to 3.15.0)

Optional:

  • ScrollTrigger, only for data-trigger="scroll". Without it a scroll container falls back to click and logs a warning.

No Lenis, no SplitText and no other plugins.

Also in your download: the full source, worked examples, the events and programmatic API, and the class reference.

£7