Reveal Card
nyxui/reveal-cardFreeComponent
A reveal card that that provide several effects.
Live preview
live · rendered by the registry
Rendered by shadcn/ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://nyxui.com/r/reveal-card.jsonSource
1"use client";2import React, { useEffect, useRef, useState } from "react";3import Image from "next/image";45interface CardProps {6 coverImage: string;7 titleImage: string;8 characterImage: string;9 width?: number;10 height?: number;11 hoverRotation?: number;12 titleTranslateY?: number;13 characterTranslateY?: number;14 characterTranslateZ?: number;15 alt?: {16 cover?: string;17 title?: string;18 character?: string;19 };20 animation?: {21 duration?: number;22 delay?: number;23 };24 priority?: boolean;25 threshold?: number;26 className?: string;27}2829const RevealCard: React.FC<CardProps> = ({30 coverImage,31 titleImage,32 characterImage,33 width = 266,34 height = 400,35 hoverRotation = 25,36 titleTranslateY = -50,37 characterTranslateY = -15,38 characterTranslateZ = 100,39 alt = {40 cover: "Cover Image",41 title: "Title",42 character: "Character",43 },44 animation = {45 duration: 500,46 delay: 0,47 },48 priority = false,49 threshold = 0.3,50 className = "",51}) => {52 const cardRef = useRef<HTMLDivElement>(null);53 const [isVisible, setIsVisible] = useState(false);54 const [isMobile, setIsMobile] = useState(false);55 const [isRevealed, setIsRevealed] = useState(false);56 const [hasBeenRevealed, setHasBeenRevealed] = useState(false);5758 useEffect(() => {59 const checkMobile = () => {60 setIsMobile(window.innerWidth < 768);61 };62 checkMobile();63 window.addEventListener("resize", checkMobile);6465 const currentRef = cardRef.current;6667 const observer = new IntersectionObserver(68 ([entry]) => {69 if (entry.isIntersecting) {70 setIsVisible(true);71 if (!hasBeenRevealed) {72 setIsRevealed(true);73 setHasBeenRevealed(true);74 }75 } else {76 setIsVisible(false);77 }78 },79 { threshold },80 );8182 if (currentRef) {83 observer.observe(currentRef);84 }8586 return () => {87 window.removeEventListener("resize", checkMobile);88 if (currentRef) observer.unobserve(currentRef);89 };90 }, [threshold, hasBeenRevealed]);9192 const handleCardClick = () => {93 setIsRevealed(!isRevealed);94 setHasBeenRevealed(true);95 };9697 const animationStyle = {98 transitionDuration: `${animation.duration}ms`,99 transitionDelay: `${animation.delay}ms`,100 };101102 const shouldReveal = isMobile103 ? isRevealed104 : isRevealed || (!hasBeenRevealed && isVisible);105106 const mobileRevealClass =107 isMobile && shouldReveal108// … truncated
What it pulls in
npm packages
Files it writes
More from shadcn/ui
All 68 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| 3D Layered Card3d-layered-card | shadcn/ui | Components | Free | 1 dep | |
| Animated Code Blockanimated-code-block | shadcn/ui | Components | Free | 3 deps | |
| Animated Grainy Backgroundanimated-grainy-bg | shadcn/ui | Components | Free | 1 dep | |
| Animated Textanimated-text | shadcn/ui | Components | Free | 1 dep | |
| Apple Glass Effectapple-glass-effect | shadcn/ui | Components | Free | 1 dep | |
| Bubble Backgroundbubble-background | shadcn/ui | Components | Free | no deps | |
| Custom Cursorcustom-cursor | shadcn/ui | Components | Free | 1 dep | |
| Cyberpunk Cardcyberpunk-card | shadcn/ui | Components | Free | no deps |
