Preview Updated 2026-05-10

Dock layout

Recursive split + tabbed-pane shell for desktop application layouts. v1 is declarative; v2 will add drag-to-rearrange.

Basic usage

The layout is declared as a tree of DockGroup nodes: each group either has children (further splits) or panels (a tabbed area). Content is provided through the named slot panel-{id} (Vue) / slots["panel-{id}"] (React).

  • 📁 src
  • 📄 orders.ts
  • 📄 login.ts
// orders.ts
export const fetchOrders = () => …
$ pnpm dev
[vite] dev server running on :5173
<CfDockLayout :layout="layout">
<template #panel-orders>… orders.ts content …</template>
<template #panel-login>… login.ts content …</template>
<template #panel-terminal>… terminal content …</template>
</CfDockLayout>
<CfDockLayout layout={layout} slots={{
'panel-orders': <pre>orders.ts</pre>,
'panel-login': <pre>login.ts</pre>,
'panel-terminal': <Terminal />,
}} />

Minimal layout (no nesting)

A single group with multiple panels = a plain tabbed view, equivalent to CfTabs. If you only need tab switching, use CfTabs directly — it’s lighter.

预览区(这是一个仅 tab 切换的简化布局)
<CfDockLayout :layout="{ id: 'r', orientation: 'vertical', panels: [...] }" />
<CfDockLayout layout={{ id: "r", orientation: "vertical", panels: [...] }} />

API

PropTypeDefaultDescription
layoutDockGroupLayout description tree
activeRecord<groupId, panelId>{}Active tab id per group

DockGroup: { id, orientation: 'horizontal' \| 'vertical', children?: DockGroup[], panels?: DockPanel[], size? }

DockPanel: { id, title, contentKey?, closable?, detachable?, size?, collapsed? }

Events: active-change(groupId, panelId) / panel-close(...) / panel-detach(...).

v1 limitations: splitter resize and drag-to-rearrange are not yet supported; planned for v2.

反馈与讨论

Dock layout · Discussion

0
0 / 600
一键发送
正在加载评论...