# Dock

> Icon dock on a lit glass shelf: icons swell on a smooth cosine curve toward the pointer, a soft pool of light and a brightening edge follow it across the shelf, and a small dot and floor reflection mark the icon underneath.

- Package: `fancy-ui-svelte` (Svelte 5 + Tailwind CSS v4)
- Category: Navigation
- Tags: dock, navigation, launcher, magnification, hover, spotlight
- Types: `DataOrientation`, `Direction`, `DockContext`
- Docs: https://fancy-ui.rama.app/docs/components/dock
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/src/lib/fancy-ui/dock

## Import

```svelte
<script lang="ts">
  import { Dock } from 'fancy-ui-svelte';
</script>
```

Setup (once per project): `npm install fancy-ui-svelte`, then add `@import "fancy-ui-svelte/tailwind.css";` after `@import "tailwindcss";` in your main CSS file. Full guide: https://fancy-ui.rama.app/llms.txt

React: `import { Dock } from 'fancy-ui-react';` (`class` becomes `className`, snippets become `ReactNode`, DOM callbacks are camel-cased; exact names on https://fancy-ui.rama.app/docs/components/react/dock.md).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `magnification` | `number` | `60` | Maximum icon size in pixels when magnified |
| `distance` | `number` | `140` | Pointer distance over which the magnification falls off (cosine curve) |
| `direction` | `"top" \| "middle" \| "bottom"` | `"middle"` | Cross-axis alignment of the icons |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Dock orientation |
| `spotlight` | `boolean` | `true` | Soft pool of accent light that follows the pointer inside the shelf, plus a lit shelf edge near the pointer |
| `reflection` | `boolean` | `true` | Soft contact shadow (light) / accent glow (dark) ellipse under each icon that grows with it |
| `ariaLabel` | `string` | `undefined` | Accessible name for the toolbar, rendered as aria-label |

## Snippets

| Snippet | Description |
| --- | --- |
| `children` | DockIcon and DockSeparator elements |

## Examples

### Basic Usage

A lit glass shelf of app tiles resting on a quiet floor.

```svelte
<script lang="ts">
	import { Dock, DockIcon, DockSeparator } from "fancy-ui-svelte";
	import House from "@lucide/svelte/icons/house";
	import Search from "@lucide/svelte/icons/search";
	import Inbox from "@lucide/svelte/icons/inbox";
	import Calendar from "@lucide/svelte/icons/calendar";
	import Music from "@lucide/svelte/icons/music";
	import Settings from "@lucide/svelte/icons/settings";
	import Trash2 from "@lucide/svelte/icons/trash-2";

	const apps = [
		{ label: "Home", icon: House },
		{ label: "Search", icon: Search },
		{ label: "Inbox", icon: Inbox },
		{ label: "Calendar", icon: Calendar },
		{ label: "Music", icon: Music },
	];
	const system = [
		{ label: "Settings", icon: Settings },
		{ label: "Trash", icon: Trash2 },
	];

	// One tile look for every app: a squircle with a top-lit face and a hairline.
	const tile =
		"grid size-full place-items-center rounded-[30%] border border-black/[0.07] bg-gradient-to-b from-white to-zinc-100 text-zinc-700 shadow-[inset_0_1px_0_rgba(255,255,255,1),0_1px_2px_rgba(0,0,0,0.06)] outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/60 dark:border-white/[0.08] dark:from-[#26262a] dark:to-[#141416] dark:text-zinc-200 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),0_1px_2px_rgba(0,0,0,0.6)]";
</script>

<!-- Outer frame, inner stage: the dock rests on a quiet floor. -->
<div
	class="w-full max-w-2xl rounded-[22px] border border-black/[0.06] bg-black/[0.015] p-1.5 dark:border-white/[0.06] dark:bg-white/[0.02]"
>
	<div
		class="relative flex h-64 items-end justify-center overflow-hidden rounded-2xl border border-black/[0.06] bg-[#fafafa] pb-10 dark:border-white/[0.06] dark:bg-[#0b0b0c]"
	>
		<div
			aria-hidden="true"
			class="pointer-events-none absolute inset-x-0 bottom-0 h-2/3 bg-[radial-gradient(60%_70%_at_50%_100%,rgba(0,0,0,0.045),transparent)] dark:bg-[radial-gradient(60%_70%_at_50%_100%,rgba(255,255,255,0.05),transparent)]"
		></div>
		<Dock direction="bottom" ariaLabel="Applications">
			{#each apps as app (app.label)}
				<DockIcon>
					<button type="button" class={tile} aria-label={app.label} title={app.label}>
						<app.icon class="size-[46%]" strokeWidth={1.6} />
					</button>
				</DockIcon>
			{/each}
			<DockSeparator />
			{#each system as app (app.label)}
				<DockIcon>
					<button type="button" class={tile} aria-label={app.label} title={app.label}>
						<app.icon class="size-[46%]" strokeWidth={1.6} />
					</button>
				</DockIcon>
			{/each}
		</Dock>
	</div>
</div>
```

### Direction

Align icons to the top, middle or bottom of a taller shelf.

```svelte
<script lang="ts">
	import { Dock, DockIcon } from "fancy-ui-svelte";
	import type { Direction } from "fancy-ui-svelte";

	const directions: Direction[] = ["top", "middle", "bottom"];
	const swatches = [
		"from-zinc-200 to-zinc-400 dark:from-zinc-500 dark:to-zinc-800",
		"from-zinc-100 to-zinc-300 dark:from-zinc-400 dark:to-zinc-700",
		"from-zinc-200 to-zinc-400 dark:from-zinc-500 dark:to-zinc-800",
	];
</script>

<div class="space-y-8">
	{#each directions as dir (dir)}
		<div>
			<p class="text-muted-foreground mb-3 text-center font-mono text-xs">direction="{dir}"</p>
			<div class="flex justify-center">
				<Dock direction={dir} class="h-[96px]" magnification={36} ariaLabel="Dock aligned {dir}">
					{#each swatches as swatch, i (i)}
						<DockIcon>
							<div
								class="size-full rounded-[30%] border border-black/[0.07] bg-gradient-to-br shadow-[inset_0_1px_0_rgba(255,255,255,0.7)] dark:border-white/[0.08] dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.12)] {swatch}"
							></div>
						</DockIcon>
					{/each}
				</Dock>
			</div>
		</div>
	{/each}
</div>
```

### Vertical

A side rail: the dock stands on its edge and the indicator dot moves beside the icons.

```svelte
<script lang="ts">
	import { Dock, DockIcon, DockSeparator } from "fancy-ui-svelte";
	import PenLine from "@lucide/svelte/icons/pen-line";
	import ImageIcon from "@lucide/svelte/icons/image";
	import Layers from "@lucide/svelte/icons/layers";
	import MessageCircle from "@lucide/svelte/icons/message-circle";
	import Settings from "@lucide/svelte/icons/settings";

	const tools = [
		{ label: "Write", icon: PenLine },
		{ label: "Media", icon: ImageIcon },
		{ label: "Layers", icon: Layers },
		{ label: "Comments", icon: MessageCircle },
	];

	const tile =
		"grid size-full place-items-center rounded-[30%] border border-black/[0.07] bg-gradient-to-b from-white to-zinc-100 text-zinc-700 shadow-[inset_0_1px_0_rgba(255,255,255,1),0_1px_2px_rgba(0,0,0,0.06)] outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/60 dark:border-white/[0.08] dark:from-[#26262a] dark:to-[#141416] dark:text-zinc-200 dark:shadow-[inset_0_1px_0_rgba(255,255,255,0.09),0_1px_2px_rgba(0,0,0,0.6)]";
</script>

<!-- A side rail: the dock stands on its edge, the indicator dot moves beside the icons. -->
<div
	class="w-full max-w-2xl rounded-[22px] border border-black/[0.06] bg-black/[0.015] p-1.5 dark:border-white/[0.06] dark:bg-white/[0.02]"
>
	<div
		class="flex h-[26rem] items-center rounded-2xl border border-black/[0.06] bg-[#fafafa] pl-10 dark:border-white/[0.06] dark:bg-[#0b0b0c]"
	>
		<Dock
			orientation="vertical"
			direction="top"
			magnification={40}
			class="mx-0"
			ariaLabel="Editor tools"
		>
			{#each tools as tool (tool.label)}
				<DockIcon>
					<button type="button" class={tile} aria-label={tool.label} title={tool.label}>
						<tool.icon class="size-[46%]" strokeWidth={1.6} />
					</button>
				</DockIcon>
			{/each}
			<DockSeparator />
			<DockIcon>
				<button type="button" class={tile} aria-label="Settings" title="Settings">
					<Settings class="size-[46%]" strokeWidth={1.6} />
				</button>
			</DockIcon>
		</Dock>
	</div>
</div>
```
