Skip to content

Reveal

Open .md
Live preview

Loading example…

Fades its content in with a small rise when it mounts on the client, or first scrolls into view with inView. Server-rendered content and reduced motion show the end state at once. The content stays in the accessibility tree the whole time: hiding uses opacity only.

import { Reveal } from "@jcsoftdev/ui/motion";
export const RevealOnMount: Story = {
render: () => (
<Replay>
{() => (
<Reveal>
<Card className="max-w-sm p-card">Welcome back. Three tasks are waiting for you.</Card>
</Reveal>
)}
</Replay>
),
};

Source of the Storybook story.

Prop Type Default Description
delay number Extra wait before entering, in ms.
inView boolean false Enter when the element first scrolls into view instead of on mount.
asChild boolean Animate the single child element instead of rendering a div.
ref Ref<HTMLElement>

* marks a required prop.

It also accepts the native props of the element or primitive it renders (for example className, id, aria-* and event handlers).

packages/ui/src/motion/reveal.tsx