Floating Dock
- Source
- Aceternity UI ↗
- Author
- Aceternity UI
- Licence
- Aceternity UI licence (free component)
Loading…
A macOS-style dock whose icons magnify toward the pointer.
Code
"use client";
import React from "react";
import { Fit } from "./_fit";
import { FloatingDock } from "@/lab/aceternity/ui/floating-dock";
import {
IconBrandGithub,
IconBrandX,
IconExchange,
IconHome,
IconNewSection,
IconTerminal2,
} from "@tabler/icons-react";
export default function FloatingDockDemo() {
const links = [
{
title: "Home",
icon: (
<IconHome className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
{
title: "Products",
icon: (
<IconTerminal2 className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
{
title: "Components",
icon: (
<IconNewSection className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
{
title: "Aceternity UI",
icon: (
// eslint-disable-next-line @next/next/no-img-element
<img
src="https://assets.aceternity.com/logo-dark.png"
width={20}
height={20}
alt="Aceternity Logo"
/>
),
href: "#",
},
{
title: "Changelog",
icon: (
<IconExchange className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
{
title: "Twitter",
icon: (
<IconBrandX className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
{
title: "GitHub",
icon: (
<IconBrandGithub className="h-full w-full text-neutral-500 dark:text-neutral-300" />
),
href: "#",
},
];
return (
<Fit width={560} height={240} max={1.6}>
<div className="flex items-center justify-center h-full w-full">
<FloatingDock desktopClassName="flex" mobileClassName="hidden" items={links} />
</div>
</Fit>
);
}
Prompt
Build "Floating Dock", a navigation animation. What it does: A macOS-style dock whose icons magnify toward the pointer. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using @tabler/icons-react, motion. Technique: the Motion library, pointer tracking. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/floating-dock (Aceternity UI, Aceternity UI licence (free component)).