Components

Custom Cursor

A custom cursor component for React and Tailwind CSS: a dot that sits on the pointer and a ring that trails it on a spring, growing over links and buttons and showing short labels like “View” or “Play”. Scoped to a container or the whole page, and it falls back to the native cursor on touch screens and with reduced motion.

  • Spring trailing ring
  • Hover labels
  • Container or page scope
  • Zero re-renders on move
  • Touch & reduced-motion fallback
Northwind Studio

Brand and product design for small software teams.

The ring grows over anything clickable. Plain text keeps the small dot.

Installation

$ npx shadcn@latest add https://duskui.com/r/custom-cursor.json

Usage

showcase.tsx
import { CustomCursor } from "@/components/dusk/custom-cursor/custom-cursor"

export function Showcase() {
  return (
    <CustomCursor className="grid gap-4 overflow-hidden rounded-xl p-6 sm:grid-cols-3">
      <a href="/work/aurora" data-cursor-label="View">Aurora</a>
      <a href="/work/tide" data-cursor-label="View">Tide</a>
      <div data-cursor="hover">Anything can enlarge the ring</div>
    </CustomCursor>
  )
}

Examples

Hover labels

Add data-cursor-label to any element and the ring fills in and shows the text. Keep labels to a word or two; size the bubble with labelSize.

Spring feel

spring sets how the ring follows: stiff and damped for a snappy cursor, soft and heavy for a floaty one. data-cursor="hover" enlarges the ring over non-interactive elements too.

Snappy

stiffness 900 · damping 50

Floaty

stiffness 120 · damping 18

Page scope

Render <CustomCursor scope="page" /> once (for example in a layout) to draw the cursor across the whole document. It is portaled to body; text fields and data-cursor="native" keep the native cursor.

With scope="page" the cursor follows you across the whole document. Text fields keep their native caret.

API Reference

In container scope it renders a div that accepts any HTML attribute. Data attributes on descendants: data-cursor="hover", data-cursor-label="…", data-cursor="native".

PropTypeDefaultDescription
scope"container" | "page""container"Draw only inside this element (wrapping children), or across the whole page.
ringSizenumber32Ring diameter in px.
hoverSizenumber56Ring diameter over links, buttons and [data-cursor="hover"].
labelSizenumber76Ring diameter when showing a data-cursor-label.
dotSizenumber6Dot diameter in px.
springSpringOptions{ stiffness: 380, damping: 32, mass: 0.6 }Spring for the trailing ring. The dot uses a much stiffer one.
hoverSelectorstring—Extra CSS selector for elements that enlarge the ring.
classNamestring—Classes for the container (container scope only).

Accessibility

  • The drawn dot and ring are aria-hidden and pointer-events: none; clicks, focus and hover states of your content are untouched.
  • The native cursor is hidden only inside the scoped area, and only once the custom cursor is active; text inputs keep their caret.
  • Touch screens, pens and coarse pointers keep the native cursor and render nothing extra.
  • With prefers-reduced-motion the component is disabled entirely and the native cursor stays.
  • Pointer tracking uses motion values, so moving the mouse never re-renders React.