Easeout LabMagnetic Dock

Magnetic Dock

A macOS-style dock: icons swell under the cursor and push their neighbours aside, each on a critically damped spring.

Install

npx shadcn add@easeout/magnetic-dock

Dependencies

motiontailwindcss

Tags

NavigationFree componentMIT

Usage

After installing, it lives at components/magnetic-dock.tsx

app/example.tsx
"use client"

import { MagneticDock } from "@/components/magnetic-dock"

export default function Example() {
  return (
    <MagneticDock
      aria-label="Apps"
      items={[
        { label: "Home", icon: <span aria-hidden="true">⌂</span>, onClick: () => {} },
        { label: "Search", icon: <span aria-hidden="true">⌕</span>, onClick: () => {} },
        { label: "Settings", icon: <span aria-hidden="true">⚙</span>, onClick: () => {} },
      ]}
    />
  )
}

Props

PropTypeDefaultWhat it does
items{ label: string; icon: ReactNode; onClick?: () => void; bg?: string; fg?: string }[]–The icons, with a tile colour and an icon colour each.
maxnumber1.55The biggest scale an icon reaches under the cursor.
autoplaybooleanfalseA virtual cursor sweeps across until a real mouse arrives. Works on touch screens too.
aria-labelstring"Dock"Accessible name of the dock.
classNamestring–Classes for the dock.

Want a whole page built like this?