Secret Reveal

A sheer knit veil over something secret. Pull it off, or click it.

Recovery phrase

Write these 12 words down. Anyone who has them can open your wallet.

1orbit
2lantern
3velvet
4harbor
5thimble
6quartz
7meadow
8cinder
9falcon
10ribbon
11tundra
12mosaic
Drag the veil away, or click it

Installation

Terminal
npx shadcn@latest add https://fabrickit.org/r/secret-reveal.json

This copies the component into components/fabricui and its engine into lib/fabricui. It's your code from then on. First time? Add the theme once: see Installation.

Code

components/fabricui/secret-reveal.tsx
"use client";

import * as React from "react";
import { Veil } from "@/lib/fabricui/veil";
import "./secret-reveal.css";

// A layout effect places the cloth before the browser paints (no stand-in
// frame at all when the component appears after the page has loaded); on the
// server it's a plain effect.
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;

export type SecretRevealProps = {
  /** What lies under the veil. Mark the parts to hide with `data-veil-cell`. */
  children: React.ReactNode;
  /** Revealed (controlled). Leave out to let the veil keep its own state. */
  revealed?: boolean;
components/fabricui/secret-reveal.css
/*
 * Secret Reveal — content under a sheer knit veil (lib/fabricui/veil.js).
 * Mark the parts to hide with data-veil-cell: each is blurred by how much
 * cloth lies over it (the engine sets --veil, 0 – 1, on it), so it sharpens
 * the moment the veil slides off.
 */
.fui-veil { position: relative; touch-action: none; }
/* Until the engine draws the cloth (the server-rendered first paint), a
   stand-in lies where it will: the cloth's colour, its staggered knit, and
   (from secret-reveal.tsx) its resting creases, lit the same way. When the
   real cloth is drawn the two cross-fade, so the texture never jumps. */
.fui-veil .fui-veil__target::before {
  content: "";
  position: absolute;
  inset: -10px;
  z-index: 2;
lib/fabricui/veil.js
import { Dither } from "./dither";

/*
 * veil.js — Fabric Kit's sheer knit veil, laid over something secret. The
 * Secret Reveal component (components/fabricui/secret-reveal.tsx) hands it
 * its elements; this simulates and draws the cloth.
 *
 *   const veil = new Veil(stage, target, { cells, onChange: revealed => … });
 *   veil.reveal();   // whip it off
 *   veil.cover();    // let it float back down
 *
 * One piece of real cloth, simulated live (position-based dynamics: a grid of
 * particles held by stretch, shear and bend constraints) and lying on the
 * card under gravity. It's laid a few percent short, so it rests in soft
 * wrinkles. Hover and it lifts over your finger; press and the pinch rises;
 * drag and it slides off the card behind your hand, folding over itself;

Usage

Usage
import { SecretReveal } from "@/components/fabricui/secret-reveal";

export function ApiKey() {
return (
  <SecretReveal label="Reveal API key">
    <code data-veil-cell>sk-live-4f9a2c…</code>
  </SecretReveal>
);
}

Props

PropTypeDefault
children

What lies under the veil. Mark the parts to hide with data-veil-cell; each blurs by how much cloth covers it.

ReactNode—
revealed

Revealed, if you control it.

boolean—
onRevealedChange

Called when the veil comes off or goes back on.

(revealed: boolean) => void—
lift

How high the cloth lifts over a hovering pointer, px.

number6
settle

Seconds for the cloth to settle back after a tug that didn't take it off.

number1.6
bleed

How far past its own box the cloth may be drawn as it's pulled away, px.

number160
label

The keyboard label for taking the veil off.

string"Reveal"