Skip to content

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

feat: add orbiting circles

Dillion Verma72d2b48f4005
diff --git a/config/docs.ts b/config/docs.ts
index 577e868d..a6e13bfc 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -169,6 +169,12 @@ export const docsConfig: DocsConfig = {
href: `/docs/components/globe`,
items: [],
},
+ {
+ title: "Orbiting Circles",
+ href: `/docs/components/orbiting-circles`,
+ items: [],
+ label: "New",
+ },
],
},
diff --git a/content/docs/components/orbiting-circles.mdx b/content/docs/components/orbiting-circles.mdx
new file mode 100644
index 00000000..93ba4da2
--- /dev/null
+++ b/content/docs/components/orbiting-circles.mdx
@@ -0,0 +1,58 @@
+---
+title: Orbiting Circles
+date: 2024-04-24
+description: A collection of circles which move in orbit along a circular path
+author: dillionverma
+published: true
+video: https://cdn.magicui.design/orbiting-circles.mp4
+---
+
+<ComponentPreview name="orbiting-circles-demo" />
+
+<Steps>
+
+### Installation
+
+Copy and paste the following code into your project.
+
+```js
+// tailwind.config.js
+module.exports = {
+ theme: {
+ extend: {
+ animation: {
+ orbit: "orbit calc(var(--duration)*1s) linear infinite",
+ },
+ keyframes: {
+ orbit: {
+ "0%": {
+ transform: "rotate(0deg) translateY(calc(var(--radius) * 1px)) rotate(0deg)",
+ },
+ "100%": {
+ transform: "rotate(360deg) translateY(calc(var(--radius) * 1px)) rotate(-360deg)",
+ },
+ },
+ },
+ },
+ },
+};
+```
+
+```text
+components/magicui/orbiting-circles.tsx
+```
+
+<ComponentSource name="orbiting-circles" />
+
+</Steps>
+
+## Props
+
+| Prop | Type | Description | Default |
+| ----------- | --------------- | -------------------------------------------- | ------- |
+| className | string | The class name for the component | "" |
+| children | React.ReactNode | The children nodes of the component | null |
+| reverse | boolean | If true, the animation plays in reverse | false |
+| duration | number | The duration of the animation in seconds | 20 |
+| delay | number | The delay before the animation starts in seconds | 10 |
+| radius | number | The radius of the orbit in pixels | 50 |
diff --git a/registry/components/example/orbiting-circles-demo.tsx b/registry/components/example/orbiting-circles-demo.tsx
new file mode 100644
index 00000000..0d20b3d1
--- /dev/null
+++ b/registry/components/example/orbiting-circles-demo.tsx
@@ -0,0 +1,39 @@
+import OrbitingCircles from "@/registry/components/magicui/orbiting-circles";
+import { BarChartIcon, LinkIcon } from "lucide-react";
+
+export default function OrbitingCirclesDemo() {
+ return (
+ <div className="relative flex h-full w-full max-w-[32rem] items-center justify-center overflow-hidden rounded-lg border bg-background px-40 pb-40 pt-8 md:pb-60 md:shadow-xl">
+ <span className="pointer-events-none whitespace-pre-wrap bg-gradient-to-b from-black to-gray-300/80 bg-clip-text text-center text-8xl font-semibold leading-none text-transparent dark:from-white dark:to-slate-900/10">
+ Circles
+ </span>
+
+ {/* Inner Circles */}
+ <OrbitingCircles className="h-[40px] w-[40px]">
+ <BarChartIcon className="text-black dark:text-white" />
+ </OrbitingCircles>
+ <OrbitingCircles className="h-[40px] w-[40px]" duration={20} delay={20}>
+ <LinkIcon className="text-black dark:text-white" />
+ </OrbitingCircles>
+
+ {/* Outer Circles (reverse) */}
+ <OrbitingCircles
+ className="h-[50px] w-[50px]"
+ reverse
+ radius={140}
+ duration={20}
+ >
+ hello
+ </OrbitingCircles>
+ <OrbitingCircles
+ className="h-[50px] w-[50px]"
+ reverse
+ radius={140}
+ duration={20}
+ delay={20}
+ >
+ world
+ </OrbitingCircles>
+ </div>
+ );
+}
diff --git a/registry/components/magicui/orbiting-circles.tsx b/registry/components/magicui/orbiting-circles.tsx
new file mode 100644
index 00000000..e0908c2f
--- /dev/null
+++ b/registry/components/magicui/orbiting-circles.tsx
@@ -0,0 +1,36 @@
+import { cn } from "@/lib/utils";
+
+export default function OrbitingCircles({
+ className,
+ children,
+ reverse,
+ duration = 20,
+ delay = 10,
+ radius = 50,
+}: {
+ className?: string;
+ children?: React.ReactNode;
+ reverse?: boolean;
+ duration?: number;
+ delay?: number;
+ radius?: number;
+}) {
+ return (
+ <div
+ style={
+ {
+ "--duration": duration,
+ "--radius": radius,
+ "--delay": -delay,
+ } as React.CSSProperties
+ }
+ className={cn(
+ "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform-gpu animate-orbit items-center justify-center rounded-full border bg-black/10 [animation-delay:calc(var(--delay)*1000ms)] dark:bg-white/10",
+ { "[animation-direction:reverse]": reverse },
+ className,
+ )}
+ >
+ {children}
+ </div>
+ );
+}
diff --git a/registry/index.tsx b/registry/index.tsx
index 13b41ca6..d917644f 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -127,6 +127,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/animated-gradient-text.tsx"],
},
+ "orbiting-circles": {
+ name: "orbiting-circles",
+ type: "components:ui",
+ files: ["registry/components/magicui/orbiting-circles.tsx"],
+ },
};
const example: Registry = {
@@ -526,6 +531,14 @@ const example: Registry = {
() => import("@/registry/components/example/animated-gradient-text-demo"),
),
},
+ "orbiting-circles-demo": {
+ name: "orbiting-circles-demo",
+ type: "components:example",
+ files: ["registry/components/example/orbiting-circles-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/orbiting-circles-demo"),
+ ),
+ },
};
const blocks: Registry = {
diff --git a/tailwind.config.ts b/tailwind.config.ts
index a534c37c..e547e755 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -75,6 +75,7 @@ module.exports = {
line: "line 2s linear infinite",
shimmer: "shimmer 8s infinite",
"border-beam": "border-beam calc(var(--duration)*1s) infinite linear",
+ orbit: "orbit calc(var(--duration)*1s) linear infinite",
},
keyframes: {
"accordion-down": {
@@ -162,6 +163,16 @@ module.exports = {
"background-position": "calc(100% + var(--shimmer-width)) 0",
},
},
+ orbit: {
+ "0%": {
+ transform:
+ "rotate(0deg) translateY(calc(var(--radius) * 1px)) rotate(0deg)",
+ },
+ "100%": {
+ transform:
+ "rotate(360deg) translateY(calc(var(--radius) * 1px)) rotate(-360deg)",
+ },
+ },
},
},
},