# Redacted Reveal

> Bars cover the key facts like a classified file, then lift one by one on scroll, hover or click.

Category: Text · Free · Updated 2026-10-20 · Live demo: https://www.motionkitui.com/components/redacted-reveal

## When to use it

Teasing results ("we cut [load time] by [62%]"), launch announcements and playful case-study intros.

## How it works

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.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/redacted-reveal.json
```

Or copy `components/motionkit/redacted-reveal.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| 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. |

## Accessibility

- **Keyboard: Pass.** When the reveal waits for hover or click, a Reveal button appears for keyboard users.
- **Screen readers: Pass.** The covered words are real text and are always read in full.
- **Reduced motion: Pass.** With reduced motion on, the bars vanish at once instead of sliding away.
- **Colour contrast: Not applicable.** Uses whatever text colour you pass in className.

## Source

```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>
  );
}
```
