Words lift out of a blur one after another as the line scrolls into view.
Bars cover the key facts like a classified file, then lift one by one on scroll, hover or click.
Customize
Usage
import { RedactedReveal } from "@/components/motionkit/redacted-reveal";
<RedactedReveal
text="We cut [load time] by [62%] in [six weeks]."
/>Motion
The exact curves this component runs, plotted with Motion's own maths.
Bar lift
Scrolls into view
Teasing results ("we cut [load time] by [62%]"), launch announcements and playful case-study intros.
Wrap the parts to hide in square brackets. Each bracketed part gets a bar on top that scales away to the side on scroll, hover or click, one after another with a stagger. When the reveal waits for the reader, a real button is provided for keyboard users.
Works in the App Router as is. Requires Tailwind CSS v4.
One command adds the file and installs its dependencies. Needs a components.json (run npx shadcn@latest init once if you don't have one).
npx shadcn@latest add https://www.motionkitui.com/r/redacted-reveal.jsonnpm install motionSave as components/motionkit/redacted-reveal.tsx.
"use client";
import { Fragment, useRef, useState, type ElementType } from "react";
import { motion, useInView, useReducedMotion } from "motion/react";
type RedactedRevealProps = {
/** The sentence. Wrap the parts to redact in square brackets: "We cut [load time] by [62%]." */
text: string;
/** "view" lifts the bars on scroll into view; "hover" and "click" wait for the reader. */
trigger?: "view" | "hover" | "click";
/** Bar colour. On a dark page a light bar reads as redaction, as black does on paper. */
barColor?: string;
/** Seconds each bar takes to lift. */
duration?: number;
/** Seconds between one bar and the next. */
stagger?: number;
/** Element to render, e.g. "p". */
as?: ElementType;
className?: string;
};
export function RedactedReveal({
text,
trigger = "view",
barColor = "#F6F1E8",
duration = 0.5,
stagger = 0.25,
as: Tag = "p",
className = "",
}: RedactedRevealProps) {
const ref = useRef<HTMLElement>(null);
const inView = useInView(ref, { once: true, amount: 0.8 });
const reduceMotion = useReducedMotion();
const [asked, setAsked] = useState(false);
const revealed = trigger === "view" ? inView : asked;
// odd entries are the bracketed, redacted parts
const parts = text.split(/\[([^\]]+)\]/);
let barIndex = 0;
const interactive = trigger !== "view" && !revealed;
return (
<Tag
ref={ref}
className={`${className} ${interactive ? "cursor-pointer" : ""}`}
onPointerEnter={trigger === "hover" ? () => setAsked(true) : undefined}
onClick={trigger === "click" ? () => setAsked(true) : undefined}
>
{parts.map((part, i) => {
if (i % 2 === 0) return <Fragment key={i}>{part}</Fragment>;
const delay = barIndex++ * stagger;
return (
<span key={i} className="relative inline-block whitespace-nowrap">
{part}
<motion.span
aria-hidden
className="absolute inset-x-[-0.1em] inset-y-[0.08em] origin-right rounded-[2px]"
style={{ backgroundColor: barColor }}
initial={false}
animate={{ scaleX: revealed ? 0 : 1 }}
transition={{ duration: reduceMotion ? 0 : duration, delay: reduceMotion || !revealed ? 0 : delay, ease: [0.65, 0, 0.35, 1] }}
/>
</span>
);
})}
{/* a real button for keyboard users when the reader has to ask for the reveal */}
{interactive && (
<button type="button" onClick={() => setAsked(true)} className="sr-only focus:not-sr-only focus:ml-2 focus:underline">
Reveal redacted text
</button>
)}
</Tag>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | — | The sentence. Wrap redacted parts in [square brackets]. |
| trigger | "view" | "hover" | "click" | "view" | What lifts the bars. |
| barColor | string | "#F6F1E8" | Bar colour. Light bars read as redaction on a dark page. |
| duration | number | 0.5 | Seconds each bar takes to lift. |
| stagger | number | 0.25 | Seconds between bars. |
| as | ElementType | "p" | Element to render. |
How we audit: the WCAG 2.2 animation checklist and respecting reduced motion in React.
Yes. The file starts with "use client", so you can import it straight into a Server Component page or layout. It works in Vite as is, and in Astro as a React island.
Only the motion package, beside React and Tailwind CSS v4. There is no MotionKit package and no Tailwind config to add.
Yes. Run npx shadcn@latest add https://www.motionkitui.com/r/redacted-reveal.json in any project with a components.json. It saves the file to components/motionkit and installs its dependencies.
With reduced motion on, the bars vanish at once instead of sliding away.
Words lift out of a blur one after another as the line scrolls into view.
Headlines that rise letter by letter, slide up line by line, blur into focus or light up as you scroll.
A heading in dim ink lit by a soft spotlight that follows the cursor, and sweeps across by itself when left alone.
We cut load time by 62% in six weeks.