Join our Discord community
Interactive

Animated Cursor

Advanced animated cursor component with customizable following elements and spring animations. Perfect for React applications requiring interactive cursor effects with Next.js integration and TypeScript support.

Powered by

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/animated-cursor.json
npx shadcn@latest add https://www.shadcn.io/registry/animated-cursor.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/animated-cursor.json
bunx shadcn@latest add https://www.shadcn.io/registry/animated-cursor.json

Features

  • Custom cursor replacement with animated scale and opacity transitions
  • Following elements with spring-based physics and configurable alignment options
  • Context-based architecture using React Context for state management across components
  • Automatic parent positioning with intelligent relative positioning detection
  • Spring animations with customizable stiffness, damping, and bounce parameters
  • TypeScript support with complete interface definitions and alignment types
  • shadcn/ui integration using design system utilities and responsive classes

Examples

Cursor Follow Only

Loading component...

Use Cases

This free open source React component works well for:

  • Creative portfolios - Artistic cursor interactions built with Next.js
  • Interactive presentations - Engaging cursor effects using TypeScript and Tailwind CSS
  • Design showcases - Portfolio cursor customization with shadcn/ui integration
  • Gaming interfaces - Custom cursor mechanics for React applications
  • Marketing pages - Eye-catching cursor animations with spring physics

API Reference

CursorProvider

PropTypeDefaultDescription
childrenReact.ReactNoderequiredChild components that use cursor context
classNamestring-Additional CSS classes for provider container

Cursor

PropTypeDefaultDescription
childrenReact.ReactNoderequiredCustom cursor content (SVG, icon, etc.)
classNamestring-Additional CSS classes for cursor element

CursorFollow

PropTypeDefaultDescription
childrenReact.ReactNoderequiredFollowing element content (tooltip, badge, etc.)
sideOffsetnumber15Distance offset from cursor in pixels
alignAlign'bottom-right'Positioning relative to cursor
transitionSpringOptions{ stiffness: 500, damping: 50, bounce: 0 }Spring animation configuration
classNamestring-Additional CSS classes for follow element

Alignment Options

  • center - Centered on cursor position
  • top - Above cursor with center alignment
  • top-left - Above and to the left of cursor
  • top-right - Above and to the right of cursor
  • bottom - Below cursor with center alignment
  • bottom-left - Below and to the left of cursor
  • bottom-right - Below and to the right of cursor (default)
  • left - To the left with center alignment
  • right - To the right with center alignment

Spring Configuration

transition?: {
  stiffness?: number;    // Spring stiffness (default: 500)
  damping?: number;      // Spring damping (default: 50)
  bounce?: number;       // Spring bounce (default: 0)
  mass?: number;         // Spring mass
  velocity?: number;     // Initial velocity
}

Implementation Notes

  • Automatically sets parent element position to relative if static
  • Hides default cursor when component is active using CSS cursor: none
  • Uses React Context for efficient state sharing between cursor elements
  • Calculates positioning based on mouse coordinates relative to parent container
  • Spring animations provide smooth, natural following motion with motion/react
  • Elements are positioned with high z-index values for proper layering
  • Supports nested components and complex cursor interactions
  • Integrates seamlessly with shadcn/ui design system and accessibility patterns