macOS Dock for React
A macOS dock for React with magnification: icons near the pointer swell and push their neighbors apart, with labels riding on top.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/dock.jsonDockDockItemDockSeparatordefaultDockLabels- +2 more
App dock
Move the pointer along it. Click an app to see it bounce. Keyboard: Tab into it, then arrow keys, Home and End; the focused app swells too, and Escape hides its label. Open apps (the dot) say so to screen readers: “Finder, open”. In a narrow window it turns into a plain bar that scrolls inside itself, with the label drawn above the bar.
import type { ReactNode } from "react";
import { Dock, DockItem, DockSeparator } from "@/components/sheenui/dock/dock";
import { useToast } from "@/components/sheenui/toast/toast";
// Package build (after the first npm release, or a packed tarball): import { Dock, DockItem, DockSeparator, useToast } from "@sheenui/theme";
import {
Calendar as CalendarIcon,
MessageCircle as ChatIcon,
Download as DownloadIcon,
Smile as FaceIcon,
Flower as FlowerIcon,
Mail as MailIcon,
Music as MusicIcon,
Settings as GearIcon,
Trash2 as TrashIcon,
} from "lucide-react";
// This example also uses toast: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toast.json
type App = { label: string; icon: ReactNode; tile: string; active?: boolean; badge?: number; badgeLabel?: string };
const apps: App[] = [
{ label: "Finder", icon: <FaceIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-7),var(--sheen-chart-1))]", active: true },
{ label: "Mail", icon: <MailIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-7),var(--sheen-chart-3))]", badge: 3, badgeLabel: "3 unread" },
{ label: "Calendar", icon: <CalendarIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-8),var(--sheen-chart-2))]" },
{ label: "Music", icon: <MusicIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-5),var(--sheen-chart-8))]", active: true },
{ label: "Photos", icon: <FlowerIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-4),var(--sheen-chart-2))]" },
{ label: "Messages", icon: <ChatIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-chart-3),var(--sheen-chart-6))]" },
{ label: "Settings", icon: <GearIcon />, tile: "[background:linear-gradient(160deg,var(--sheen-ink-500),var(--sheen-ink-700))]" },
];
export function Example() {
const toast = useToast();
return (
<Dock label="Apps" labels={{ active: "open" }}>
{apps.map((app) => (
<DockItem
key={app.label}
label={app.label}
icon={app.icon}
active={app.active}
badge={app.badge}
badgeLabel={app.badgeLabel}
bounce
onClick={() => toast.info(`Opening ${app.label}`)}
tileClassName={`${app.tile} text-sheen-accent-fg`}
/>
))}
<DockSeparator />
<DockItem label="Downloads" icon={<DownloadIcon />} onClick={() => toast.info("Opening Downloads")} />
<DockItem label="Trash" icon={<TrashIcon />} onClick={() => toast.info("Trash is empty")} />
</Dock>
);
}Files to copy
5 folders · 4 files · 4 packages
- From
theme/src/ components/dock/hooks/{use-media-query.ts, use-preferences.ts}motion/tokens.tslib/cn.tsstyles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/dock.jsonRegistry item: dock. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/spinner/components/toast/hooks/use-direction.tslib/state-light.tsx
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/toast.json- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Navigation links, at the top
Items with href are links (aria-current marks the active one). side="top" grows the icons downward with labels underneath. Smaller icons, a gentler swell.
import { Dock, DockItem } from "@/components/sheenui/dock/dock";
// Package build (after the first npm release, or a packed tarball): import { Dock, DockItem } from "@sheenui/theme";
import { Folder as FolderIcon, House as HomeIcon, Search as SearchIcon, User as UserIcon } from "lucide-react";
export function Example() {
return (
<Dock label="Sections" side="top" size="sm" magnification={1.45}>
<DockItem label="Home" icon={<HomeIcon />} href="#home" active />
<DockItem label="Search" icon={<SearchIcon />} href="#search" />
<DockItem label="Library" icon={<FolderIcon />} href="#library" />
<DockItem label="Profile" icon={<UserIcon />} href="#profile" />
</Dock>
);
}Notch
With notch, the active item lifts out of a round notch cut into the glass bar and glides to the next active item. Click an icon to move it. Needs an active item.
import { useState } from "react";
import { Dock, DockItem } from "@/components/sheenui/dock/dock";
// Package build (after the first npm release, or a packed tarball): import { Dock, DockItem } from "@sheenui/theme";
import { Folder as FolderIcon, House as HomeIcon, Search as SearchIcon, User as UserIcon } from "lucide-react";
export function Example() {
const [active, setActive] = useState("Home");
const items = [
{ label: "Home", icon: <HomeIcon /> },
{ label: "Search", icon: <SearchIcon /> },
{ label: "Library", icon: <FolderIcon /> },
{ label: "Profile", icon: <UserIcon /> },
];
return (
<Dock label="Sections" notch>
{items.map((item) => (
<DockItem
key={item.label}
label={item.label}
icon={item.icon}
active={active === item.label}
onClick={() => setActive(item.label)}
/>
))}
</Dock>
);
}Dock props
DockLabels keys and English defaults (1)
DockItem props
DockSeparator props
Keyboard
Accessibility
- A Base UI toolbar: roving focus, with aria-label on the dock and a name on each item (the label is also its accessible name).
- Magnification is decorative.
- Under reduced motion items do not scale; the label still shows on focus.
All exports on this page
Dock— Dock: a macOS-style launcher bar.DockItem— One icon in a Dock: a button, or a link when you give it an href (or render your router's <Link>).DockSeparator— A thin divider between groups of items (e.g.defaultDockLabels— The English strings of Dock.
When to use the macOS dock effect
- Use it as a floating dock with magnification for an app launcher or quick-action bar in a desktop-style web app, where icons near the pointer swell and push neighbors apart like the macOS Dock.
- Use it as a floating bottom bar in a portfolio or a docs playground, with DockItem links to sections, a DockSeparator before utility items and a badge on an inbox icon.
- Set side="top" to pin the bar to the top edge instead of the default bottom; icons grow away from that edge and labels appear on the far side. Only top and bottom are supported, so use VerticalNav for a vertical rail.
- Skip it when you need editor controls or primary site navigation: use Toolbar for formatting controls and Navbar for site navigation, since magnification adds nothing to a menu of text links.
- Pair it with Dialog or MorphingDialog so an item opens a window-like panel, Badge for status elsewhere in the shell, and DockItem badge for counts; no Tooltip is needed because the dock draws its own labels.
Frequently asked questions
Related pages
Guides that cover it
19 effects pages in all: browse them on All effects.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .