skeleton-demo.tsx
skeleton.tsx
prompt.md
Collapse
Reset
Copy Code
Download
Run
1
"use client";
2
3
import { useState } from "react"
4
import { Skeleton } from "./skeleton"
5
import { motion, AnimatePresence } from "framer-motion"
6
7
export function SkeletonDemo() {
8
const [isRevealed, setIsRevealed] = useState(false)
9
10
return (
11
<div className="w-full h-full flex flex-col items-center justify-center p-8 gap-6">
12
13
<div className="flex items-center gap-4 min-w-[220px]">
14
<AnimatePresence mode="wait">
15
{!isRevealed ? (
16
<motion.div
17
key="skeleton"
18
initial={{ opacity: 0 }}
19
animate={{ opacity: 1 }}
20
exit={{ opacity: 0 }}
21
transition={{ duration: 0.2 }}
22
className="flex items-center gap-4 w-full"
23
>
24
<Skeleton className="w-11 h-11 rounded-full shrink-0" />
25
<div className="flex flex-col gap-2 w-full">
26
<Skeleton className="h-3 w-3/4" />
27
<Skeleton className="h-3 w-1/2" />
28
</div>
29
</motion.div>
30
) : (
31
<motion.div
32
key="content"
33
initial={{ opacity: 0 }}
34
animate={{ opacity: 1 }}
35
exit={{ opacity: 0 }}
36
transition={{ duration: 0.2 }}
37
className="flex items-center gap-4 w-full"
38
>
39
<div className="w-11 h-11 shrink-0 rounded-full overflow-hidden bg-zinc-200 dark:bg-zinc-800">
40
<img
41
src="https://images.unsplash.com/photo-1599566150163-29194dcaad36?auto=format&fit=crop&q=80&w=100&h=100"
42
alt="Pratik Pandey"
43
className="w-full h-full object-cover"
44
/>
45
</div>
46
<div className="flex flex-col justify-center">
47
<span className="text-[14px] font-semibold text-zinc-900 dark:text-zinc-100 leading-tight">
48
Pratik Pandey
49
</span>
50
<span className="text-[13px] text-zinc-500 mt-0.5">
51
Design engineer
52
</span>
53
</div>
54
</motion.div>
55
)}
56
</AnimatePresence>
57
</div>
58
59
<button
60
onClick={() => setIsRevealed(!isRevealed)}
61
className="px-4 py-1.5 rounded-full text-[13px] font-medium bg-zinc-100 dark:bg-[#1C1C1C] text-zinc-900 dark:text-zinc-100 hover:bg-zinc-200 dark:hover:bg-[#2A2A2A] transition-colors border border-black/5 dark:border-white/5 shadow-sm"
62
>
63
{isRevealed ? "Hide" : "Reveal"}
64
</button>
65
66
</div>
67
)
68
}
69

