Overview
TheBackgroundGradient component wraps content with an animated, multi-color radial gradient border effect. It features smooth background position animations and interactive hover states, creating a premium, modern visual effect.
Visual Effect
The component creates:- Two layered animated gradient effects (blurred and sharp)
- Four radial gradients positioned at corners: cyan, purple, yellow, and blue
- Smooth background position animation that loops infinitely
- Opacity transition on hover (60% → 100%)
- Blur effect on the bottom gradient layer
Source Location
/workspace/source/src/app/components/ui/background-gradient.tsx
Props
Content to be wrapped with the gradient effect
Additional classes for the inner content wrapper (z-index 10)
Additional classes for the outer container element
Whether to enable the background position animation. Set to
false for a static gradient.Type Definition
From/workspace/source/src/app/components/ui/background-gradient.tsx:5-14:
Animation Details
The component uses Framer Motion for smooth animations.Motion Variants
From/workspace/source/src/app/components/ui/background-gradient.tsx:16-23:
Transition Configuration
Animation duration in seconds
Number of times to repeat the animation
How the animation repeats (“reverse” creates a back-and-forth effect)
The animation only applies when
animate={true}. When disabled, all motion props are set to undefined.Gradient Color Scheme
The gradient uses four radial gradients positioned at each corner:Usage Examples
Profile Image Wrapper
From/workspace/source/src/app/components/sections/ProfileCard.tsx:14-23:
Card with Content
Static Gradient (No Animation)
Layer Structure
The component creates three layers:-
Outer Container (
relative p-[4px] group)- 4px padding creates the border effect
groupenables hover state targeting
-
Gradient Layers (both
absolute inset-0 z-[1])- Bottom layer: Blurred gradient with opacity transition
- Top layer: Sharp gradient
- Both animated with same motion variants
-
Content Layer (
relative z-10)- Sits above gradients
- Contains your custom content
Styling Classes
Container
Blurred Gradient Layer
Sharp Gradient Layer
Content Wrapper
The
will-change-transform property optimizes animation performance by hinting to the browser about upcoming transforms.Performance Considerations
- GPU Acceleration: Uses
will-change-transformfor smooth animations - Conditional Animation: Disable with
animate={false}for static use cases - Background Size: Set to
400% 400%when animated to allow smooth position transitions
Dependencies
framer-motion- For animation capabilities@/lib/utils- Providescn()utility for class merging- React
- Tailwind CSS
Accessibility
The component respects user motion preferences:Customization Tips
- Border Width: Adjust the
p-[4px]padding incontainerClassNameprop - Corner Radius: Modify
rounded-3xlclasses - Colors: The gradient colors are hardcoded—edit the component source to customize
- Animation Speed: Change the
duration: 5value in the transition config - Hover Behavior: The blur layer transitions from 60% to 100% opacity on hover