A quieter way to work.
A focused workspace for the source, its context and the result. Tabs keep their content mounted when you switch, collapse or move them; on narrow screens the panes stack.
A two-pane workspace that keeps your drafts intact as tabs move, panels collapse and the working space changes.
A focused workspace for the source, its context and the result. Tabs keep their content mounted when you switch, collapse or move them; on narrow screens the panes stack.
"use client";
import { useState } from "react";
import { Dock, type DockLayout, TextArea, Button } from "mizu-ui";
export function Example() {
const initial: DockLayout = {
panes: [["draft", "notes"], ["preview"]],
active: ["draft", "preview"],
split: 52,
collapsed: null,
};
const [layout, setLayout] = useState(initial);
return (
<div style={{ display: "grid", gap: 16 }}>
<Dock
label="Release workspace"
value={layout}
onValueChange={setLayout}
tabs={[
{
id: "draft",
label: "Draft",
content: (
<TextArea
label="Release draft"
rows={7}
defaultValue={
"A quieter way to work.\n\nEvery panel keeps its place, and every draft stays yours."
}
hint="Edit this, then move the tab. Your draft travels with it."
/>
),
},
{
id: "notes",
label: "Notes",
content: (
<section>
<h3>Before publishing</h3>
<ul className="mizu-field-hint">
<li>Check the keyboard path.</li>
<li>Read the empty and error states.</li>
<li>Keep the motion purposeful.</li>
</ul>
</section>
),
},
{
id: "preview",
label: "Preview",
content: (
<article>
<h3>A quieter way to work.</h3>
<p className="mizu-field-hint">
A focused workspace for the source, its context and the
result. Tabs keep their content mounted when you switch,
collapse or move them; on narrow screens the panes stack.
</p>
</article>
),
},
]}
/>
<Button
variant="ghost"
arrow={false}
size="sm"
style={{ justifySelf: "start" }}
onClick={() => setLayout(initial)}
>
Reset layout
</Button>
</div>
);
}
It starts with "use client" because it keeps state or passes functions to components, so it pastes into a Next.js page as it is. Other React setups ignore the directive.
Add this component to your project with the shadcn CLI. The command copies its source into your configured UI directory, with base.css, Mizu’s tokens, and the stylesheets that hold its rules. Each rule lives in one stylesheet, so components you add together never repeat CSS. In a project without a components.json, run npx shadcn@latest init 0xuser64bit/mizu/preset first: plain init installs shadcn’s theme into your global CSS. Then load the fonts.
npx shadcn@latest add 0xuser64bit/mizu/dock 0xuser64bit/mizu/text-area 0xuser64bit/mizu/buttonThe example also uses TextArea and Button, so the command adds them too.
Every component imports from its own path, its name in kebab case. To paste the example, replace its mizu-ui import with:
import { Dock, type DockLayout } from "@/components/ui/mizu/dock";
import { TextArea } from "@/components/ui/mizu/text-area";
import { Button } from "@/components/ui/mizu/button";For npm imports, import mizu-ui/styles.css once. Fonts are optional via mizu-ui/fonts.css. Override --mizu-* tokens or use className for local styling. Uses native React and CSS; install the package peers for root imports. A Client Component: its source starts with “use client”.
Source is included in the npm package under src/layout/Dock.tsx.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | — | Accessible workspace name, also shown in the toolbar. |
| tabs | DockTab[] | — | Unique id, label and content for every panel. Content stays mounted when hidden or moved. |
| value / defaultValue / onValueChange | DockLayout / DockLayout / function | — | Controlled layout or an initial layout: panes contains two ordered ID lists, active contains each pane's selected ID, split is the first pane's percentage, and collapsed is 0, 1 or null. |
| readOnly | boolean | false | Lock resizing, collapsing, moving and reordering. Tab selection stays available. |
Named workspace with two roving-tabindex tablists and labelled tabpanels. Arrow keys select, Home/End reach the first/last tab. Every structural action has a labelled button. The separator supports pointer capture, arrows, Shift for 10%, and Home/End for the 20–80% bounds. On small screens panes stack and the separator is removed. Unknown or repeated IDs are removed, newly supplied tabs join the first pane, and missing selections fall back to the first available tab.
Resizing tracks the hand directly; tabs and collapse update without travel. Hidden panels remain mounted so form values and component state survive layout changes.