Back

Motion Dock Navigation

A polished dock navigation component with expandable sliding panels, spring physics transitions, and per-tab content panels for dashboard interfaces.

Category
NavigationReact
CSS
Tailwind

Manual

Create a file and paste the following code into it.

src/components/dock-nav/dock-nav.constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import type { Variants } from "motion/react";
import {
  House,
  Bell,
  SlidersHorizontal,
  BookOpen,
  Shield,
} from "@phosphor-icons/react";
import type { TabConfig } from "./dock-nav.types";

export const TABS: TabConfig[] = [
  { id: "dashboard", icon: House, label: "Dashboard" },
  { id: "notifications", icon: Bell, label: "Notifications" },
  { id: "settings", icon: SlidersHorizontal, label: "Settings" },
  { id: "changelog", icon: BookOpen, label: "Changelog" },
  { id: "security", icon: Shield, label: "Security" },
];

export const TAB_ORDER = TABS.map((tab) => tab.id);

export const HEIGHT_SPRING = {
  type: "spring",
  stiffness: 280,
  damping: 26,
  mass: 1.0,
} as const;

export const DOCK_SPRING = {
  type: "spring",
  stiffness: 540,
  damping: 40,
  mass: 1,
} as const;

export const SLIDE_SPRING = {
  type: "spring",
  stiffness: 380,
  damping: 34,
  mass: 0.95,
} as const;

export const tabVariants: Variants = {
  enter: (direction: number) => ({
    x: direction >= 0 ? "22%" : "-22%",
    opacity: 0,
  }),
  center: {
    x: "0%",
    opacity: 1,
    transition: SLIDE_SPRING,
  },
  exit: (direction: number) => ({
    x: direction >= 0 ? "-22%" : "22%",
    opacity: 0,
    transition: SLIDE_SPRING,
  }),
};

Update the import paths to match your project setup.

Similar screens