Floating Dock
ComponentsFloating Dock
NavigationNew

Floating Dock

A little lift for every destination. Icons grow and make room as your pointer passes.

React + CSS
Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/floating-dock.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { FloatingDock } from '@/components/anticraft/FloatingDock';

export function Example() {
  return (
    <FloatingDock
      activeId="work"
      label="Studio navigation"
      items={[
        { id: 'work', label: 'Work', href: '/#work', icon: <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5"><rect x="4" y="4" width="16" height="16" rx="3" /><path d="M4 10h16M10 10v10" /></svg> },
        { id: 'about', label: 'About', href: '/#about', icon: <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5"><circle cx="12" cy="8" r="3" /><path d="M5 21v-2a7 7 0 0 1 14 0v2" /></svg> },
        { id: 'contact', label: 'Contact', href: '/#contact', icon: <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5"><rect x="3" y="5" width="18" height="14" rx="2" /><path d="m3 6 9 7 9-7" /></svg> },
      ]}
    />
  );
}
03

Props

PropTypeDefaultDescription
itemsFloatingDockItem[]RequiredDestinations with a unique id, visible label, and real href. Replace the example URLs with destinations in your project.
activeIdstringundefinedThe controlled id of the current destination. Only that link receives aria-current="page". Update this from your route or selected section.
labelstring'Primary navigation'The accessible navigation label. Disclosure components also use it for their visible trigger.
onNavigate(id: string, event: MouseEvent<HTMLAnchorElement>) => voidundefinedRuns when a destination is activated. Anchors navigate normally; call event.preventDefault() only when handling navigation yourself, such as a local preview or router adapter.
classNamestring''Additional classes for sizing and CSS custom properties. Each component imports its matching stylesheet; keep both files together.
items[].iconReactNodeRequiredDecorative artwork for each destination. Links receive their accessible name from label; do not put interactive elements inside icons.
04

Motion & accessibility

Considered by default.

Fine mouse movement magnifies nearby artwork while the fixed link targets remain easy to hit. Hover or keyboard focus reveals a label; the current destination has a small marker. Tab reaches every link, and Left/Right, Home, and End provide optional shortcuts. Long docks scroll horizontally. Coarse pointers and reduced motion keep artwork still. Customize the surface, icons, label, and focus colors with --ac-dock-* properties.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.