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.jsonTerminal
pnpm dlx shadcn@latest add https://fabrickit.org/r/secret-reveal.jsonTerminal
yarn shadcn@latest add https://fabrickit.org/r/secret-reveal.jsonTerminal
bunx --bun shadcn@latest add https://fabrickit.org/r/secret-reveal.jsonThis 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.
Step 1: Add the theme (once)
Every colour, radius and curve the components use, as --fabric-* variables. Save it as fabric.css next to your global CSS and import it there. If you've added another Fabric Kit component before, skip this.globals.css@import "./fabric.css";fabric.css/* * fabric.css — Fabric Kit's theme: every colour, radius, ring and curve the * components use, as --fabric-* variables (prefixed, so they never clash * with your own shadcn theme). Installed by `shadcn add @fabrickit/theme` * (it lands in your global CSS) — or import this file once, globally. * Dark by default. For light, put data-theme="light" on <html> (or on any * element: the tokens follow it down the tree; data-theme="dark" turns back). */ :root, [data-theme="dark"] { --fabric-page: #111111; --fabric-surface: #191919; /* triggers, recessed tiles */ --fabric-panel: #202020; /* open panels */ --fabric-raised: #2a2a2a; /* hover, range band */ --fabric-raised-hi: #343434; /* hover inside a band */ --fabric-preview: #252525; /* soft preview fills */ --fabric-text: #e0e0e0;Step 2: Copy the shared engines
Plain JavaScript that does the motion, shared between components. Create each file at the same path in your project; if a file is already there from another component, keep it.lib/fabricui/dither.js/* * dither.js — Fabric Kit's dither, in one place. Every dithered thing (cloth * fold shade, shimmer, weaves, chart fills) uses this 4×4 ordered (Bayer) * pattern, so dots line up and read as one texture across components. * * Dither.B4 the 4×4 matrix, 0–15 * Dither.T4 its thresholds, centred: (v + 0.5) / 16 * Dither.at(x, y) the threshold for cell (x, y) * Dither.GLSL the same pattern for shaders: bayer4(cell) → 0–1 */ const B4 = [0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5]; const T4 = B4.map(v => v / 16 + 1 / 32); export const Dither = { B4, T4,Step 3: Copy the Secret Reveal files
The component itself. Create each one at the same path in your project. It's your code from here on.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.jsimport { 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;Step 4: Check the import paths
The files import each other through the @/ alias (the shadcn default, there in a new Next.js app). If your project doesn't have it, add it to tsconfig.json, or change the imports to relative paths.tsconfig.json{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./*"] } } }Step 5: Use it
Import it from @/components/fabricui/secret-reveal. The Usage example below shows it in a page.
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
| Prop | Type | Default |
|---|---|---|
| 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. | number | 6 |
| settle Seconds for the cloth to settle back after a tug that didn't take it off. | number | 1.6 |
| bleed How far past its own box the cloth may be drawn as it's pulled away, px. | number | 160 |
| label The keyboard label for taking the veil off. | string | "Reveal" |