Skip to content

Label Cursor

Custom cursor that morphs from a dot into a label or a ring over marked elements.

From the Nitip template — see it in context
Forest slopes in drifting fogHover: label
Hover: label + plus
Hover: ring

Installation

$ npx shadcn@latest add https://framebrick.co/r/label-cursor.json

Usage

import { LabelCursor } from "@/components/ui/label-cursor";

// once, in the root layout
<LabelCursor />

// anywhere
<a href="/work/aurora" data-cursor="View project">…</a>
<button data-cursor="More details" data-cursor-icon="plus">…</button>
<figure data-cursor="ring">…</figure>

Props

PropTypeDefaultDescription
dotbooleantrueShow the small trailing dot outside marked elements.
scopestring—CSS selector: only show the cursor inside matching elements.
classNamestring—Classes for the morphing shape.
  • data-cursor="<text>" shows a label centered on the pointer and hides the system cursor.
  • data-cursor-icon="arrow" (default), "plus" or "none" sets the icon after the label.
  • data-cursor="ring" shows an outlined ring above the pointer and keeps the system cursor.
  • Only runs on devices that can hover; touch screens never see it.

AI prompt

Paste into v0, Lovable, Bolt or Claude to rebuild this component in your own project.

Create a React + Tailwind CSS + Motion (motion/react) component called LabelCursor — a custom cursor rendered once in the layout.
- A fixed, pointer-events-none element that follows the pointer instantly (motion values x/y set on pointermove).
- It reads the element under the pointer: closest [data-cursor].
  - none → a 12px dot (bg-foreground) 20px below-right of the pointer; system cursor stays.
  - data-cursor="ring" → a 44px outlined ring (1px border-foreground) offset (20, -20) above the pointer.
  - any other value → a label centered on the pointer styled like the shadcn Tooltip: bg-foreground, text-background,
    rounded-md, px-3 py-1.5, text-xs font-medium, shadow-md,
    the text from the attribute plus an icon from data-cursor-icon (arrow default, plus, none). Hide the system cursor
    while the label shows (toggle an attribute on <html> and a style rule cursor:none !important).
- Width, height and corner radius (dot 6, ring 22, label 6) morph with a spring (stiffness 500, damping 60);
  the label text cross-fades in 0.15s.
- Fade the cursor out when the pointer leaves the window; re-check the element under the pointer on scroll.
- Only enable when matchMedia("(any-hover: hover)") matches; ignore touch pointers. Optional scope selector and dot toggle.

Be the first to know

Get new templates and components first

One short email when we release a template or a free component. No spam — unsubscribe anytime.

We use your email only for Framebrick updates. Privacy policy