pnpm dlx shadcn@latest add @gammaui/inverted-cursor
Add the Cursor component to your root layout or main app component:
import { Cursor } from "@/components/gammaui/inverted-cursor"
export default function RootLayout({ children }) {
return (
<html>
<body>
<Cursor />
{children}
</body>
</html>
)
}import { Cursor } from "@/components/gammaui/cursor"
export default function App() {
return (
<>
<Cursor size={80} />
{/* Your content */}
</>
)
}| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | 60 | Diameter of the cursor in pixels |
requestAnimationFrame for buttery smooth cursor trackingmix-blend-difference for automatic color contrastaria-hidden for screen readersModify the lerp factor in the animate function (line 25-26):
// Faster (0.3 = more responsive)
const deltaX = (targetX - currentX) * 0.3
const deltaY = (targetY - currentY) * 0.3
// Slower (0.1 = more smooth/laggy)
const deltaX = (targetX - currentX) * 0.1
const deltaY = (targetY - currentY) * 0.1Override the default styles with Tailwind classes:
<div
ref={cursorRef}
className="pointer-events-none fixed z-50 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 blur-sm"
style={{
width: size,
height: size,
opacity: visible ? 1 : 0,
}}
/>Try different mix-blend modes for various effects:
// Default (inverts colors)
className = "... mix-blend-difference"
// Additive lighting effect
className = "... mix-blend-screen"
// Multiply effect
className = "... mix-blend-multiply"
// Exclusion effect
className = "... mix-blend-exclusion";<Cursor size={100} />
// In the component, add blur:
className = "... blur-md"export default function App() {
return (
<>
<Cursor size={60} /> {/* Outer cursor */}
<Cursor size={20} />{" "}
{/* Inner cursor - will need className modification */}
{/* Your content */}
</>
)
}// Modify the component's className
className =
"fixed pointer-events-none rounded-full bg-gradient-to-r from-cyan-500 to-blue-500 opacity-70 z-50"z-50 by default. Adjust if you have elements with higher z-indexrequestAnimationFrame for optimal performanceWorks in all modern browsers that support:
mix-blend-difference CSS propertyrequestAnimationFrame APIThe cursor includes aria-hidden="true" to prevent screen readers from announcing it, as it's purely decorative.