Join our Discord Community
Dock

Dock

Animated macOS-style dock component with magnification effects and smooth spring physics. A free React component for Next.js featuring TypeScript support and Tailwind CSS integration with shadcn/ui.

Powered by

Loading component...

Installation

npx shadcn@latest add https://www.shadcn.io/registry/dock.json
npx shadcn@latest add https://www.shadcn.io/registry/dock.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/dock.json
bunx shadcn@latest add https://www.shadcn.io/registry/dock.json

Features

  • Free open source React component built for Next.js applications with professional macOS dock functionality
  • Dynamic magnification effects using advanced Framer Motion spring physics with JavaScript-powered interactions
  • TypeScript-first development with comprehensive type definitions and IntelliSense support for reliable development
  • Tailwind CSS integration for seamless styling, dark mode support, and responsive design patterns
  • shadcn/ui compatibility following established design system patterns and component architecture
  • Interactive tooltip labels that appear smoothly on hover with animated positioning
  • Configurable spring animations with customizable stiffness, damping, and mass properties
  • Keyboard navigation support with full accessibility compliance and ARIA label implementation
  • Responsive overflow handling with horizontal scrolling for larger dock configurations
  • Customizable magnification distance and strength for precise user experience control
  • Performance optimized with efficient mouse tracking and minimized re-renders

Usage

The dock component consists of four main parts:

  • Dock - The main container that handles mouse tracking and animations
  • DockItem - Individual items within the dock that respond to magnification
  • DockIcon - The icon container that scales with the magnification effect
  • DockLabel - Tooltip labels that appear when hovering over items
import { Dock, DockIcon, DockItem, DockLabel } from '@/components/ui/dock';

<Dock>
  <DockItem>
    <DockLabel>Home</DockLabel>
    <DockIcon>
      <HomeIcon />
    </DockIcon>
  </DockItem>
</Dock>

Props

Dock

PropTypeDefaultDescription
childrenReact.ReactNode-The dock items
classNamestring-Additional CSS classes
distancenumber150The distance for magnification effect
panelHeightnumber64The height of the dock panel
magnificationnumber80The maximum magnification size
springSpringOptions{ mass: 0.1, stiffness: 150, damping: 12 }Framer Motion spring configuration

DockItem

PropTypeDefaultDescription
childrenReact.ReactNode-The item content (DockIcon and DockLabel)
classNamestring-Additional CSS classes

DockIcon

PropTypeDefaultDescription
childrenReact.ReactNode-The icon content
classNamestring-Additional CSS classes

DockLabel

PropTypeDefaultDescription
childrenReact.ReactNode-The label text content
classNamestring-Additional CSS classes for custom styling

Use Cases

This free open source React component is perfect for:

  • Next.js applications - Create professional desktop-like navigation with TypeScript integration and type safety
  • Dashboard interfaces - Build intuitive navigation bars with macOS-inspired design using shadcn/ui patterns
  • Portfolio websites - Showcase applications with sophisticated dock navigation using Tailwind CSS styling
  • Admin panels - Implement elegant application launchers with smooth animations and JavaScript interactions
  • Creative portfolios - Design unique navigation experiences that stand out with professional animation effects
  • SaaS applications - Create memorable user interfaces with dock-style navigation and open source flexibility
  • Design systems - Integrate premium navigation components into existing shadcn/ui component libraries

Technical Details

Magnification Algorithm

The dock uses advanced mouse proximity calculation with Framer Motion transforms:

  1. Mouse tracking: Real-time cursor position monitoring with smooth coordinate updates
  2. Distance calculation: Geometric distance computation between cursor and each dock item
  3. Transform application: Smooth scaling transitions based on configurable distance thresholds

Performance Optimizations

  • Efficient re-rendering with React context optimization and minimal state updates
  • Framer Motion springs with optimized physics calculations for smooth 60fps animations
  • TypeScript-optimized component structure with proper memoization and prop validation
  • Tailwind CSS classes for consistent theming without runtime style computation

Accessibility

This open source component includes comprehensive accessibility features:

  • ARIA label implementation with proper toolbar and button role assignments for screen readers
  • Keyboard navigation support with tab order management and focus indication
  • React-compatible focus handling when used in interactive Next.js applications
  • High contrast compatibility with automatic dark mode adaptation using Tailwind CSS
  • Responsive design patterns that work across all device sizes and orientations