🥶 Moving Border Card
The MovingBorderCard component wraps its content with a stylish animated border effect. It accepts children (content inside the card), along with optional wrapper and card-specific class names for customization. Ideal for highlighting key information with a modern, dynamic look. 🚀✨
Preview
The dynamic moving border adds a touch of elegance and modernity.
Follow below steps 👇🏻
Styles
Add these styles in your .css file
1.moving-border-card {2display: flex;3align-items: center;4justify-content: center;5background: linear-gradient(var(--angle), transparent 90%, #ffffff 90%);6animation: moveGradient 4s linear infinite;7}89@property --angle {10syntax: '<angle>';11initial-value: 0deg;12inherits: false;13}1415@keyframes moveGradient {16to {17--angle: 360deg;18}19}
Component
Create a file moving-border-card.tsx in your components folder and paste this code
1import React from 'react';23const MovingBorderCard = ({4children,5wrapperClassName,6className7}: {8children?: React.ReactNode;9wrapperClassName?: string;10className?: string;11}) => {12return (13<div className={`moving-border-card p-[3px] ${wrapperClassName}`}>14<div className={`flex items-center justify-center relative ${className}`}>{children}</div>15</div>16);17};1819export default MovingBorderCard;
Usage
1<MovingBorderCard2wrapperClassName="rounded-xl"3className="h-[250px] w-[300px] bg-gradient-to-br from-gray-700 via-gray-800 to-black text-white shadow-xl rounded-lg p-6"4>5<div className="flex flex-col items-center justify-center h-full">6<h2 className="text-2xl font-semibold mb-2">Premium Card</h2>7<p className="text-center mb-4 text-gray-300">8The dynamic moving border adds a touch of elegance and modernity.9</p>10<button className="mt-auto bg-white text-black px-4 py-2 rounded-full shadow-md hover:bg-gray-200 transition-colors">11Learn More12</button>13</div>14</MovingBorderCard>
⭐️ Got a question or feedback?
Feel free to reach out!