skip to content
mpkcn

~/components/reveal

Reveal

Fade and slide content in as it scrolls into view. Stays still under reduced motion.

$ reveal --from up

rises into place

$ reveal --from left

slides in from the left

$ reveal --from right

slides in from the right

$ reveal --from scale

grows from 94%

Installation

terminal
npx mpkcn add reveal
deps:framer-motion@13.4.4· tested with react@19.3.0

Usage

Wrap anything that should appear as it scrolls into view:

tsx
import { Reveal } from "@/components/mpkcn/reveal";

export function Features() {
  return (
    <section className="grid gap-4 sm:grid-cols-3">
      <Reveal>
        <Card title="Copy" />
      </Reveal>
      <Reveal delay={0.1}>
        <Card title="Paste" />
      </Reveal>
      <Reveal delay={0.2}>
        <Card title="Own" />
      </Reveal>
    </section>
  );
}

The content fades in over 0.7s with the ease [0.22, 1, 0.36, 1] once 20% of it is visible. Reveal is a client component, but its children can be server components.

Examples

Directions

from sets where the content comes from: up (default), left, right or scale.

$ reveal --from up

rises into place

$ reveal --from left

slides in from the left

$ reveal --from right

slides in from the right

$ reveal --from scale

grows from 94%

Stagger a list

Give each item a growing delay to cascade them:

tsx
{items.map((item, i) => (
  <Reveal key={item.id} delay={i * 0.08}>
    <Row item={item} />
  </Reveal>
))}

Replay on every scroll

By default an element animates only the first time it enters the viewport. Set once={false} to animate it every time it comes back into view.

tsx
<Reveal from="scale" once={false}>
  <Stat value="99.9%" label="uptime" />
</Reveal>

Props

PropTypeDefaultDescription
childrenReact.ReactNode—Content to reveal.
from"up" | "left" | "right" | "scale""up"Direction the content comes in from.
delaynumber0Delay before the animation starts, in seconds.
oncebooleantrueAnimate only the first time it scrolls into view.
ignoreReducedMotionbooleanfalseAnimate even when the user prefers reduced motion. Only use it behind an explicit action, like a "play anyway" button.
classNamestring—Extra classes for the wrapper div.

Accessibility

  • Under prefers-reduced-motion: reduce nothing moves: position and scale snap into place and only the opacity fades. ignoreReducedMotion overrides this; keep it behind an explicit user action.
  • The wrapper is a plain div with no role, so the content is read exactly as written.
  • Server and client render the same markup, so there is no hydration mismatch.