Encrypted Card
godui/encrypted-cardFreeComponent
A card whose surface hides a live stream of scrambling ciphertext, revealed only through a soft spotlight that follows the pointer.
Install it
npx shadcn@latest add https://godui.design/r/encrypted-card.jsonSource
1"use client";23import * as React from "react";45export type EncryptedCardProps = React.HTMLAttributes<HTMLDivElement> & {6 /** Pool of glyphs the encrypted stream is drawn from. */7 characters?: string;8 /** Milliseconds between glyph re-randomizations while hovered. */9 speed?: number;10 /** Radius of the reveal window that follows the pointer, in pixels. */11 revealRadius?: number;12 /** Color of the encrypted glyph stream. Accepts any CSS color. */13 streamColor?: string;14 /**15 * Opacity of the revealed glyph stream, 0–1. Lower values make the ciphertext16 * subtler. Defaults to 1 (fully opaque inside the reveal window).17 */18 streamOpacity?: number;19};2021// A wide alphabet keeps the stream looking like ciphertext rather than a word.22const DEFAULT_CHARS =23 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789<>[]{}/*#$%&";24// Enough characters to flood any reasonably sized card.25const STREAM_LEN = 1500;2627const ROOT_BASE =28 "group relative overflow-hidden rounded-xl border border-border bg-card text-card-foreground";2930// The glyph layer, revealed only inside a soft radial mask centered on the31// pointer (`--x` / `--y`, defaulting to center so the first paint isn't a corner32// flash). `mask-image` is a single longhand so the shorthand-reset trap does not33// apply here.34const STREAM_BASE =35 "pointer-events-none absolute inset-0 select-none break-all font-mono text-[11px] leading-[1.15] tracking-[0.15em] opacity-0 [transition:opacity_300ms_ease] group-hover:[opacity:var(--stream-opacity,1)] motion-reduce:[transition:none] [mask-image:radial-gradient(var(--reveal)_circle_at_var(--x,50%)_var(--y,50%),#000_0%,transparent_100%)] [-webkit-mask-image:radial-gradient(var(--reveal)_circle_at_var(--x,50%)_var(--y,50%),#000_0%,transparent_100%)]";3637function randomString(length: number, chars: string): string {38 let out = "";39 for (let i = 0; i < length; i++) {40 out += chars[Math.floor(Math.random() * chars.length)];41 }42 return out;43}4445function usePrefersReducedMotion(): boolean {46 const [reduced, setReduced] = React.useState(false);47 React.useEffect(() => {48 const mq = window.matchMedia("(prefers-reduced-motion: reduce)");49 const update = () => setReduced(mq.matches);50 update();51 mq.addEventListener("change", update);52 return () => mq.removeEventListener("change", update);53 }, []);54 return reduced;55}5657const EncryptedCard = React.forwardRef<HTMLDivElement, EncryptedCardProps>(58 (59 {60// … truncated
What it pulls in
Other registry items
Files it writes
More from godui
All 105 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | godui | Components | Free | 1 dep | |
| Agent Flowagent-flow | godui | Components | Free | 1 dep | |
| Agent Timelineagent-timeline | godui | Components | Free | 1 dep | |
| Animated Beamanimated-beam | godui | Components | Free | 1 dep | |
| Animated Testimonialsanimated-testimonials | godui | Components | Free | 1 dep | |
| Animated Tooltipanimated-tooltip | godui | Components | Free | 1 dep | |
| App Showcaseapp-showcase | godui | Components | Free | 1 dep | |
| Aurora Textaurora-text | godui | Components | Free | no deps |
