# Magnifying dock

> A dock that makes room for the tool you reach for, then opens it in place.

Most docks magnify and stop there. This one is a single surface that grows into the tool you choose. Sweep across it and nearby tools swell while the row parts around them, one label glides above with its letters morphing, and a soft pad rides under the selected tool. Choose a tool with content and the tray itself rises into its panel; switch tools and the panel slides in from the side you moved toward. Every moving part is a transform eased by one frame loop that sleeps when it settles: no layout and no React renders while you move.

## Install

```bash
npx shadcn@latest add @hairline/magnifying-dock
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `text-morph`, `number-roll`
- Docs and live preview: https://hairlineui.com/ui/magnifying-dock
- Registry item (source): https://hairlineui.com/r/magnifying-dock.json

## Usage

```tsx
import { Inbox, CalendarDays, NotebookPen } from "lucide-react";
import { MagnifyingDock } from "@/components/magnifying-dock";

<MagnifyingDock
  items={[
    { id: "inbox", label: "Inbox", icon: <Inbox />, badge: 3, content: <InboxPreview /> },
    { id: "calendar", label: "Calendar", title: "Today", icon: <CalendarDays />, content: <Agenda /> },
    { id: "notes", label: "Notes", icon: <NotebookPen />, content: <QuickNote /> },
  ]}
/>
```

## Open real views from it

Selection and the open panel can both be controlled, so the dock can follow your router or close when work elsewhere starts.

```tsx
"use client";
import { useState } from "react";
import { MagnifyingDock, type DockItem } from "@/components/magnifying-dock";

export function WorkspaceDock({ tools }: { tools: DockItem[] }) {
  const [view, setView] = useState(tools[0]?.id);
  const [open, setOpen] = useState(false);
  return (
    <MagnifyingDock
      items={tools}
      value={view}
      onValueChange={setView}
      open={open}
      onOpenChange={setOpen}
      label="Workspace"
    />
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `DockItem[]` | – | Each tool: id, label, icon, and optionally content (what it opens into), title (the panel heading, defaults to label), badge (a count) and disabled. |
| `value / defaultValue` | `string` | – | Controlled selected tool or the initial one. Defaults to the first enabled tool. |
| `onValueChange` | `(id: string) => void` | – | Called when a different tool is chosen. |
| `open / defaultOpen` | `boolean` | – | Whether the selected tool’s panel is open. Tools without content never open. |
| `onOpenChange` | `(open: boolean) => void` | – | Called when the panel opens or folds away. |
| `size` | `number` | `40` | Rest size of a tool in pixels, 32–56. |
| `magnification` | `number` | `1.6` | Peak scale under the pointer, 1–2. It eases down to 1.22 while a panel is open so tools stay clear of it. |
| `panelWidth` | `number` | `340` | Width of the open panel; it never exceeds the space available. |
| `label` | `string` | `Tools` | Accessible name for the toolbar. |

## States

- **lens**: Tools within 2.4 tool-widths of the pointer scale up on a cosine falloff and the row parts around them; the tray widens to fit. Distances use fixed rest positions, so growth never moves the target under the pointer.
- **label**: One label follows the nearest tool, lifting above its current height; when the tool changes, its words morph letter by letter.
- **select**: The pad glides to the chosen tool and keeps riding its magnification as you sweep.
- **open**: A tool with content grows the tray up into its panel: width, height and corners ease together, the title morphs, and the content fades in. Switching tools slides the new panel in from the side you moved toward while its height eases.
- **close**: Choosing the open tool again, Escape or a click outside folds the panel back into the tray. Escape returns focus to the tool.
- **badge**: A count on a tool rolls when it changes and folds away at zero.

## What it handles

Most docks magnify icons and stop there. This one is a tool tray: it makes room for the tool you reach for, then opens that tool in place.

- **Icons swell near the pointer**: Tools close to the pointer scale up and the row parts around them. Distances use fixed rest positions, so the target never slides away.
- **One label that follows**: A single label follows the nearest tool, and its letters morph when the tool changes.
- **The tray becomes the panel**: A tool with content grows the tray up into its panel. Switching tools slides the new panel in from the side you moved toward.
- **Badges that roll**: A count on a tool rolls when it changes and folds away at zero.
- **Keyboard like a toolbar**: One tab stop, arrow keys, Home and End. Keyboard focus magnifies like the pointer.
- **Light on the page**: One frame loop writes only transforms and sleeps when nothing moves. Touch skips the lens and opens tools directly.

## Replaces

dock magnification maths, a toolbar, a popover per tool, tooltips, badge counts

## Where it fits

- **Floating tool trays**: A tray of notes, search and settings that opens each tool in place.
- **Portfolio and personal sites**: Navigation between sections that feels like a toolbar.
- **Product demo pages**: A dock of features where each one opens a small preview.
- **Admin quick actions**: The handful of tools people reach for all day, one click away.

## Notes

- The tools form a toolbar: one tab stop, Left and Right (and Home, End) move between enabled tools, and keyboard focus magnifies like the pointer.
- Tools with content are disclosure buttons (aria-expanded, aria-controls) for a labelled panel region that follows them in the tab order; tools without content are toggle buttons.
- Touch skips the lens and opens tools directly. Reduced motion removes the lens and every eased move; states change in place.
- One frame loop eases the lens, pad, label and tray, writes only transforms and the tray’s size, and stops when everything settles, so a resting dock costs nothing.

License: MIT (https://hairlineui.com/license#components)
