🔍 Glass Button
GlassButton brings a modern, glassmorphic touch to your UI with a semi-transparent gradient background, a soft blur effect, and smooth hover transitions. Powered by Framer Motion for animations and Tailwind CSS for styling, this button delivers a sleek, futuristic feel perfect for minimalist and modern designs.
Preview
Follow below steps 👇🏻
Install dependencies
1npm i framer-motion
Component
Create a file glass-button.tsx in your components folder and paste this code
1import { HTMLMotionProps, motion } from 'framer-motion';2import React from 'react';34type GlassButtonProps = HTMLMotionProps<'button'> & {5children?: React.ReactNode;6className?: string;7};89const GlassButton = ({ children, className, ...props }: GlassButtonProps) => {10return (11<motion.button12{...props}13className={`relative overflow-hidden rounded-xl px-6 py-3 text-white font-semibold14bg-gradient-to-tr from-[#46C0F780] to-[#E3E8EA80] backdrop-blur-lg15shadow-inner shadow-white/20 transition-all duration-30016hover:shadow-lg hover:shadow-cyan-200/30 ${className}`}17initial={{ opacity: 0 }}18animate={{ opacity: 1 }}19>20{/* Light Reflection Animation */}21<motion.span22className="absolute inset-0"23style={{24background: 'linear-gradient(-70deg, transparent 45%, #ffffffa0 50%, transparent 55%)',25filter: 'blur(2px)'26}}27initial={{ x: '-100%' }}28animate={{ x: '100%' }}29transition={{30duration: 2,31repeatDelay: 1,32repeat: Infinity,33ease: 'linear'34}}35/>3637{/* Button Content */}38<div className="relative">{children}</div>39</motion.button>40);41};4243export default GlassButton;
Usage
1<GlassButton>Continue</GlassButton>
⭐️ Got a question or feedback?
Feel free to reach out!