A macOS-style floating dock with magnetic hover animations and keyboard navigation.
Made by raouf.codesOverview
Core Concept
The FloatingDock component provides a macOS-style dock with magnetic hover effects, spring physics animations, and full keyboard accessibility. Built on Framer Motion, it delivers fluid scaling animations based on mouse proximity.
Key Features
- Magnetic hover effect — Icons smoothly scale based on mouse proximity
- Spring animations — Natural feeling physics-based transitions
- Keyboard navigation — Full arrow key support with focus management
- Link obfuscation — Optional base64-encoded hrefs for spam protection
- Variant system — Full support for intent, styling, shape, and elevation
Anatomy
FloatingDock— Root component (context provider, mouse/keyboard handling)FloatingDock.Item— Interactive dock item with animated scalingFloatingDock.Separator— Visual divider between item groupsuseDock()— Hook for custom integrations
Installation
Usage
Basic
With Separator
Using useDock() for custom items
API Reference
FloatingDock (root)
| Prop | Type | Default |
|---|---|---|
orientation? | enum | "vertical" |
size? | enum | "md" |
intent? | enum | "primary" |
styling? | enum | "solid" |
shape? | enum | "pill" |
elevation? | enum | "raised" |
className? | string | - |
...props? | ComponentProps<"div"> | - |
FloatingDock.Item
Azemmur API Reference - Button Primitive
| Prop | Type | Default |
|---|---|---|
item | DockItemData | - |
tabIndex? | number | 0 |
className? | string | - |
...props? | ComponentProps<"a"> | - |
FloatingDock.Separator
| Prop | Type | Default |
|---|---|---|
className? | string | - |
...props? | ComponentProps<"div"> | - |
DockItemData
| Prop | Type | Default |
|---|---|---|
title | string | - |
icon | React.ReactNode | - |
href | string | - |
obfuscated? | boolean | false |
useDock()
Hook to access dock context values for building custom dock items.
| Prop | Type | Default |
|---|---|---|
mousePosition? | MotionValue<number> | - |
orientation? | "vertical" | "horizontal" | - |
size? | "sm" | "md" | "lg" | - |
intent? | "primary" | "accent" | "secondary" | "success" | "info" | "warning" | "error" | - |
styling? | "solid" | "outline" | "ghost" | "link" | - |
shape? | "rounded" | "pill" | "sharp" | - |
elevation? | "raised" | "floating" | - |
Keyboard Navigation
Keyboard navigation adapts to the dock orientation:
Vertical orientation:
| Key | Action |
|---|---|
Arrow Down | Move focus to the next item |
Arrow Up | Move focus to the previous item |
Horizontal orientation:
| Key | Action |
|---|---|
Arrow Right | Move focus to the next item |
Arrow Left | Move focus to the previous item |
Common keys:
| Key | Action |
|---|---|
Enter / Space | Activate the focused link |
Tab | Move focus into/out of the dock |
Accessibility
- ARIA labels — Proper aria-label attributes from item titles
- Focus indicators — Visible focus rings for keyboard navigation
- Role semantics — Links maintain proper anchor semantics
Features
- Magnetic hover effect — Icons smoothly scale based on mouse proximity
- Spring animations — Natural feeling physics-based transitions
- Keyboard navigation — Full arrow key support with focus management
- Link obfuscation — Optional base64-encoded hrefs for spam protection
- Variant system — Full support for intent, styling, shape, and elevation
Credits
- Inspired by macOS dock interactions
- Built with Motion for animations
Built by raouf.codes. The source code is available on GitHub.
Last updated: 3/21/2026