# Dock

> A macOS style dock for React: icons magnify under the pointer with spring physics and show a label. Real buttons or links, keyboard reachable and labelled.

- Kind: Motion component (Navigation)
- Docs: https://ui.minidev.pro/docs/dock
- Source (registry JSON with the full file): https://ui.minidev.pro/r/dock.json
- License: MIT. One file, yours to edit after install.

## When to use

Every item is a real button (with `onClick`) or link (with `href`), reachable and labelled for keyboard and screen reader users; focus shows the label too. Magnification is pointer only and off for reduced motion. Use it for an app launcher or a playful bottom nav on marketing pages; for product navigation use a sidebar or Tabs.

## Installation

### shadcn CLI (copies the source into your project)

```bash
npx shadcn@latest add @minidev/dock
```

Writes `components/ui/dock.tsx` and installs its npm dependencies. Older CLI versions: `npx shadcn@latest add https://ui.minidev.pro/r/dock.json`.

### npm package

```bash
npm i minidev-ui-kit lucide-react motion
```

Add the tokens to your global stylesheet once:

```css
@import "tailwindcss";
@import "minidev-ui-kit/styles.css";
@source "../node_modules/minidev-ui-kit";
```

Next.js also needs `transpilePackages: ["minidev-ui-kit"]` in next.config.

## Import

After the shadcn install:

```tsx
import { Dock } from "@/components/ui/dock"
```

From the npm package:

```tsx
import { Dock } from "minidev-ui-kit/premium/dock"
```

## Usage

```tsx
import { Dock } from "@/components/ui/dock"

export function Example() {
  return (
    <Dock />
  )
}
```

## Props

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `items` | `DockItem[]` | `DEFAULT` | no |  |
| `label` | `string` | `"Dock"` | no | Accessible name of the dock's nav landmark. |
| `size` | `number` | `44` | no | Resting icon size in pixels. |
| `magnify` | `number` | `68` | no | Size under the pointer. |
| `distance` | `number` | `130` | no | How far the swell reaches, in pixels. |
| `className` | `string` | - | no |  |

## Examples

### Custom items with links

Each item takes a label and a lucide icon; with href it renders a link, and active adds the dot underneath.

```tsx
<Dock
  items={[
    { label: "Overview", icon: HouseIcon, href: "#overview", active: true },
    { label: "Invoices", icon: FileTextIcon, href: "#invoices" },
    { label: "Customers", icon: UsersIcon, href: "#customers" },
    { label: "Reports", icon: ChartBarIcon, href: "#reports" },
    { label: "Settings", icon: SettingsIcon, href: "#settings" },
  ]}
/>
```

### Bigger swell

size is the resting icon, magnify the size under the pointer and distance how far the swell reaches.

```tsx
<Dock size={40} magnify={88} distance={180} />
```

### Active item

Keep the current page in state and set active and onClick per item to use the dock as app navigation.

```tsx
const PAGES = [
  { label: "Overview", icon: HouseIcon },
  { label: "Invoices", icon: FileTextIcon },
  { label: "Customers", icon: UsersIcon },
  { label: "Reports", icon: ChartBarIcon },
]

function AppDock() {
  const [page, setPage] = React.useState("Invoices")
  return (
    <div className="flex flex-col items-center gap-3">
      <p className="text-sm text-fg-muted">
        Open: <span className="font-medium text-fg">{page}</span>
      </p>
      <Dock items={PAGES.map((p) => ({ ...p, active: p.label === page, onClick: () => setPage(p.label) }))} />
    </div>
  )
}
```

## Keyboard interactions

| Key | Action |
| --- | --- |
| `Tab` | Moves to each dock item and shows its label above it. |
| `Enter` | Follows the link, or runs `onClick` on a button item. |
| `Space` | Activates a button item. |

## Accessibility

- The dock is a `<nav>` named by `label` (default "Dock"). Each item has `aria-label` from its `label`, and the active one has `aria-current="page"`.
- The floating label and the running dot are `aria-hidden`, so names are not read twice. The label also shows on keyboard focus.

## FAQ

### Can Dock items be Next.js links?

An item with `href` renders a plain `<a>`, not a Next.js `Link`, so it does a full page load. For client-side navigation, use `onClick` with `router.push`, or edit the `motion.a` in the file.

### Does the magnification work on phones?

It is made for a mouse. The swell follows `pointermove` across the dock, so on touch the icons mostly stay at `size` (44px). Under reduced motion `magnify` is ignored and icons never grow.

## Rules for generating code

- Use semantic tokens only (bg, surface, sunken, border, fg, fg-muted, fg-subtle, ink, accent, success, warning, danger). Never raw hex or palette steps like blue-500.
- Shadows only from the set: shadow-xs, shadow-sm, shadow-raised, shadow-md, shadow-lg, shadow-overlay.
- Numbers use tabular-nums. Dark mode is the `dark` class on <html>; components never branch on theme.

## Dependencies

- npm: `lucide-react`, `motion`

## Related

- [Tabs](https://ui.minidev.pro/docs/tabs/md): Tabs on Base UI with a raised thumb or a line underline that springs to the active tab, optional count badges, vertical orientation and roving keyboard focus.
- [Scroll Progress Rail](https://ui.minidev.pro/docs/scroll-progress-rail/md): A React reading progress bar that fills with page scroll on a spring, with section labels such as intro, product, proof and pricing shown beneath it.
- [Animated Tabs](https://ui.minidev.pro/docs/animated-tabs/md): Tabs with a sliding pill indicator and panels that fade in the direction of travel. Full WAI-ARIA tabs keyboard support with Arrow keys, Home and End.
- [Back Link](https://ui.minidev.pro/docs/back-link/md): Small back navigation link with a left arrow icon, muted text that darkens on hover and a visible focus ring. Defaults to the label Back and accepts any href.
- [Breadcrumb Ellipsis](https://ui.minidev.pro/docs/breadcrumb-ellipsis/md): Ellipsis marker for collapsing the middle of long breadcrumb trails. Decorative and hidden from assistive tech, sized to sit between breadcrumb separators.
- [Breadcrumb](https://ui.minidev.pro/docs/breadcrumb/md): Breadcrumb navigation from an items array, with chevron separators, linked ancestors and the current page marked with aria-current. Built with React.

---

All 557 components: https://ui.minidev.pro/llms.txt (full text: https://ui.minidev.pro/llms-full.txt).
