Smooth Cursor
Install: npx shadcn@latest add https://jiguang132.com/r/magic-ui/smooth-cursor.json
Use case
Follow pointer movement with a spring-smoothed cursor.
Native props used by the examples
Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.
Examples use native defaults without additional props; optional API is in the source reference.
Interaction and state checks
- smooth-cursor-demo —
smooth-cursor-demo
These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.
Business integration boundary
The cursor belongs to the current document and is decorative. Avoid duplicating cursor engines or hiding essential native affordances.
Host and motion setup
Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.
Available examples
smooth-cursor-demo
Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.
Features
- 🎯 Smooth physics-based cursor animations
- 🔄 Rotation effects based on movement direction
- ⚡ Performance optimized with RAF
- 🎨 Fully customizable cursor design
- 📦 Lightweight and easy to implement
Installation
<Tabs defaultValue="cli"> <TabsList> <TabsTrigger value="cli">CLI</TabsTrigger> <TabsTrigger value="manual">Manual</TabsTrigger> </TabsList> <TabsContent value="cli">npx shadcn@latest add @magicui/smooth-cursor
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
<Step>Add the component to your page or layout.</Step>
import { SmoothCursor } from "@/components/ui/smooth-cursor"
export default function Page() {
return (
<>
<SmoothCursor />
{/* Your page content */}
</>
)
}
</Steps>
</TabsContent>
</Tabs>
Usage
import { SmoothCursor } from "@/components/ui/smooth-cursor"
<SmoothCursor />
Hiding Default Browser Cursor
To prevent the default browser cursor from overlapping with the custom cursor, add the following CSS globally:
* {
cursor: none !important;
}
Optional: Keep text cursor for inputs
input,
textarea,
select {
cursor: text !important;
}
💡 If you're using Tailwind CSS, you can add cursor-none to your layout wrapper:
<div className="cursor-none">
<SmoothCursor />
{/* your app */}
</div>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
cursor | React.ReactNode | <DefaultCursorSVG /> | Custom cursor component to replace the default cursor |
springConfig | SpringConfig | See below | Configuration object for the spring animation behavior |
SpringConfig Type
interface SpringConfig {
damping: number // Controls how quickly the animation settles
stiffness: number // Controls the spring stiffness
mass: number // Controls the virtual mass of the animated object
restDelta: number // Controls the threshold at which animation is considered complete
}
Default Spring Configuration
const defaultSpringConfig = {
damping: 45,
stiffness: 400,
mass: 1,
restDelta: 0.001,
}
Browser Support
Compatible with all modern browsers that support:
requestAnimationFrame- CSS transforms
- Pointer events
- Hover-capable fine pointers (mouse or trackpad)
Touch-first devices are ignored automatically to prevent the custom cursor from appearing after taps.
Accessibility
When using this component, consider that:
- Users navigating via keyboard will not see the custom cursor
- You may want to provide alternative visual cues for interactive elements
- Some users may have motion sensitivity, so consider providing a way to disable the animation
Credits
- Credit to @Code_Parth for the original concept and implementation
Complete example installation
The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.
smooth-cursor-demo
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/smooth-cursor/smooth-cursor-demo.json
Default import: @/components/magicui/examples/smooth-cursor-demo
Dependencies: clsx@2.1.1, motion@12.42.2, tailwind-merge@3.6.0
Minimal usage and theme
import Demo from '@/components/magicui/examples/smooth-cursor-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}
Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
SmoothCursor({
cursor = <DefaultCursorSVG />,
springConfig = {
damping: 45,
stiffness: 400,
mass: 1,
restDelta: 0.001,
},
}: SmoothCursorProps)
export interface SmoothCursorProps {
cursor?: React.ReactNode
springConfig?: {
damping: number
stiffness: number
mass: number
restDelta: number
}
}
Destructuring defaults in source
Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.
// SmoothCursor
cursor = <DefaultCursorSVG />
// SmoothCursor
springConfig = {
damping: 45,
stiffness: 400,
mass: 1,
restDelta: 0.001,
}
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
React.ReactNode