How frontendfyi/macos-dock-animation-with-css works
This is a small React/TypeScript demonstration recreating the macOS Dock hover animation. The browser mounts the dock, and pointer movement over an icon computes a bounded horizontal offset that is written to CSS custom properties for the stylesheet to animate. The README describes CSS :has() and variables as the animation technique. Source excerpts establish the runtime calls and data updates; the stylesheet itself was not sampled, so its specific selectors and styling behavior are represented only at the documented level.
Main entry points: App.tsx Dock UI and hover handler · main.tsx React mount · index.css CSS dock animation · scale.ts Bounded offset scaling
Components 5
Browser runtime
- React mount
src/main.tsx
Dock interaction
- Dock UI and hover handler
src/App.tsx - Bounded offset scaling
src/utils/scale.ts - CSS dock animation
src/index.css
Other components
- Desktop visitor
Connections 5
- Desktop visitor → React mount: opens app
src/main.tsx - React mount → Dock UI and hover handler: renders
src/main.tsx - Dock UI and hover handler → Bounded offset scaling: scales cursor position
src/App.tsx - Dock UI and hover handler → CSS dock animation: sets CSS variables
src/App.tsx - Dock UI and hover handler → CSS dock animation: imports styles
src/App.tsx