Components

Dock

A macOS-style dock for React built with Motion and Tailwind CSS: icons magnify smoothly as the cursor approaches, labels fade in on hover and focus, and an active dot glides between apps. Pointer tracking runs on motion values and springs, so it never re-renders — and it works horizontally or vertically.

  • macOS magnification
  • No re-renders
  • Keyboard magnify
  • Vertical option
  • Static on touch
  • prefers-reduced-motion

Installation

$ npx shadcn@latest add https://duskui.com/r/dock.json

The dock doesn't position itself — wrap it in e.g. fixed inset-x-0 bottom-4 flex justify-center. Its bar keeps a fixed height; icons grow out of it, so nothing around it shifts.

Usage

app-dock.tsx
import { Folder, Mail, Settings } from "lucide-react"
import { Dock, DockItem, DockSeparator } from "@/components/dusk/dock/dock"

export function AppDock() {
  return (
    <div className="fixed inset-x-0 bottom-4 flex justify-center">
      <Dock aria-label="Applications">
        <DockItem label="Finder" active>
          <Folder />
        </DockItem>
        <DockItem label="Mail" href="/mail">
          <Mail />
        </DockItem>
        <DockSeparator />
        <DockItem label="Settings">
          <Settings />
        </DockItem>
      </Dock>
    </div>
  )
}

Examples

Vertical

position="left" (or right) stands the dock up: icons grow to the side, labels open the other way and Up / Down arrows move between items. Tune iconSize and magnification to fit a sidebar.

Give items an href to render links (the active one gets aria-current="page"), or use asChild with your router's Link. position="top" grows icons downward; a smaller distance makes the swell tighter.

API Reference

Dock renders a nav with a list; DockItem renders a button, a link (href) or your element (asChild) and accepts its props; DockSeparator draws a divider.

PropTypeDefaultDescription
position"bottom" | "top" | "left" | "right""bottom"On Dock: the edge it sits on. Icons grow away from it; left / right are vertical.
iconSizenumber44On Dock: resting icon size in px.
magnificationnumber72On Dock: size of the icon under the cursor in px.
distancenumber140On Dock: how far from the cursor icons start to grow, in px.
disableMagnificationbooleanfalseOn Dock: keep icons static.
aria-labelstring"Dock"On Dock: names the navigation landmark.
labelstring—On DockItem: accessible name, shown as the hover / focus label.
activebooleanfalseOn DockItem: shows the gliding dot and sets aria-current.
href / asChildstring / boolean—On DockItem: render a link or your own element.

Accessibility

  • The dock is a nav landmark containing a list; every item is a real button or link named by its label, so screen readers never depend on the icon.
  • Tab reaches each item, and arrow keys (Left / Right, or Up / Down when vertical) plus Home / End move between them.
  • Keyboard focus magnifies the focused icon and its neighbours and shows its label, just like hovering.
  • Active items carry aria-current ("page" for links); the active dot and the floating label are decorative and aria-hidden.
  • Magnification only follows a mouse — touch screens get a static, tappable dock — and it's off entirely under prefers-reduced-motion.