Reveal

A wrapper whose children rise into place one after another the first time it scrolls into view.

Item 1
Item 2
Item 3
import { Reveal } from "@produkto/ui/Reveal";

const items: string[] = ["Item 1", "Item 2", "Item 3"];

const Example = () => (
  <Reveal className="flex w-full max-w-sm flex-col gap-2">
    {items.map((item) => (
      <div
        className="rounded-xl border border-border bg-card p-4 body-sm"
        key={item}
      >
        {item}
      </div>
    ))}
  </Reveal>
);

export default Example;

Usage

import { Reveal } from "@produkto/ui/Reveal";
<Reveal className="flex flex-col gap-2">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</Reveal>

Examples

As child

asChild plays the reveal on the element it wraps, so a list's own items rise in with no div between them; by default Reveal draws its own div.

  • Item 1
  • Item 2
  • Item 3
import { Reveal } from "@produkto/ui/Reveal";

const items: string[] = ["Item 1", "Item 2", "Item 3"];

const Example = () => (
  <Reveal asChild>
    <ul className="flex w-full max-w-sm flex-col gap-2">
      {items.map((item) => (
        <li
          className="rounded-xl border border-border bg-card p-4 body-sm"
          key={item}
        >
          {item}
        </li>
      ))}
    </ul>
  </Reveal>
);

export default Example;

API Reference

Reveal

RevealProps ยท components/Reveal/Reveal.types.ts
PropTypeDefault
asChildbooleanfalse

It also takes the props of <div>.