BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/Sora UI/custom-cursor

Custom Cursor

sora-ui/custom-cursor
FreeComponent

A smooth custom cursor that morphs when hovering interactive targets, powered by Motion.

Install it

npx shadcn@latest add https://ui.soralabs.io.vn/r/custom-cursor.json

Source

registry/primitives/effects/custom-cursor/index.tsxui.soralabs.io.vn/r/custom-cursor.json · first 6 KB
1/** biome-ignore-all lint/a11y/noNoninteractiveElementInteractions: Cursor targets use hover-only affordances. */
2/** biome-ignore-all lint/a11y/noStaticElementInteractions: Cursor targets are decorative hover zones. */
3
4"use client";
5
6import { cn } from "@/lib/utils";
7import { cva, type VariantProps } from "class-variance-authority";
8import {
9 motion,
10 type SpringOptions,
11 useMotionValue,
12 useReducedMotion,
13 useSpring,
14} from "motion/react";
15import {
16 type ComponentProps,
17 type ComponentPropsWithoutRef,
18 createContext,
19 type ReactNode,
20 useContext,
21 useEffect,
22 useMemo,
23 useState,
24} from "react";
25
26type MotionDivAnimate = NonNullable<
27 ComponentProps<typeof motion.div>["animate"]
28>;
29
30const DEFAULT_CURSOR_COLOR = "#ff4c24";
31
32const CURSOR_EASE = [0.625, 0.05, 0, 1] as const;
33
34const customCursorVariants = cva("relative select-none", {
35 variants: {
36 layout: {
37 default: "",
38 demo: "flex min-h-72 items-center justify-center",
39 },
40 },
41 defaultVariants: {
42 layout: "default",
43 },
44});
45
46const customCursorTargetVariants = cva(
47 "flex items-center justify-center text-foreground transition-opacity hover:opacity-80",
48 {
49 variants: {
50 size: {
51 sm: "size-10",
52 md: "size-14",
53 lg: "size-16",
54 },
55 },
56 defaultVariants: {
57 size: "md",
58 },
59 }
60);
61
62interface CustomCursorContextValue {
63 setIsHovering: (isHovering: boolean) => void;
64}
65
66const CustomCursorContext = createContext<CustomCursorContextValue | null>(
67 null
68);
69
70function useCustomCursorContext() {
71 const context = useContext(CustomCursorContext);
72
73 if (!context) {
74 throw new Error(
75 "CustomCursorTarget must be used within a CustomCursor provider."
76 );
77 }
78
79 return context;
80}
81
82function hexToRgba(hex: string, alpha: number) {
83 const normalized = hex.replace("#", "");
84
85 if (normalized.length !== 6) {
86 return `rgba(255, 76, 36, ${alpha})`;
87 }
88
89 const red = Number.parseInt(normalized.slice(0, 2), 16);
90 const green = Number.parseInt(normalized.slice(2, 4), 16);
91 const blue = Number.parseInt(normalized.slice(4, 6), 16);
92
93 return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
94}
95
96function resolveCursorAppearance(
97 isHovering: boolean,
98 color: string
99): MotionDivAnimate {
100 if (!isHovering) {
101 return {
102 width: 16,
103 height: 16,
104 borderRadius: 9999,
105 backgroundColor: color,
106 borderColor: color,
107 borderWidth: 1,
108 };
109 }
110
111 return {
112 width: 48,
113 height: 48,
114 borderRadius: 9999,
115// … truncated

What it pulls in

npm packages

  • motion
  • class-variance-authority

Other registry items

  • utils

Files it writes

  • registry/primitives/effects/custom-cursor/index.tsx

Facts

Registry
Sora UI
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-12
Last confirmed
today

Go to the source

ui.soralabs.io.vn Raw registry item This item as JSON

More from Sora UI

All 97 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordionSora UIComponentsFree2 deps
Border Trailborder-trailSora UIComponentsFree1 dep
Bottom Sheetbottom-sheetSora UIComponentsFree2 deps
Cursor Bubblecursor-bubbleSora UIComponentsFree2 deps
Cursor Trail Revealcursor-trail-revealSora UIComponentsFree1 dep
Accordion Demodemo-accordionSora UIComponentsFreeno deps
Border Trail Demodemo-border-trailSora UIComponentsFreeno deps
Border Trail Loading Card Demodemo-border-trail-loadingSora UIComponentsFreeno deps
BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex

BlockDex

Built by

Kynth Studios

the studio behind StoreReady, ToolDrift and BreachProbe

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

© 2026 BlockDex. A Kynth Studios product.

BlockDex