Wave Reveal

A colourful wave that carries one screen into the next.

Preview

"use client";

import { useState } from "react";
import { WaveReveal } from "@/components/motion/wave-reveal";

export function WaveRevealUsage() {
  const [sent, setSent] = useState(false);

  return (
    // The wave leaves from wherever the button was pressed.
    <WaveReveal
      revealed={sent}
      className="w-72 rounded-2xl border border-border"
      revealedContent={
        <div className="flex flex-col gap-3 p-5">
          <p className="text-sm font-medium">Invite sent</p>
          <button
            type="button"
            onClick={() => setSent(false)}
            className="h-10 rounded-full border border-border text-sm"
          >
            Done
          </button>
        </div>
      }
    >
      <div className="flex flex-col gap-3 p-5">
        <p className="text-sm font-medium">Invite your team</p>
        <button
          type="button"
          onClick={() => setSent(true)}
          className="h-10 rounded-full bg-primary text-sm text-primary-foreground"
        >
          Send invite
        </button>
      </div>
    </WaveReveal>
  );
}

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/wave-reveal

API Reference

children
ReactNode

The first screen, shown while `revealed` is false.

Default—
revealedContent
ReactNode

The screen the wave carries in when `revealed` turns true.

Default—
revealed
boolean

Which screen shows. Flip it to play the wave; flipping it back plays the wave again toward the first screen.

Default—
type?
"vertical" | "horizontal" | "center"

Shape of the wave front: a wide arc that travels up or down, a tall arc that travels sideways, or a ring from the centre. Default: "vertical"

Defaultvertical
sourceRef?
RefObject<HTMLElement | null>

Element the wave leaves from, such as the confirm button. Without it the wave leaves from the last press inside, else from the bottom edge, the left edge or the centre.

Default—
duration?
number

Time the wave takes to cross the screen, in seconds. A short gather before it and the fading edge glow after it add about 1.3s. Default: 1.6

Default1.6
colors?
string[]

Colours of the wave and the glow it leaves on the edges, any CSS colour. Default: amber, sky, pink, peach and cyan

Default["#ffc915", "#7ec4ff", "#eb64a0", "#ffb07a", "#7fd9ee"]
distortion?
number

How far the wave swells the screen under it, in px. 0 turns the swell off. Default: 26

Default26
onRevealComplete?
((revealed: boolean) => void)

Called when a wave finishes, with the `revealed` value it carried in.

Default—
className?
string

Classes merged onto the root element.

Default—

Updated