← All components Next componentAudio Waveform→
Cursors · Minimal
Split Orbit
Two thin rings tumbling on opposite axes around the pointer that align into one over buttons.
Move over the words, then the buttons.
Read the docsdata-cursor-text
<SplitOrbitRingCursor />Live
Hover a button: the rings align
Customize
Rings#e4e4e7
Installation
Use it in your project
Or skip the copy-paste
One command: writes the file and installs the dependencies.
$ npx deepui-cli add split-orbit
01
Install
The 3D packages this component is built on.
Nothing to install: React is all it needs.
02
Add the component
One self-contained file: create components/SplitOrbitRingCursor.tsx and paste it in.
components/SplitOrbitRingCursor.tsx
1"use client";23import { memo, useEffect, useRef, useState, type CSSProperties, type RefObject } from "react";45/** What counts as interactive: the cursors react when the pointer is over one of these. */6const INTERACTIVE_SELECTOR =7 "a, button, [role='button'], input, select, textarea, label, summary, [data-cursor], [data-cursor-text], [data-cursor-hover]";89/** A layer pinned to the top-left corner and moved with transforms (no layout, no repaint). */10const FOLLOWER_STYLE: CSSProperties = {11 position: "fixed",12 top: 0,13 left: 0,14 pointerEvents: "none",15 zIndex: 9999,16 willChange: "transform",17};1819/**20 * False on touch screens (`pointer: coarse`) and during server rendering: the custom cursor is not21 * drawn and the native cursor is left alone. Follows the media query live (tablet + mouse…).22 */23function useCursorEnabled() {24 const [enabled, setEnabled] = useState(false);25 useEffect(() => {26 const query = window.matchMedia("(pointer: coarse)");27 const sync = () => setEnabled(!query.matches);28 sync();29 query.addEventListener("change", sync);30 return () => query.removeEventListener("change", sync);31 }, []);32 return enabled;33}3435function usePrefersReducedMotion() {36 const [reduced, setReduced] = useState(false);37 useEffect(() => {38 const query = window.matchMedia("(prefers-reduced-motion: reduce)");39 const sync = () => setReduced(query.matches);40 sync();41 query.addEventListener("change", sync);42 return () => query.removeEventListener("change", sync);43 }, []);44 return reduced;45}4647/** Hides the system cursor on the whole page while `active` (restored on unmount). */48function useHideNativeCursor(active: boolean) {49 useEffect(() => {50 if (!active) return undefined;51 const style = document.createElement("style");52 style.setAttribute("data-custom-cursor", "");53 style.textContent = "*, *::before, *::after { cursor: none !important; }";54 document.head.appendChild(style);55 return () => style.remove();56 }, [active]);57}5859interface CursorPointer {60 /** Position in CSS pixels, relative to the viewport. */61 x: number;62 y: number;63 /** Smoothed velocity, in CSS pixels per second. */64 vx: number;65 vy: number;66 speed: number;67 /** False until the first move, and while the pointer is outside the window. */68 visible: boolean;69 down: boolean;70 /** The interactive element under the pointer (closest match of the selector), or null. */71 target: HTMLElement | null;72 /** Incremented on every press, to trigger click effects. */73 clicks: number;74}7576/**77 * Tracks the pointer through window listeners and returns a ref read inside the animation loop:78 * moving the mouse never re-renders React. All listeners are removed on unmount.79 */80function useCursorPointer(enabled: boolean, selector = INTERACTIVE_SELECTOR): RefObject<CursorPointer> {81 const pointer = useRef<CursorPointer>({ x: -100, y: -100, vx: 0, vy: 0, speed: 0, visible: false, down: false, target: null, clicks: 0 });8283 useEffect(() => {84 if (!enabled) return undefined;85 let last = performance.now();86 const p = pointer.current;87 const pick = (event: PointerEvent) => {88 const el = event.target instanceof Element ? event.target.closest(selector) : null;89 p.target = el instanceof HTMLElement ? el : null;90 };91 const move = (event: PointerEvent) => {92 if (event.pointerType === "touch") return;93 const now = performance.now();94 const dt = Math.max(1, now - last) / 1000;95 last = now;96 if (p.visible) {97 // Smoothed: one jittery event must not make the effects jump98 p.vx = p.vx * 0.6 + ((event.clientX - p.x) / dt) * 0.4;99 p.vy = p.vy * 0.6 + ((event.clientY - p.y) / dt) * 0.4;100 }101 p.x = event.clientX;102 p.y = event.clientY;103 p.visible = true;104 pick(event);105 };106 const down = (event: PointerEvent) => {107 if (event.pointerType === "touch") return;108 p.down = true;109 p.clicks += 1;110 pick(event);111 };112 const up = () => {113 p.down = false;114 };115 const leave = () => {116 p.visible = false;117 p.down = false;118 };119 window.addEventListener("pointermove", move, { passive: true });120 window.addEventListener("pointerdown", down, { passive: true });121 window.addEventListener("pointerup", up, { passive: true });122 document.documentElement.addEventListener("pointerleave", leave);123 window.addEventListener("blur", leave);124 return () => {125 window.removeEventListener("pointermove", move);126 window.removeEventListener("pointerdown", down);127 window.removeEventListener("pointerup", up);128 document.documentElement.removeEventListener("pointerleave", leave);129 window.removeEventListener("blur", leave);130 };131 }, [enabled, selector]);132133 return pointer;134}135136/**137 * requestAnimationFrame loop: `frame(dt, time)` runs every frame (dt in seconds, capped) while138 * `enabled`; the browser pauses it in background tabs. The latest callback is always used.139 */140function useAnimationFrame(enabled: boolean, frame: (dt: number, time: number) => void) {141 const frameRef = useRef(frame);142 useEffect(() => {143 frameRef.current = frame;144 });145 useEffect(() => {146 if (!enabled) return undefined;147 let id = 0;148 let last = performance.now();149 const tick = (now: number) => {150 const dt = Math.min((now - last) / 1000, 1 / 20);151 last = now;152 frameRef.current(dt, now / 1000);153 id = requestAnimationFrame(tick);154 };155 id = requestAnimationFrame(tick);156 return () => cancelAnimationFrame(id);157 }, [enabled]);158}159160/**161 * Velocity only changes on pointer events: call this once per frame so it fades out when the pointer162 * stops, and read `speed` afterwards.163 */164function settlePointer(p: CursorPointer, dt: number) {165 const k = Math.exp(-10 * dt);166 p.vx *= k;167 p.vy *= k;168 p.speed = Math.hypot(p.vx, p.vy);169}170171/** Exponential smoothing factor for a frame: frame-rate independent `lerp`. */172const damp = (lambda: number, dt: number) => 1 - Math.exp(-lambda * dt);173174/** 4. Rendering, materials and glow. */175interface MaterialProps {176 /** Main color of the object. Default "#6366f1". */177 primaryColor?: string;178 /** Color of the glow. Default "#00f0ff". */179 emissiveColor?: string;180 /** Strength of the glow, 0 (none) to 3. Default 1. */181 emissiveIntensity?: number;182 /** 0 (mirror, glass) to 1 (matte). Default 0.3. */183 roughness?: number;184 /** 0 (plastic, organic) to 1 (metal). Default 0.5. */185 metalness?: number;186 /** 0 (opaque) to 1 (clear glass): see-through, refracting surfaces. Default 0. */187 transmission?: number;188 /** Technical wireframe rendering. Default false. */189 wireframe?: boolean;190}191192export interface SplitOrbitProps extends Pick<MaterialProps, "primaryColor"> {193 primaryColor?: string;194 /** @deprecated Use `primaryColor`. */195 ringColor?: string;196 /** Spin speed multiplier. Default 1. */197 rotationSpeed?: number;198 /** Diameter of the rings, in CSS pixels. Default 40. */199 size?: number;200 /** Hide the system cursor while the rings are shown. Default true. */201 hideNativeCursor?: boolean;202}203204/**205 * Two thin concentric rings tumbling on opposite axes in 3D (CSS transforms), like a gyroscope around206 * the pointer. Over an interactive element they straighten up, align into one flat ring and grow.207 */208function SplitOrbitRingCursor({ primaryColor, ringColor = primaryColor ?? "#e4e4e7", rotationSpeed = 1, size = 40, hideNativeCursor = true }: SplitOrbitProps) {209 const enabled = useCursorEnabled();210 const reducedMotion = usePrefersReducedMotion();211 const pointer = useCursorPointer(enabled);212 useHideNativeCursor(enabled && hideNativeCursor);213 const root = useRef<HTMLDivElement>(null);214 const outer = useRef<HTMLDivElement>(null);215 const inner = useRef<HTMLDivElement>(null);216 const dot = useRef<HTMLDivElement>(null);217 const state = useRef({ x: -100, y: -100, t: 0, align: 0, scale: 1, opacity: 0 });218219 useAnimationFrame(enabled, (dt) => {220 const p = pointer.current;221 settlePointer(p, dt);222 const s = state.current;223 s.x += (p.x - s.x) * damp(20, dt);224 s.y += (p.y - s.y) * damp(20, dt);225 s.align += ((p.target ? 1 : 0) - s.align) * damp(8, dt);226 s.scale += ((p.target ? 1.5 : p.down ? 0.8 : 1) - s.scale) * damp(10, dt);227 s.opacity += ((p.visible ? 1 : 0) - s.opacity) * damp(10, dt);228 s.t += dt * rotationSpeed * (reducedMotion ? 0.2 : 1) * (1 + p.speed / 1500) * (1 - s.align);229230 const free = 1 - s.align;231 const a = s.t * 2.1;232 const b = s.t * 1.6;233 if (root.current) {234 root.current.style.opacity = s.opacity.toFixed(3);235 root.current.style.transform = `translate3d(${s.x - size / 2}px, ${s.y - size / 2}px, 0) scale(${s.scale})`;236 }237 // Opposite axes; as `align` reaches 1 both tilts fade to zero and the rings lie flat, one inside the other238 if (outer.current) outer.current.style.transform = `rotateX(${a * free}rad) rotateY(${0.6 * free}rad) rotateZ(${s.t}rad)`;239 if (inner.current) inner.current.style.transform = `scale(${0.72 + s.align * 0.18}) rotateY(${-b * free}rad) rotateX(${-0.6 * free}rad) rotateZ(${-s.t}rad)`;240 if (dot.current) dot.current.style.transform = `scale(${1 - s.align * 0.6})`;241 });242243 if (!enabled) return null;244 const ring = { position: "absolute", inset: 0, borderRadius: "50%", border: `1.5px solid ${ringColor}` } as const;245 return (246 <div ref={root} aria-hidden="true" style={{ ...FOLLOWER_STYLE, width: size, height: size, opacity: 0, perspective: size * 4 }}>247 <div style={{ position: "absolute", inset: 0, transformStyle: "preserve-3d" }}>248 <div ref={outer} style={{ ...ring, borderLeftColor: "transparent" }} />249 <div ref={inner} style={{ ...ring, borderTopColor: "transparent", borderBottomColor: "transparent" }} />250 </div>251 <div252 ref={dot}253 style={{ position: "absolute", left: "50%", top: "50%", width: 4, height: 4, margin: -2, borderRadius: "50%", background: ringColor }}254 />255 </div>256 );257}258259export default memo(SplitOrbitRingCursor);
03
Drop it in a page
Updated live with the settings above.
app/page.tsx
1import SplitOrbitRingCursor from "@/components/SplitOrbitRingCursor";23export default function Section() {4 return (5 // The component fills this box: give it a position and a height6 <div style={{ position: "relative", width: "100%", height: "100vh" }}>7 <SplitOrbitRingCursor8 rotationSpeed={1}9 size={40}10 primaryColor="#e4e4e7"11 />12 </div>13 );14}