Disclose Image
spectrumui/disclose-imageFreeComponent
An image reveal component with animated sliding door panels.
Install it
npx shadcn@latest add https://ui.spectrumhq.in/r/disclose-image.jsonSource
1/* eslint-disable @next/next/no-img-element */2"use client";3import { ImgHTMLAttributes, useState } from "react";4import { cn } from "@/lib/utils";56export default function DiscloseImage({7 className,8 doorClassName,9 vertical = false,10 ...props11}: ImgHTMLAttributes<HTMLImageElement> & {12 doorClassName?: string;13 vertical?: boolean;14}) {15 const [imageLoaded, setImageLoaded] = useState(false);16 const baseClassName =17 "ease-slow duration-mid absolute bg-sky-500 transition-all animate-out fill-mode-forwards";1819 const { alt, ...imgProps } = props;20 return (21 <div className="relative h-64 w-52 overflow-hidden rounded-md bg-yellow-100">22 <img23 alt={alt || "Disclose image"}24 onLoad={() => setImageLoaded(true)}25 {...imgProps}26 className={cn("h-full w-full object-cover", className)}27 />2829 {imageLoaded && (30 <>31 <div32 className={cn(baseClassName, doorClassName, {33 "top-0 h-1/2 w-full slide-out-to-top-full": vertical,34 "bottom-0 left-0 top-0 w-1/2 slide-out-to-left-full": !vertical,35 })}36 />37 <div38 className={cn(baseClassName, doorClassName, {39 "bottom-0 h-1/2 w-full slide-out-to-bottom-full": vertical,40 "bottom-0 right-0 top-0 w-1/2 slide-out-to-right-full": !vertical,41 })}42 />43 </>44 )}45 </div>46 );47}
Files it writes
More from spectrumui
All 182 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | spectrumui | Components | Free | no deps | |
| Alert demoalert-1 | spectrumui | Components | Free | 1 dep | |
| Alert 2alert-2 | spectrumui | Components | Free | no deps | |
| Alert 3alert-3 | spectrumui | Components | Free | 1 dep | |
| Alert 4alert-4 | spectrumui | Components | Free | 1 dep | |
| Animated Cardanimated-card | spectrumui | Components | Free | 1 dep · 2 files | |
| Animated Draweranimated-drawer | spectrumui | Components | Free | 4 deps | |
| Animated SVG Chartanimated-SVG-chart | spectrumui | Components | Free | 1 dep |
