Magnetic Cursor Dock

macOS-style dock with magnetic cursor effect. Items scale and lift as cursor approaches.

Last updated Mar 5, 2026

Component

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/magnetic-cursor-dock.json"

Usage

Import

Add the MagneticCursorDock import.

import { MagneticCursorDock } from "@/components/magnetic-cursor-dock";

Use

Wrap your dock items.

<MagneticCursorDock>{/* items */}</MagneticCursorDock>;

Guidelines

  • Pass children as dock items. Each child gets the magnetic effect.
  • Use maxDist, scaleFactor, liftAmount to tune the effect.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
classNamestringAdditional CSS classes for the dock container.
dockClassNamestringAdditional classes for the dock (merged with className).
maxDistnumber90Max distance (px) for magnetic effect.
scaleFactornumber1.2Scale factor when cursor is near.
liftAmountnumber8Lift amount (px) when cursor is near.

Examples

Basic

Basic dock with icon items.

import { MagneticCursorDock } from "@/components/magnetic-cursor-dock";
import { Home, Search, Mail } from "lucide-react";

<MagneticCursorDock className="h-24">
  <div className="flex size-12 items-center justify-center rounded-xl bg-zinc-800">
    <Home className="size-6 text-white" />
  </div>
  <div className="flex size-12 items-center justify-center rounded-xl bg-zinc-800">
    <Search className="size-6 text-white" />
  </div>
  <div className="flex size-12 items-center justify-center rounded-xl bg-zinc-800">
    <Mail className="size-6 text-white" />
  </div>
</MagneticCursorDock>;

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: