Skip to content

Morphing Menu Icon

A hamburger-to-close morph that opens a perspective drawer.

CSS 3DTypeScriptLight + AMOLED
Example.tsx
import { Navigation3D } from "@/components/3d/navigation";

export default function Example() {
  return (
    <div style={{ height: 340 }}>
      <Navigation3D
        variant="morph"
        theme="light"
      />
    </div>
  );
}

Deps: framer-motion, lucide-react

Installation

Install the runtime dependencies, then copy the component module (and the shared 3D core when the component uses WebGL).

terminal
npm install framer-motion lucide-react

# Copy the component module
cp -r src/components/3d/navigation <your-project>/src/components/3d/navigation

Dependencies: framer-motion, lucide-react

Usage

Every category module exposes one typed component. Pick an implementation with variant and pass props grouped by concern.

Example.tsx
import { Navigation3D } from "@/components/3d/navigation";

export default function Example() {
  return (
    <div style={{ height: 340 }}>
      <Navigation3D
        variant="morph"
        theme="light"
      />
    </div>
  );
}

React implementation

With every prop set explicitly. The complete, copyable source of src/components/3d/navigation/index.tsx is available in the playground’s Source tab.

Example.tsx
import { Navigation3D } from "@/components/3d/navigation";

export default function Example() {
  return (
    <div style={{ height: 340 }}>
      <Navigation3D
        variant="morph"
        theme="amoled"
        items="Home,Work,About,Contact"
        accent="#5255ff"
        depth={14}
        speed={1}
        reducedMotion={false}
      />
    </div>
  );
}

Next.js implementation

This component is DOM based, but it is still code-split with next/dynamic so interaction code ships only where it's used.

app/morphing-menu-icon/page.tsx
// app/morphing-menu-icon/page.tsx  (Next.js App Router)
"use client";

import dynamic from "next/dynamic";

// Heavy interactive code is split into its own chunk.
const Navigation3D = dynamic(
  () => import("@/components/3d/navigation").then((m) => m.Navigation3D),
  { ssr: false, loading: () => <div aria-busy="true" style={{ height: 340 }} /> },
);

export default function Page() {
  return (
    <main>
      <div style={{ height: 340 }}>
        <Navigation3D
          variant="morph"
          theme="light"
        />
      </div>
    </main>
  );
}

TypeScript interfaces

MorphingMenuIcon.types.ts
export type Theme = "light" | "amoled";

export interface MorphingMenuIconProps {
  /** Which 3D Navigation implementation to render */
  variant: "morph";
  theme: Theme;

  /* Content */
  items?: string; // default "Home,Work,About,Contact"

  /* Visual */
  accent?: string; // default "#5255ff"
  depth?: number; // 4–40, default 14

  /* Animation */
  speed?: number; // 0.4–2.5, default 1

  /* Accessibility */
  reducedMotion?: boolean; // default false
}

Props reference

PropTypeDefaultGroupDescription
variant"morph"—CoreSelects the implementation.
theme"light" | "amoled"—CoreThemes surfaces, materials and lighting.
itemsstring"Home,Work,About,Contact"ContentItems (comma separated)
accentstring (hex)"#5255ff"VisualAccent
depthnumber14VisualDepth / magnification (4 – 40)
speednumber1AnimationSpring speed (0.4 – 2.5)
reducedMotionbooleanfalseAccessibilityForce reduced motion

Customization

Colour props accept any hex string. Content props accept plain strings. Every value shown in the playground maps 1:1 to a prop, so you can design visually and copy the generated code. Use Share to send a pre-configured link or Export to download the configuration JSON.

Customized.tsx
import { Navigation3D } from "@/components/3d/navigation";

export default function Example() {
  return (
    <div style={{ height: 340 }}>
      <Navigation3D
        variant="morph"
        theme="light"
        accent="#ff5a36"
      />
    </div>
  );
}

Animation settings

  • speedSpring speed · 0.4–2.5

All motion is suspended when prefers-reduced-motion is on.

Theme support

Pass theme="light" or theme="amoled". Surfaces, borders, shadows and text switch via CSS variables (--bg, --card, --fg, --border, --accent). AMOLED uses true #000000. Use the theme switch in the playground toolbar to preview both.

Responsive behavior

The component fills its parent, so size it with the container. Use the playground’s desktop / tablet / mobile selector to test. Layouts use fluid widths and container-relative sizing.

Accessibility notes

  • — Navigation landmarks carry aria-label; the current page uses aria-current.
  • — Tabs implement the WAI-ARIA tab pattern with arrow, Home and End keys.
  • — Menus close with Escape and expose aria-expanded.

Performance notes

  • — Layout animation is limited to transforms and opacity.
  • — Dock magnification reads pointer position through motion values.
  • — No external dependencies beyond framer-motion.