hover-ui

Orbit

A moon circling the pointer. Its orbit widens over anything clickable.

npx shadcn@latest add https://hoverui.fun/r/orbit.json

Adds components/cursors/orbit.tsx. The CLI also installs the useCursor hook it runs on, once, into your hooks folder. The files are yours from there.

Move through the preview, then hover the controls and press.

Kind
Space
Dependencies
None
License
MIT

Usage

Any element
import { OrbitCursor } from "@/components/cursors/orbit";

export function Section() {
  return (
    <section>
      <OrbitCursor />
      {/* this section now wears Orbit */}
    </section>
  );
}

Put it inside <body> in your root layout to wear it on every page. Nested cursors take over inside their own element.

Props

className
Colors the cursor through currentColor, e.g. text-pink-500. To read on any background, pass text-white mix-blend-difference, as this site does.
Hover targets
a, button, input, select, textarea, label, [role=button], [data-cursor-label]

Source

orbit.tsx
"use client";

import { useRef } from "react";
import { cursorRoot, useCursor } from "@/hooks/use-cursor";

/** A moon circles the pointer; its orbit widens over anything clickable. */
export function OrbitCursor({ className = "" }: { className?: string }) {
  const s = useRef({ a: 0, r: 16 });
  const ref = useCursor((p, el) => {
    const st = s.current;
    if (!p.reduced) st.a += p.dt * 3.2;
    st.r += ((p.hover ? 28 : 16) - st.r) * p.ease(10);
    const [ring, moon, dot] = el.children as HTMLCollectionOf<HTMLElement>;
    ring.style.transform = `translate(${p.x}px, ${p.y}px) scale(${st.r / 16})`;
    moon.style.transform = `translate(${p.x + Math.cos(st.a) * st.r}px, ${p.y + Math.sin(st.a) * st.r}px)`;
    dot.style.transform = `translate(${p.x}px, ${p.y}px)`;
  });

  return (
    <div ref={ref} aria-hidden className={`${cursorRoot} ${className}`}>
      <div className="absolute size-8 -translate-1/2 rounded-full border border-current opacity-30" />
      <div className="absolute size-2 -translate-1/2 rounded-full bg-current" />
      <div className="absolute size-1.5 -translate-1/2 rounded-full bg-current" />
    </div>
  );
}

It runs on the useCursor hook, which has its own source and API.

More space cursors

Made a cursor of your own? Contributed cursors carry their maker's name on their page.

Contribute a cursor