Special effects
Magnetic
Interactive magnetic attraction effects that follow cursor movement. Perfect for React applications requiring engaging hover animations with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/magnetic.json
npx shadcn@latest add https://www.shadcn.io/registry/magnetic.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/magnetic.json
bunx shadcn@latest add https://www.shadcn.io/registry/magnetic.json
Features
- Smooth magnetic attraction with configurable strength and range using Motion for fluid animations
- Customizable spring physics with adjustable stiffness, damping, and mass parameters
- Hover activation modes supporting always-on or hover-only magnetic behavior
- Touch device detection with automatic disabling on touch interfaces for optimal UX
- TypeScript support with complete interface definitions and prop validation
- shadcn/ui compatibility using standard React patterns and flexible styling
Use Cases
This free open source React component works well for:
- Interactive buttons - Call-to-action elements with magnetic hover effects built with Next.js
- Portfolio showcases - Creative portfolio items using TypeScript and Tailwind CSS
- Landing page elements - Hero section components that engage users on scroll
- Gaming interfaces - Interactive UI elements for games and immersive experiences
API Reference
Magnetic
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactElement | required | Single child element to apply magnetic effect to |
strength | number | 0.5 | Magnetic attraction strength factor (0-1) |
range | number | 120 | Detection range in pixels from element center |
springOptions | SpringOptions | { stiffness: 100, damping: 10, mass: 0.5 } | Motion spring configuration object |
onlyOnHover | boolean | false | Only activate magnetic effect when hovering element |
disableOnTouch | boolean | true | Disable effect on touch devices for performance |
Spring Options
- stiffness - Spring stiffness value (higher = snappier)
- damping - Spring damping factor (higher = less oscillation)
- mass - Element mass simulation (higher = slower response)
Implementation Notes
- Wraps children in a motion.div with inline-block display
- Uses global mousemove listener for cursor tracking
- Automatically detects touch devices via media queries
- Smooth spring animations with configurable physics
- Compatible with shadcn/ui design system
Animated Beam
Animated beam connection component for React and Next.js applications. Built with TypeScript support, Tailwind CSS styling, and shadcn/ui design featuring SVG path animations, bidirectional flow, and customizable gradients.
Motion Highlight
Versatile highlight component with smooth animations for interactive UI elements. Perfect for React applications requiring dynamic visual feedback with Next.js integration and TypeScript support.