Dock

A macOS-style dock component with smooth magnification animation on hover, inspired by the macOS dock.

motion-sv
Dock

Installation

pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/dock.json

Usage

<script lang="ts">	import HomeIcon from "@lucide/svelte/icons/house";	import { Dock, DockIcon } from "#lib/components/magic/dock/index.js";</script>
<Dock>	<DockIcon>		<button type="button" aria-label="Home">			<HomeIcon class="size-5" />		</button>	</DockIcon></Dock>

Examples

Direction

Direction: Top
Direction: Middle (Default)
Direction: Bottom

Custom Magnification

Colored Icons

Disabled Magnification

Props

Dock

The main dock container that provides context and handles mouse tracking for magnification effects.

NameTypeDefaultDescription
classClassValue""Additional CSS classes to apply.
iconSizenumber40The base size of icons in pixels.
iconMagnificationnumber60The magnified size of icons when hovered.
disableMagnificationbooleanfalseDisables the magnification effect on hover.
iconDistancenumber140The distance in pixels at which magnification starts to take effect.
direction"top" | "middle" | "bottom""middle"The alignment direction of icons within the dock.
childrenSnippet-The dock icon children to render inside the dock.

Dock Icon

Individual icon wrapper that responds to the dock's magnification context.

NameTypeDefaultDescription
classClassValue""Additional CSS classes to apply.
childrenSnippet-The icon content to render inside the dock icon.