Membrane
A sheet you can pluck. Every click sends one soft ring out across the grid, drawn as dots, fabric, mesh, dashes or crosses.
Installation
pnpm dlx shadcn@latest add @breeze/membraneUsage
import { Membrane } from "@/components/breeze/membrane"Put it behind your content. It listens on its parent, so buttons and inputs on top keep working, and a click anywhere in the section plucks the sheet there.
<section className="relative h-[480px]">
<Membrane variant="fabric" className="absolute inset-0 h-full w-full" />
<div className="relative">{/* content */}</div>
</section>Variants
Every variant is the same simulated surface, drawn differently:
| Variant | Looks like |
|---|---|
dots | Dots that swell and shift with the wave; crests lean to the accent |
fabric | A plain weave, threads over and under, lit from the upper left, so waves read as folds travelling through cloth |
mesh | A wireframe whose joints are displaced by the slope |
dashes | Strokes that lean with the slope, like filings in a field |
crosses | Plus marks that grow and turn with the slope |
How it moves
Each click sends out one soft ring. It travels outward, thins as it spreads and fades away. Nothing springs back behind it and nothing bounces off the edges. Rings from several clicks simply overlap. speed sets how fast a ring travels and sustain how long it lasts. Once the last ring fades the animation stops, so a resting background costs nothing.
Pluck from code
Call pluck() on the ref to send a ring yourself, for example when a form succeeds. With no arguments it plucks the centre at the default force.
"use client"
import { useRef } from "react"
import { Membrane, type MembraneHandle } from "@/components/breeze/membrane"
export function Unlock() {
const sheet = useRef<MembraneHandle>(null)
return (
<div className="relative h-96">
<Membrane ref={sheet} interactive={false} className="absolute inset-0 h-full w-full" />
<button className="relative" onClick={() => sheet.current?.pluck(undefined, undefined, 2)}>
Unlock
</button>
</div>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "dots" | "fabric" | "mesh" | "dashes" | "crosses" | "dots" | How the surface is drawn |
color | string | "var(--foreground)" | Ink colour, any CSS colour or var() |
accentColor | string | "var(--brand)" | Colour wave crests lean toward |
gap | number | 18 | Distance between grid points in CSS px |
size | number | per variant | Dot radius, or line width, in CSS px |
idleOpacity | number | per variant | Opacity of the sheet at rest, 0 to 1 |
speed | number | 1 | How fast a ring travels (1 = 650 px per second) |
sustain | number | 0.6 | 0 to 1, how long a ring lasts before it fades |
force | number | 1 | Strength of a click |
displacement | number | 7 | How far points shift with the slope, in CSS px |
pluckOnMount | boolean | true | Pluck the centre once when it first appears |
interactive | boolean | true | Pluck where you click inside the parent |
ref | Ref<MembraneHandle> | Exposes pluck(x?, y?, force?) |
With reduced motion the sheet stays still.