Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

adjust gradient background dynamically based on card dimensions (#147)

shreya w0db6fbcc2f4f
diff --git a/registry/components/magicui/neon-gradient-card.tsx b/registry/components/magicui/neon-gradient-card.tsx
index b10ffffe..c8426941 100644
--- a/registry/components/magicui/neon-gradient-card.tsx
+++ b/registry/components/magicui/neon-gradient-card.tsx
@@ -96,6 +96,13 @@ const NeonGradientCard: React.FC<NeonGradientCardProps> = ({
};
}, []);
+ useEffect(() => {
+ if (containerRef.current) {
+ const { offsetWidth, offsetHeight } = containerRef.current;
+ setDimensions({ width: offsetWidth, height: offsetHeight });
+ }
+ }, [children]);
+
return (
<div
ref={containerRef}