Skip to content

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

fix: update ripple component

Dillion Vermad16db2156f07
diff --git a/registry/components/example/ripple-demo.tsx b/registry/components/example/ripple-demo.tsx
index 7bfa610f..56c1cae6 100644
--- a/registry/components/example/ripple-demo.tsx
+++ b/registry/components/example/ripple-demo.tsx
@@ -1,4 +1,4 @@
-import Ripple from "@/components/magicui/ripple";
+import Ripple from "@/registry/components/magicui/ripple";
export default function RippleDemo() {
return (
diff --git a/registry/components/magicui/ripple.tsx b/registry/components/magicui/ripple.tsx
index 9022dc6a..4fcfa987 100644
--- a/registry/components/magicui/ripple.tsx
+++ b/registry/components/magicui/ripple.tsx
@@ -1,27 +1,43 @@
import React, { CSSProperties } from "react";
-// Modify these
-const MAIN_CIRCLE_SIZE = 210;
-const MAIN_CIRCLE_OPACITY = 0.24;
-const NUM_CIRCLES = 8;
+interface RippleProps {
+ mainCircleSize?: number;
+ mainCircleOpacity?: number;
+ numCircles?: number;
+}
-const Ripple = React.memo(() => {
+const Ripple = React.memo(function Ripple({
+ mainCircleSize = 210,
+ mainCircleOpacity = 0.24,
+ numCircles = 8,
+}: RippleProps) {
return (
- <div className="absolute left-1/2 top-1/2 h-full w-full overflow-visible">
- {Array.from({ length: NUM_CIRCLES }, (_, i) => (
- <div
- key={i}
- className={`absolute -translate-x-1/2 -translate-y-1/2 animate-ripple rounded-full bg-neutral-400`}
- style={
- {
- width: MAIN_CIRCLE_SIZE + i * 70,
- height: MAIN_CIRCLE_SIZE + i * 70,
- opacity: MAIN_CIRCLE_OPACITY - i * 0.03,
- animationDelay: `${i * 0.06}s`,
- } as CSSProperties
- }
- ></div>
- ))}
+ <div className="absolute inset-0 flex items-center justify-center bg-white/5 [mask-image:linear-gradient(to_bottom,white,transparent)]">
+ {Array.from({ length: numCircles }, (_, i) => {
+ const size = mainCircleSize + i * 70;
+ const opacity = mainCircleOpacity - i * 0.03;
+ const animationDelay = `${i * 0.06}s`;
+ const borderStyle = i === numCircles - 1 ? "dashed" : "solid";
+ const borderOpacity = 5 + i * 5;
+
+ return (
+ <div
+ key={i}
+ className={`absolute animate-ripple rounded-full bg-foreground/25 shadow-xl border top-1/2 left-1/2 translate-x-1/2 translate-y-1/2 [--i:${i}]`}
+ style={
+ {
+ width: `${size}px`,
+ height: `${size}px`,
+ opacity: opacity,
+ animationDelay: animationDelay,
+ borderStyle: borderStyle,
+ borderWidth: "1px",
+ borderColor: `rgba(var(--foreground-rgb), ${borderOpacity / 100})`,
+ } as CSSProperties
+ }
+ />
+ );
+ })}
</div>
);
});
diff --git a/tailwind.config.ts b/tailwind.config.ts
index d3f1c98d..13f4b8d4 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -75,7 +75,7 @@ module.exports = {
rotate: "rotate var(--spark) linear infinite both",
"spin-around": "spin-around calc(var(--speed) * 2) infinite linear",
slide: "slide var(--speed) ease-in-out infinite alternate",
- ripple: "ripple 3400ms ease infinite",
+ ripple: "ripple var(--duration,2s) ease calc(var(--i, 0)*.2s) infinite",
line: "line 2s linear infinite",
shimmer: "shimmer 8s infinite",
"border-beam": "border-beam calc(var(--duration)*1s) infinite linear",