# Dock

- Page: https://jiguang132.com/resources/magic-ui/docs/dock
- Resource: Magic UI (https://jiguang132.com/resources/magic-ui.md)
- All guides: https://jiguang132.com/resources/magic-ui/docs.md

Install: `npx shadcn@latest add https://jiguang132.com/r/magic-ui/dock.json`

## Use case

Magnify dock items near the pointer.

## Native props used by the examples

Extracted from all local examples for this entry, grouped by imported module and native owner, including other Magic components used by compound demos. This is not an exhaustive API or a universal host variant. Inspect spread object declarations and the source types/defaults below.

| Owning component prop | Explanation | Example source |
| --- | --- | --- |
| `Dock.direction` (dock) | Native orientation/direction enum; values differ by component. | `examples/dock-demo.tsx`、`examples/dock-demo-2.tsx` |
| `Dock.children` (dock) | Native child content; keep the owning component's text/element constraints. | `examples/dock-demo.tsx`、`examples/dock-demo-2.tsx`、`examples/dock-demo-3.tsx` |
| `DockIcon.children` (dock) | Native child content; keep the owning component's text/element constraints. | `examples/dock-demo.tsx`、`examples/dock-demo-2.tsx`、`examples/dock-demo-3.tsx` |
| `Dock.iconMagnification` (dock) | Dock's magnified icon size. | `examples/dock-demo-3.tsx` |
| `Dock.iconDistance` (dock) | Dock distance over which icons respond to the pointer. | `examples/dock-demo-3.tsx` |
| `DockIcon.className` (dock) | Classes on this native component; initialize Tailwind and its required CSS first. | `examples/dock-demo-3.tsx` |

## Interaction and state checks

- Dock Demo — `dock-demo`
- Dock Demo 2 — `dock-demo-2`
- Dock Demo 3 — `dock-demo-3`

These names identify real example entries, not new component props or extra components. Check pointer/keyboard behavior, themes, small screens and failures for the selected example. Decorative effects must not invent disabled/error/submission states. Complete example installation includes the actual dependency closure.

## Business integration boundary

DockIcon is a native composition helper. Use real labelled links/buttons inside it and verify touch/keyboard behavior separately.

## Host and motion setup

Initialize Tailwind CSS v4, semantic CSS variables and the dark variant; import the independent local Registry namespace. Reuse an existing next-themes Provider without substituting JGuang UI/Base UI/HeroUI APIs. Mount effects in view and unmount offscreen; provide static alternatives for unavailable Canvas/WebGL or failed remote media. Respect prefers-reduced-motion and verify timer/RAF/observer/listener cleanup: stopping CSS alone does not prove the engine stopped. Examples provide no backend, login, payment or real AI stream. This practical guide is bilingual; detailed upstream references and demo text retain their original language.


## Available examples

dock-demo, dock-demo-2, dock-demo-3

Demo state and mock data do not provide a backend service. Inspect the component props before wiring real data.




## Installation

<Tabs defaultValue="cli">

<TabsList>
  <TabsTrigger value="cli">CLI</TabsTrigger>
  <TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">

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

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Copy and paste the following code into your project.</Step>



<Step>Update the import paths to match your project setup.</Step>

</Steps>

</TabsContent>

</Tabs>

## Examples

### Custom Direction



### Custom magnification



## Usage

```tsx showLineNumbers
import { Home, Search, Settings } from "lucide-react"

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

```tsx showLineNumbers
<Dock>
  <DockIcon>
    <Home />
  </DockIcon>
  <DockIcon>
    <Settings />
  </DockIcon>
  <DockIcon>
    <Search />
  </DockIcon>
</Dock>
```

## Props

### Dock

| Prop                   | Type        | Default    | Description                          |
| ---------------------- | ----------- | ---------- | ------------------------------------ |
| `className`            | `string`    | `-`        | Custom CSS class for styling         |
| `children`             | `ReactNode` | `-`        | Children elements                    |
| `iconSize`             | `number`    | `40`       | Size of the icon                     |
| `iconMagnification`    | `number`    | `60`       | Level of icon magnification          |
| `iconDistance`         | `number`    | `140`      | Distance from cursor to magnify icon |
| `direction`            | `string`    | `"middle"` | Direction of the dock                |
| `disableMagnification` | `boolean`   | `false`    | Disable Magnification on hover       |

### DockIcon

| Prop            | Type                | Default | Description                          |
| --------------- | ------------------- | ------- | ------------------------------------ |
| `size`          | `number`            | `40`    | Size of the icon                     |
| `magnification` | `number`            | `60`    | Level of icon magnification          |
| `distance`      | `number`            | `140`   | Distance from cursor to magnify icon |
| `mouseX`        | `any`               | `-`     | Mouse X position for magnification   |
| `className`     | `string`            | `-`     | Custom CSS class for styling         |
| `children`      | `React.ReactNode`   | `-`     | Children elements                    |
| `props`         | `PropsWithChildren` | `-`     | Additional props                     |

## Credits

- Credits to [Build UI](https://buildui.com/recipes/magnified-dock) for this fantastic component
- Credits to [Ritesh Bucha](https://twitter.com/bucha_ritesh) for finding and improving it




## Complete example installation

The component command installs the component. Each example command also includes its actual imported components, native support UI, utilities and pinned dependencies. Helpers are not additional catalog components.

### Dock Demo

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dock/dock-demo.json
```

Default import: `@/components/magicui/examples/dock-demo`

Dependencies: `@radix-ui/react-separator@1.1.11`, `@radix-ui/react-slot@1.3.0`, `@radix-ui/react-tooltip@1.2.12`, `class-variance-authority@0.7.1`, `clsx@2.1.1`, `lucide-react@1.24.0`, `motion@12.42.2`, `next@16.4.0`, `tailwind-merge@3.6.0`

### Dock Demo 2

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dock/dock-demo-2.json
```

Default import: `@/components/magicui/examples/dock-demo-2`

Dependencies: `class-variance-authority@0.7.1`, `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Dock Demo 3

```bash
npx shadcn@latest add https://jiguang132.com/r/magic-ui/examples/dock/dock-demo-3.json
```

Default import: `@/components/magicui/examples/dock-demo-3`

Dependencies: `class-variance-authority@0.7.1`, `clsx@2.1.1`, `motion@12.42.2`, `tailwind-merge@3.6.0`

### Minimal usage and theme

```tsx
import Demo from '@/components/magicui/examples/dock-demo';
import { ThemeProvider } from 'next-themes';
export default function Example() {
  return <ThemeProvider attribute="class" defaultTheme="system" enableSystem><Demo /></ThemeProvider>;
}

```

Initialize Tailwind CSS v4, semantic color variables and the dark variant first. Reuse an existing next-themes provider rather than nesting another. Next Link examples require a Next.js environment; in static Vite projects adapt the demo links to your router without changing the native component API. Some media and tweets require network access. Examples do not supply authentication or backend services.


## Source-backed parameter reference

Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.


```ts
Dock({
      className,
      children,
      iconSize = DEFAULT_SIZE,
      iconMagnification = DEFAULT_MAGNIFICATION,
      disableMagnification = DEFAULT_DISABLEMAGNIFICATION,
      iconDistance = DEFAULT_DISTANCE,
      direction = "middle",
      ...props
    }, ref)

DockIcon({
  size = DEFAULT_SIZE,
  magnification = DEFAULT_MAGNIFICATION,
  disableMagnification,
  distance = DEFAULT_DISTANCE,
  mouseX,
  className,
  children,
  ...props
}: DockIconProps)
```



```ts
export interface DockProps extends VariantProps<typeof dockVariants> {
  className?: string
  iconSize?: number
  iconMagnification?: number
  disableMagnification?: boolean
  iconDistance?: number
  direction?: "top" | "middle" | "bottom"
  children: React.ReactNode
}

export interface DockIconProps extends Omit<
  MotionProps & React.HTMLAttributes<HTMLDivElement>,
  "children"
> {
  size?: number
  magnification?: number
  disableMagnification?: boolean
  distance?: number
  mouseX?: MotionValue<number>
  className?: string
  children?: React.ReactNode
  props?: PropsWithChildren
}
```


### Destructuring defaults in source

Only defaults written directly in parameter/props destructuring are listed. Conditional expressions, runtime theme and computed values require source inspection; this is not an exhaustive behavior-default list.


```ts
// Dock
iconSize = DEFAULT_SIZE

// Dock
iconMagnification = DEFAULT_MAGNIFICATION

// Dock
disableMagnification = DEFAULT_DISABLEMAGNIFICATION

// Dock
iconDistance = DEFAULT_DISTANCE

// Dock
direction = "middle"

// DockIcon
size = DEFAULT_SIZE

// DockIcon
magnification = DEFAULT_MAGNIFICATION

// DockIcon
distance = DEFAULT_DISTANCE
```


### Native and external types

External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.


```ts
HTMLDivElement
VariantProps<typeof dockVariants>
React.ReactNode
Omit<
  MotionProps & React.HTMLAttributes<HTMLDivElement>,
  "children"
>
MotionProps
React.HTMLAttributes<HTMLDivElement>
MotionValue<number>
PropsWithChildren
```

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
