StealThis .dev

macOS Dock

A macOS-style dock with smooth icon magnification on hover. Icons scale up based on proximity to the cursor, creating a fluid fisheye effect.

Open in Lab
css javascript vue svelte
Targets: TS JS HTML React Vue Svelte

Code

macOS Dock

A faithful recreation of the macOS Dock magnification effect using vanilla CSS and JavaScript. Icons smoothly scale up based on their distance from the cursor, creating the signature fisheye lens feel.

How it works

  1. A horizontal flex container positions dock items along the bottom of the viewport.
  2. On mousemove, the script calculates each icon’s center relative to the cursor X position.
  3. A gaussian-like falloff function determines the scale factor: items closest to the cursor get the maximum scale, while distant items remain at base size.
  4. CSS transition on transform keeps the scaling buttery smooth.

Features

  • Smooth fisheye magnification with configurable scale and range
  • Tooltip labels on hover
  • Responsive — works on different viewport widths
  • prefers-reduced-motion respected