🥶 Glass Card
Shine bright with GlassCard! ✨ A sleek, frosted-glass component that adds a modern, aesthetic touch to any UI. With its soft gradients, subtle transparency, and smooth hover effects, it creates a realistic glassmorphism look that blends effortlessly into any design. Perfect for elevating your cards, dashboards, and previews with style! 💎🚀
Preview
Follow below steps 👇🏻
Install dependencies
1npm i framer-motion
Component
Create a file glass-card.tsx in your components folder and paste this code
1import { motion } from 'framer-motion';2import { ReactNode } from 'react';34type GlassCardProps = {5children?: ReactNode;6className?: string;7};89const GlassCard = ({ children, className }: GlassCardProps) => {10return (11<motion.div12initial={{ y: 10, opacity: 0 }}13animate={{ y: 0, opacity: 1 }}14transition={{ duration: 0.2 }}15className={`16relative p-6 rounded-2xl bg-gradient-to-tr from-[#46C0F770] to-[#E3E8EA70]17backdrop-blur-lg shadow-lg shadow-white/20 transition-all overflow-hidden18hover:border-white/30 ${className}19`}20>21{/* Light Reflection Animation */}22<motion.span23className="absolute inset-0"24style={{25background: 'linear-gradient(-70deg, transparent 40%, #ffffffaa 50%, transparent 60%)',26filter: 'blur(3px)'27}}28initial={{ x: '-120%' }}29animate={{ x: '120%' }}30transition={{31duration: 2.5,32repeatDelay: 1.2,33repeat: Infinity,34ease: 'linear'35}}36/>3738{/* Card Content */}39<div className="relative">{children}</div>40</motion.div>41);42};4344export default GlassCard;
Usage
1<GlassCard2key={index}3className={`flex flex-col items-center justify-center p-6 text-white text-xl font-semibold tracking-wider bg-gradient-to-tr transition-transform duration-300 hover:scale-105`}4>5<span className="text-2xl">☁️ Cloudy</span>6<span className="ml-2 mt-2 text-lg">15°C</span>7</GlassCard>
⭐️ Got a question or feedback?
Feel free to reach out!