Xzero UI
Pro library

DockPro

A floating tool dock with a gliding label, a springy selection, and trays that grow out of it.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui-pro/dock
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui-pro/dock

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { Dock } from "@/components/xzero/dock/dock";
import { Hand, MousePointer2, Pencil, Square, Circle } from "lucide-react";

export function CanvasTools() {
  const [tool, setTool] = useState("select");
  const [items, setItems] = useState([
    { id: "select", label: "Select", icon: <MousePointer2 />, shortcut: "V" },
    { id: "hand", label: "Hand", icon: <Hand />, shortcut: "H" },
    { id: "shapes", label: "Shapes", icon: <Square />, items: [
      { id: "rect", label: "Rectangle", icon: <Square />, shortcut: "R" },
      { id: "ellipse", label: "Ellipse", icon: <Circle />, shortcut: "O" },
    ] },
    { id: "pen", label: "Pen", icon: <Pencil />, shortcut: "P" },
  ]);
  return <Dock items={items} value={tool} onValueChange={setTool} onItemsChange={next => setItems(next)} />;
}

API reference

Dock

A floating command dock for the tools or modes someone switches between all day. A label glides between items, a calm accent tint springs to the chosen one, and groups grow a tray out of the dock surface, all inside one hairline outline.

PropTypeDefaultDescription
items (required){ id: string; label: string; icon: ReactNode; shortcut?: string; badge?: number; items?: DockItem[] }[]–Items in order. shortcut is a display-only key hint, badge a rolling count that leaves at 0, and items turns the entry into a group with a tray.
valuestring | nullnullId of the selected item or group member.
onValueChange(id: string) => void–Called when an item or group member is chosen.
onItemsChange(items: DockItem[], change: { type: "move"; id: string; index: number }) => void–Enables drag to reorder and Alt with the arrow keys. Receives the next list and what moved.
labelstring"Tools"Accessible name of the toolbar.
classNamestring–Extra class on the root.

Keyboard interactions

KeysAction
ArrowLeft / ArrowRightMoves focus along the dock, wrapping; in an open tray, moves between members.
Home / EndFocuses the first or last item.
Enter / SpaceChooses an item. On a group, selects the member it shows and opens or closes its tray. In a tray, chooses the member, closes the tray, and returns focus to the group.
ArrowUpOn a group, opens its tray and focuses the chosen member.
ArrowDownIn a tray, closes it and returns focus to the group.
TabIn a tray, closes it and moves on.
Alt + ArrowLeft / ArrowRightMoves the focused item when onItemsChange is set.
EscapeCloses the open tray and returns focus to its group.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in docks and tabs

Guidance for AI tools

Dock: A floating tool dock with a gliding label, a springy selection, and trays that grow out of it. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components