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
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 animationsDockItem
- Individual items within the dock that respond to magnificationDockIcon
- The icon container that scales with the magnification effectDockLabel
- 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
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | - | The dock items |
className | string | - | Additional CSS classes |
distance | number | 150 | The distance for magnification effect |
panelHeight | number | 64 | The height of the dock panel |
magnification | number | 80 | The maximum magnification size |
spring | SpringOptions | { mass: 0.1, stiffness: 150, damping: 12 } | Framer Motion spring configuration |
DockItem
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | - | The item content (DockIcon and DockLabel) |
className | string | - | Additional CSS classes |
DockIcon
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | - | The icon content |
className | string | - | Additional CSS classes |
DockLabel
Prop | Type | Default | Description |
---|---|---|---|
children | React.ReactNode | - | The label text content |
className | string | - | 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:
- Mouse tracking: Real-time cursor position monitoring with smooth coordinate updates
- Distance calculation: Geometric distance computation between cursor and each dock item
- 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
Safari
Authentic Safari browser mockup featuring macOS design elements and customizable URL display. A JavaScript component that works seamlessly in React and Next.js projects with full TypeScript support and shadcn/ui compatibility.
LimelightNav
Smart navigation component with dynamic limelight highlighting and adaptive width. A JavaScript-powered React component for Next.js featuring TypeScript integration and shadcn/ui compatibility.