BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/godui/dock

Dock

godui/dock
FreeComponent

A macOS-style dock whose items magnify with spring physics as the pointer moves across them.

Install it

npx shadcn@latest add https://godui.design/r/dock.json

Source

packages/components/src/dock/dock.tsxgodui.design/r/dock.json
1"use client";
2
3import {
4 AnimatePresence,
5 type MotionValue,
6 motion,
7 useMotionValue,
8 useSpring,
9 useTransform,
10} from "framer-motion";
11import * as React from "react";
12
13type DockContextValue = {
14 mouseX: MotionValue<number>;
15 baseSize: number;
16 magnification: number;
17 distance: number;
18};
19
20const DockContext = React.createContext<DockContextValue | null>(null);
21
22function useDock() {
23 const ctx = React.useContext(DockContext);
24 if (!ctx) {
25 throw new Error("DockItem must be used within a <Dock>.");
26 }
27 return ctx;
28}
29
30export type DockProps = React.HTMLAttributes<HTMLDivElement> & {
31 /** Resting size of each item in pixels. */
32 baseSize?: number;
33 /** Maximum magnified size in pixels at the pointer. */
34 magnification?: number;
35 /** Pointer distance in pixels over which items are affected. */
36 distance?: number;
37};
38
39export type DockItemProps = React.HTMLAttributes<HTMLDivElement> & {
40 /** Label shown above the item on hover. */
41 label?: React.ReactNode;
42};
43
44const PANEL_BASE =
45 "mx-auto flex h-16 items-end gap-3 rounded-2xl border border-border bg-card/70 px-3 pb-3 shadow-lg backdrop-blur-md";
46
47const ITEM_BASE =
48 "group relative flex aspect-square items-center justify-center rounded-xl bg-muted text-foreground shadow-sm";
49
50const Dock = React.forwardRef<HTMLDivElement, DockProps>(
51 (
52 {
53 baseSize = 44,
54 magnification = 72,
55 distance = 140,
56 className,
57 children,
58 onMouseMove,
59 onMouseLeave,
60 ...props
61 },
62 ref,
63 ) => {
64 const mouseX = useMotionValue(Number.POSITIVE_INFINITY);
65
66 return (
67 <DockContext.Provider
68 value={{ mouseX, baseSize, magnification, distance }}
69 >
70 <div
71 ref={ref}
72 data-slot="dock"
73 role="toolbar"
74 aria-label="Dock"
75 className={`${PANEL_BASE} ${className ?? ""}`}
76 onMouseMove={(e) => {
77 mouseX.set(e.clientX);
78 onMouseMove?.(e);
79 }}
80 onMouseLeave={(e) => {
81 mouseX.set(Number.POSITIVE_INFINITY);
82 onMouseLeave?.(e);
83 }}
84 {...props}
85 >
86 {children}
87 </div>
88 </DockContext.Provider>
89 );
90 },
91);
92Dock.displayName = "Dock";
93
94const DockItem = React.forwardRef<HTMLDivElement, DockItemProps>(
95 ({ label, className, children, ...props }, forwardedRef) => {
96 const { mouseX, baseSize, magnification, distance } = useDock();
97 const ref = React.useRef<HTMLDivElement>(null);
98// … truncated

What it pulls in

npm packages

  • framer-motion

Other registry items

  • @godui/godui-theme

Files it writes

  • packages/components/src/dock/dock.tsx

Facts

Registry
godui
Type
registry:ui
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

godui.design LucasBassetti/godui on GitHub Raw registry item This item as JSON

More from godui

All 105 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AccordionaccordiongoduiComponentsFree1 dep
Agent Flowagent-flowgoduiComponentsFree1 dep
Agent Timelineagent-timelinegoduiComponentsFree1 dep
Animated Beamanimated-beamgoduiComponentsFree1 dep
Animated Testimonialsanimated-testimonialsgoduiComponentsFree1 dep
Animated Tooltipanimated-tooltipgoduiComponentsFree1 dep
App Showcaseapp-showcasegoduiComponentsFree1 dep
Aurora Textaurora-textgoduiComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex