opensourceui
GitHubTwitter/X
  1. Home
  2. Components
  3. Dashboard
  4. Floating Tool Rail
Back to Dashboard

Components / Dashboard

Floating Tool Rail

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

Floating vertical tool rail for editor and creator dashboards with active tool state.

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/dashboard/floating-tool-rail.tsx in your project.

  4. 4

    Import and render:

    Example

    import { FloatingToolRail } from "@/components/dashboard/floating-tool-rail";

    <FloatingToolRail 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/dashboard/floating-tool-rail.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
"use client";
 
import { forwardRef, type ComponentPropsWithoutRef } from "react";
 
import {
AudioLines,
Grid2x2,
MousePointer2,
PenLine,
Sparkles,
type LucideIcon,
} from "lucide-react";
 
import { cn } from "@/lib/cn";
 
export type FloatingToolItem = Readonly<{
id: string;
label: string;
icon?: LucideIcon;
}>;
 
export type FloatingToolRailProps = Readonly<
{
tools?: readonly FloatingToolItem[];
activeId?: string;
onSelect?: (id: string) => void;
} & ComponentPropsWithoutRef<"nav">
>;
 
const DEFAULT_TOOLS: readonly FloatingToolItem[] = [
{ id: "select", label: "Select", icon: MousePointer2 },
{ id: "layers", label: "Layers", icon: PenLine },
{ id: "draw", label: "Draw", icon: Sparkles },
{ id: "audio", label: "Audio", icon: AudioLines },
];
 
// Floating tool rail — vertical Apple-style action strip for editors.
export const FloatingToolRail = forwardRef<HTMLElement, FloatingToolRailProps>(
(
{
className,
tools = DEFAULT_TOOLS,
activeId = "select",
onSelect,
...props
},
ref,
) => (
<nav
ref={ref}
data-slot="floating-tool-rail"
aria-label="Editor tools"
className={cn(
"inline-flex w-14 flex-col items-center gap-2 rounded-full border border-neutral-100 bg-white p-2 font-sans shadow-lg shadow-black/10",
className,
)}
{...props}
>
{tools.map((tool) => {
const Icon = tool.icon ?? MousePointer2;
const active = tool.id === activeId;
 
return (
<button
key={tool.id}
type="button"
aria-label={tool.label}
aria-pressed={active}
onClick={() => onSelect?.(tool.id)}
className={cn(
"flex size-10 items-center justify-center rounded-full transition-colors",
active
? "bg-neutral-100 text-neutral-900"
: "text-neutral-500 hover:bg-neutral-50 hover:text-neutral-800",
)}
>
<Icon size={17} aria-hidden strokeWidth={1.75} />
</button>
);
})}
 
<button
type="button"
aria-label="All tools"
className="mt-1 flex size-10 items-center justify-center rounded-full bg-neutral-900 text-white transition-opacity hover:opacity-90"
>
<Grid2x2 size={16} aria-hidden />
</button>
</nav>
),
);
 
FloatingToolRail.displayName = "FloatingToolRail";
PreviousNext

On this

page

Jump to a section on this page.

  • lib/cn.ts
  • components/dashboard/floating-tool-rail.tsx

Sponsor spot · demo preview

Logo

Your brand name

Your tagline or category

A short pitch about your product or service goes here. This is a preview of how sponsor cards will look in this sidebar.

Your call to action

This slot is available. Sponsor Opensource UI and reach developers browsing components every day.