OpenSourceUIOpenSourceUIOpensource UI
GitHub—
  1. Home
  2. Components
  3. Docks
  4. Editor Tool Dock
Back to DocksComponents / Docks

Editor Tool Dock

Free Docks React component — EditorToolDock. MIT licensed, copy-paste ready for Next.js and Tailwind CSS.

Vertical editor tool dock using MacDock tile size, padding, and ease-smooth hover scale.

Preview

Setup

How to use

Free for personal and commercial use. No UI attribution required. Include the MIT copyright notice when copying component source into your project. Read the MIT license.

  1. 1

    Run in your terminal:

    $npm install clsx tailwind-merge lucide-react
  2. 2

    Copy lib/cn.ts below. Skip if you already have cn().

  3. 3

    Copy the code below and create components/docks/editor-tool-dock.tsx in your project.

  4. 4

    Import and render:

    Example

    import { EditorToolDock } from "@/components/docks/editor-tool-dock";

    <EditorToolDock activeId="select" onSelect={(id) => console.log(id)} />

lib/cn.ts

1
2
3
4
5
6
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
 
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

components/docks/editor-tool-dock.tsx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"use client";
 
import { forwardRef, useState, type ComponentPropsWithoutRef } from "react";
 
import {
AudioLines,
Folder,
MousePointer2,
PenLine,
Sparkles,
type LucideIcon,
} from "lucide-react";
 
import { cn } from "@/lib/cn";
 
export type EditorToolItem = Readonly<{
id: string;
label: string;
icon?: LucideIcon;
}>;
 
export type EditorToolDockProps = Readonly<
{
tools?: readonly EditorToolItem[];
activeId?: string;
showAllTools?: boolean;
allToolsLabel?: string;
onSelect?: (id: string) => void;
onAllTools?: () => void;
} & ComponentPropsWithoutRef<"nav">
>;
 
const DEFAULT_TOOLS: readonly EditorToolItem[] = [
{ id: "select", label: "Select", icon: MousePointer2 },
{ id: "draw", label: "Draw", icon: PenLine },
{ id: "generate", label: "Generate", icon: Sparkles },
{ id: "audio", label: "Audio", icon: AudioLines },
];
 
// Editor tool dock — vertical frosted tool strip aligned with MacDock styling.
export const EditorToolDock = forwardRef<HTMLElement, EditorToolDockProps>(
(
{
className,
tools = DEFAULT_TOOLS,
activeId: activeIdProp,
showAllTools = true,
allToolsLabel = "All tools",
onSelect,
onAllTools,
...props
},
ref,
) => {
const [activeId, setActiveId] = useState(
activeIdProp ?? tools[0]?.id ?? "select",
);
const currentId = activeIdProp ?? activeId;
 
return (
<nav
ref={ref}
data-slot="editor-tool-dock"
aria-label="Editor tools"
className={cn(
"inline-flex flex-col items-center gap-2.5 rounded-2xl border border-neutral-50 bg-white/50 p-2.5 font-sans shadow-xl shadow-black/10 backdrop-blur-md",
className,
)}
{...props}
>
{tools.map((tool) => {
const Icon = tool.icon ?? MousePointer2;
const active = tool.id === currentId;
 
return (
<button
key={tool.id}
type="button"
aria-label={tool.label}
aria-pressed={active}
title={tool.label}
onClick={() => {
setActiveId(tool.id);
onSelect?.(tool.id);
}}
className={cn(
"ease-smooth flex size-11 items-center justify-center rounded-lg shadow-xs shadow-neutral-100 transition-[background-color,color,transform] duration-300 will-change-transform",
active
? "bg-neutral-900 text-white"
: "bg-neutral-50 text-neutral-600 hover:scale-110 hover:text-neutral-900",
)}
>
<Icon size={17} aria-hidden strokeWidth={1.75} />
</button>
);
})}
 
{showAllTools ? (
<button
type="button"
aria-label={allToolsLabel}
onClick={onAllTools}
className="ease-smooth flex size-11 items-center justify-center rounded-lg bg-rose-200 text-white shadow-xs transition-transform duration-300 hover:scale-110"
>
<Folder size={16} aria-hidden fill="currentColor" />
</button>
) : null}
</nav>
);
},
);
 
EditorToolDock.displayName = "EditorToolDock";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/docks/editor-tool-dock.tsx
Platinum slotAvailable

Feature your product here.

Sticky card next to every component — highest-intent placement.

Claim this card