Target Cursor
A custom animated cursor component with GSAP. Features spinning animation, corner tracking on hover, and parallax effects. Perfect for interactive websites.
Installation
npm install gsap reactpnpm install gsap reactyarn add gsap reactbun add gsap reactUsage
import { TargetCursor } from "@/components/ui/target-cursor";
export default function MyComponent() {
return (
<div>
<TargetCursor
spinDuration={2}
hideDefaultCursor={true}
parallaxOn={true}
/>
<button className="cursor-target">Hover me!</button>
<div className="cursor-target">Another target</div>
</div>
);
}Features
- 🎯 Custom Cursor: Replaces default cursor with animated custom cursor
- 🔄 Spinning Animation: Continuous rotation animation when idle
- 📐 Corner Tracking: Corners expand to frame hovered elements
- 🎨 Parallax Effect: Smooth parallax movement of corners
- 📱 Mobile Detection: Automatically disabled on mobile devices
- ⚡ GSAP Powered: Smooth animations powered by GSAP
- 🎭 Click Animation: Scale animation on mouse down/up
Props
| Prop | Type | Default | Description |
|---|---|---|---|
targetSelector | string | ".cursor-target" | CSS selector for target elements |
spinDuration | number | 2 | Duration of spin animation in seconds |
hideDefaultCursor | boolean | true | Hide the default browser cursor |
hoverDuration | number | 0.2 | Duration of hover animation |
parallaxOn | boolean | true | Enable parallax effect on corners |
Examples
Basic Usage
<TargetCursor />
<button className="cursor-target">Hover me</button>Custom Selector
<TargetCursor targetSelector=".my-custom-target" />
<div className="my-custom-target">Custom target</div>Faster Spin
<TargetCursor spinDuration={1} />Without Parallax
<TargetCursor parallaxOn={false} />Keep Default Cursor
<TargetCursor hideDefaultCursor={false} />Styling Targets
Add the cursor-target class (or your custom selector) to any element you want the cursor to interact with:
<button className="cursor-target">Button</button>
<div className="cursor-target">Div</div>
<a href="#" className="cursor-target">Link</a>Mobile Support
The component automatically detects mobile devices and returns null to avoid conflicts with touch interactions. It checks for:
- Touch screen capability
- Screen size (≤768px)
- User agent string
Scroll Animation
Motion Number is a component that displays a number with a motion effect.
Bento Grids
Bento grids are a flexible and responsive layout system that allows you to create complex grid structures with ease. They are designed to adapt to various screen sizes and orientations, making them ideal for modern web applications.
