Skip to content
IndexRequest a UIAboutContact

Floating Navigation

A detached pill-shaped dock whose icons grow toward the pointer.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a floating dock navigation centred at the bottom of a 520px demo area, with 24px side margins, rounded 22px, a translucent surface with backdrop blur and a 1px border. It contains five icon buttons (44px) with tooltips: Home, Explore, Create, Alerts, Profile. On devices with hover, icons scale up to 1.5x as the pointer gets within 90px horizontally, using a cosine falloff computed in a pointermove handler and applied through a CSS variable --s on each button; reset smoothly with a 200ms transition when the pointer leaves. Keep the layout stable by aligning icons to the bottom so they grow upward. Show a small dot under the current item with aria-current="page". Disable scaling for pointer: coarse and for prefers-reduced-motion. Keyboard focus shows a 2px accent ring.

About this pattern

Definition

A compact navigation bar that floats above the content with a margin on every side instead of touching the screen edge. In this version icons enlarge smoothly as the pointer approaches, in the style of a desktop dock.

Purpose & UX principles

  • Frees the edges of the screen and feels lightweight, which suits portfolios, media apps and tools with a few destinations.
  • Proximity scaling makes small targets easier to hit and gives immediate feedback.
  • Because it floats over content, it needs a solid or blurred background to stay readable.

Interaction states

  • Idle: icons at 44px.
  • Pointer nearby: scale up to 1.5x with falloff over about 90px.
  • Current: small dot under the icon and aria-current="page".
  • Focus-visible: ring around the icon.

Motion specification

  • Scale is computed per frame from pointer distance, with a smooth cosine falloff.
  • Return to idle: 200ms ease-out when the pointer leaves.
  • Reduced motion: no scaling.

Responsive behaviour

  • Touch devices have no hover, so disable the magnify effect and keep icons at a constant 44px.
  • Keep the dock centred and no wider than the viewport minus 24px.

Code

HTML
<div class="area"><p class="hint">Move the pointer over the dock</p>
<nav class="dock" id="dock" aria-label="Dock">
  <button class="d" aria-current="page" aria-label="Home" title="Home">⌂</button>
  <button class="d" aria-label="Explore" title="Explore">✦</button>
  <button class="d" aria-label="Create" title="Create">+</button>
  <button class="d" aria-label="Alerts" title="Alerts">♪</button>
  <button class="d" aria-label="Profile" title="Profile">☺</button>
</nav></div>

Related patterns

Bottom Navigation

↗
Bottom NavigationNavigation

Top Navigation

↗
Top NavigationNavigation

Tab Navigation

↗
Tab NavigationNavigation