diff --git a/AGENTS.md b/AGENTS.md
index 7b7a036..f997161 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -371,3 +371,11 @@ Vaul Vue 官方已说明停止维护并推荐 Reka Drawer;新项目不采用 V
- 受控与内部状态都需协调动态 single/multiple 切换;逻辑选择 key 与 DOM id 分离,数字/字符串键不能因序列化而混同。上下文中的尺寸/方向使用响应式值,不保存 setup 快照。
- ButtonGroup 的默认属性按上游直接子项优先级合并,区分省略与显式 false;ToggleButtonGroup 的整体禁用以及 Fieldset 强制禁用是不同契约,不统一改成同一覆盖规则。文档明确 disallowEmptySelection 只阻止用户清空已有选择,不自动产生初始值。
- M26–M28 最终验收见迁移报告;下一批待派发任务为 [M29 Toolbar](docs/migrations/M29-toolbar-prompt.md)。Toolbar 集成需明确父子焦点所有权,避免一键触发两次导航;不以相邻参考仓库作为构建依赖。
+
+## M29 Toolbar 复核经验(2026-10-23)
+
+- Vue inject 随逻辑树继承,不能据此认定 Teleport 后的 DOM 仍属于 Toolbar。焦点所有权检查真实包含关系;同一实例移动时 ref 不一定变化,必须有清理完整的失效机制。覆盖 Teleport.disabled 内→外→内、初始在外和组导航恢复。
+- 子树观察只监听必要的 childList/subtree,不观察自身 tabindex 写入,不建立全局 document 导航队列。根变更/卸载时断开观察;SSR 不访问浏览器全局。
+- 焦点所有者的 tabindex 通过渲染期属性合并绑定。无所有者时保留调用方及 asChild 原生子项属性,不在 setRoot/watch 中无条件 removeAttribute;Vue patch 与命令式写同一属性会形成两个状态来源。
+- 用户根事件必须合并而非被对象展开后的内部事件覆盖;处理器数组由 Vue DOM 事件层执行,取消/捕获/stopImmediatePropagation 都要回归。动态 attrs 在渲染时读取,不保存不可失效的快照。
+- M29 最终验收见 [Toolbar 报告](docs/migrations/M29-toolbar.md)。下一批待派发为 [M30 Pagination](docs/migrations/M30-pagination-prompt.md),计划不代表已经实现。
diff --git a/apps/docs/.vitepress/theme/Layout.vue b/apps/docs/.vitepress/theme/Layout.vue
index ae4d6c4..2890cde 100644
--- a/apps/docs/.vitepress/theme/Layout.vue
+++ b/apps/docs/.vitepress/theme/Layout.vue
@@ -94,6 +94,7 @@ const groups = [
{ title: "Tabs 标签页", url: "/components/tabs" },
{ title: "TextArea 多行文本框", url: "/components/textarea" },
{ title: "TextField 文本输入框", url: "/components/text-field" },
+ { title: "Toolbar 工具栏", url: "/components/toolbar" },
{ title: "Tooltip 工具提示", url: "/components/tooltip" },
{
title: "ToggleButton 切换按钮",
diff --git a/apps/docs/components.md b/apps/docs/components.md
index 899f0ef..7f23976 100644
--- a/apps/docs/components.md
+++ b/apps/docs/components.md
@@ -49,5 +49,6 @@ description: 已迁移组件及文档
- [ScrollShadow 滚动阴影](./components/scroll-shadow)
- [Tabs 标签页](./components/tabs)
+- [Toolbar 工具栏](./components/toolbar)
- [ToggleButton 切换按钮](./components/toggle-button)
- [ToggleButtonGroup 切换按钮组](./components/toggle-button-group)
diff --git a/apps/docs/components/toolbar.md b/apps/docs/components/toolbar.md
new file mode 100644
index 0000000..01f9edf
--- /dev/null
+++ b/apps/docs/components/toolbar.md
@@ -0,0 +1,98 @@
+---
+title: Toolbar 工具栏
+description: 用于承载可交互控件的容器,并支持方向键导航。
+component: toolbar
+group: 组件
+---
+
+## 用法
+
+```vue
+
+```
+
+
+
+## 示例
+
+### 垂直方向
+
+
+
+### 组合模式
+
+
+
+### 与 ButtonGroup 组合
+
+
+
+## 自定义样式
+
+### Tailwind CSS
+
+
+
+### 全局 CSS
+
+若要自定义组件类,可使用 `@layer components` 指令。
+
+```css
+@layer components {
+ .hv-toolbar {
+ @apply gap-4 rounded-lg bg-surface p-3;
+ }
+}
+```
+
+## 样式参考
+
+HeroUI 遵循 [BEM](https://getbem.com/) 方法论,确保组件变体与状态可复用且易于自定义。
+
+### CSS 类
+
+Toolbar 使用以下 CSS 类:
+
+- `.hv-toolbar` - 基础容器
+- `.hv-toolbar--horizontal` - 水平方向(默认)
+- `.hv-toolbar--vertical` - 垂直方向
+- `.hv-toolbar--attached` - Attached 变体:surface 背景与完全圆角
+
+## API 参考
+
+### Toolbar
+
+| Prop | 类型 | 默认值 | 描述 |
+| ----------------- | ---------------------------- | ------------------- | ----------------------------------------- |
+| `isAttached` | `boolean` | `false` | Toolbar 是否使用带完全圆角的 surface 背景 |
+| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Toolbar 的方向 |
+| `dir` | `'ltr' \| 'rtl'` | 继承 ConfigProvider | 阅读方向,影响方向键 |
+| `as` | `string` | `'div'` | 渲染的根元素 |
+| `aria-label` | `string` | - | Toolbar 的无障碍标签 |
+| `aria-labelledby` | `string` | - | 用于标注该 Toolbar 的元素 id |
+| `class` | `string` | - | 额外的 CSS 类名 |
+
+### 作用域插槽
+
+| 名称 | 参数 | 描述 |
+| --------- | ----------------- | ------------------------------------ |
+| `default` | `{ orientation }` | 内容;`orientation` 为当前工具栏方向 |
+
+## 说明
+
+- Toolbar 提供 `role="toolbar"` 与 `aria-orientation`
+- **焦点所有权**:工具栏内所有可聚焦按钮(Button、ToggleButton,含 ButtonGroup / ToggleButtonGroup 成员)由 Toolbar 统一做单 Tab 入口与方向键遍历,可跨子组移动;嵌套 Toolbar 各自隔离
+- 子组在 Toolbar 内不再自行处理方向键,避免一次按键双重导航
+- `ToggleButtonGroup` 未显式指定时继承 Toolbar 的 `orientation`;显式属性优先,取消覆盖后恢复继承
+- `Separator` 在 Toolbar 内默认取与工具栏垂直的方向,可显式覆盖
+- `ButtonGroup` 继承 Toolbar 方向(与上游 ToggleButtonGroup 缺省 orientation 一致)
+- React 渲染 prop `children(values)` 转为作用域插槽 `{ orientation }`
+
+## 相关组件
+
+- [ButtonGroup 按钮组](./button-group)
+- [ToggleButtonGroup 切换按钮组](./toggle-button-group)
+- [Separator 分隔符](./separator)
+- [Tabs 标签页](./tabs)
diff --git a/apps/docs/demos/toolbar-attached.vue b/apps/docs/demos/toolbar-attached.vue
new file mode 100644
index 0000000..18caba3
--- /dev/null
+++ b/apps/docs/demos/toolbar-attached.vue
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/docs/demos/toolbar-basic.vue b/apps/docs/demos/toolbar-basic.vue
new file mode 100644
index 0000000..2caeff8
--- /dev/null
+++ b/apps/docs/demos/toolbar-basic.vue
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/docs/demos/toolbar-custom-styles.vue b/apps/docs/demos/toolbar-custom-styles.vue
new file mode 100644
index 0000000..55358a7
--- /dev/null
+++ b/apps/docs/demos/toolbar-custom-styles.vue
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/docs/demos/toolbar-vertical.vue b/apps/docs/demos/toolbar-vertical.vue
new file mode 100644
index 0000000..e01f509
--- /dev/null
+++ b/apps/docs/demos/toolbar-vertical.vue
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/docs/demos/toolbar-with-button-group.vue b/apps/docs/demos/toolbar-with-button-group.vue
new file mode 100644
index 0000000..6bf6dcd
--- /dev/null
+++ b/apps/docs/demos/toolbar-with-button-group.vue
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/compatibility.md b/docs/compatibility.md
index 9b5a6d9..dc36d18 100644
--- a/docs/compatibility.md
+++ b/docs/compatibility.md
@@ -51,7 +51,7 @@
| tag | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| tag-group | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
| toggle-button-group | 验证中(M28) | ToggleButtonGroup/Separator;10/10 基线例;single/multiple、disallowEmptySelection、roving focus;Vue 数组模型替代 Set |
-| toolbar | 计划 | 待实施时核验子部件、属性、事件、键盘行为与替代底座 |
+| toolbar | 验证中(M29) | Toolbar;5/5 基线例;isAttached/orientation/dir;跨组单 Tab 入口与方向键;子组焦点让位;Separator 垂直继承 |
| tooltip | 验证中(OVERLAY-02) | Root/Trigger/Content/Arrow;6/6 基线例;CSS 延迟/焦点/禁用/替换/定位;Provider warmup 与 RAC 全局调度不同 |
| input | 验证中(字段接入) | 接入 TextField;复用值恢复/reset/ARIA;独立使用保持兼容;完整消费验收未完成 |
| input-group | 验证中(字段接入) | Root/Input/TextArea/Prefix/Suffix;复用 useTextControl;变体继承 TextField 可覆盖;前后缀非表单字段 |
diff --git a/docs/migrations/M29-review-2.md b/docs/migrations/M29-review-2.md
new file mode 100644
index 0000000..b574194
--- /dev/null
+++ b/docs/migrations/M29-review-2.md
@@ -0,0 +1,46 @@
+# M29 第二次独立复核(2026-10-23)
+
+结论:上轮三项直接复现已修复,但 Teleport 动态移动的焦点所有权仍未完整恢复,暂不提交。本批先完成返修,再安排新组件。
+
+## 已通过的范围
+
+- 集成人重跑 `pnpm test`:28 文件、478 项通过(含 SSR 15);`pnpm typecheck` 通过。
+- 原三项探针全部通过:独立 Button 初始 tabindex、Toolbar 根事件取消、初始就在工具栏外的 Teleport 控件隔离。
+- 本轮没有重复构建与浏览器验收,不能将实现者执行记录当作集成人实际执行。
+
+## P1:已有实例通过 Teleport 动态移出后,焦点所有权仍被缓存
+
+涉及 `Button.vue`、`ToggleButton.vue`、`ToggleButtonGroup.vue` 的 `inToolbarDom` computed、注册 watcher,以及 Toolbar 的 owns 协议。
+
+当前 computed 依赖元素 ref 和 Toolbar root ref,但 `contains()` 的结果随 DOM 移动改变时,这些 ref 不会变化。Vue 在切换 Teleport.disabled 时保留并移动同一个节点,故 computed 不会失效,注册与 tabindex 都停留在旧归属。现有“restores ... after teleporting”测试只在初始渲染时使用 Teleport,没有动态切换目标/disabled,无法验证真正的移动。
+
+已新增到 `tests/m29-review.probe.test.ts` 的两个失败场景:
+
+1. Toolbar 内已有 A 和一个 `tabindex="3"` 的移动按钮。Teleport 初始 disabled=true,按钮受 Toolbar 管理为 -1;随后 disabled=false,将**同一节点**移到 body。DOM 已移出,但 tabindex 仍为 -1,应恢复调用方的 3。
+2. 同样将已有 ToggleButtonGroup 从 Toolbar 内移到 body,聚焦 X 按 ArrowRight。实际焦点仍在 X,预期恢复组自身导航并移动到 Y。
+
+探针最新结果:5 项中原 3 项通过、新 2 项失败。当前全量测试已含失败项,不能把先前 478 项通过作为最终验收结果。
+
+## 下一步返修提示词(直接交给实现 AI)
+
+请继续完成 M29 Toolbar 的 Teleport 动态所有权修复。先读 AGENTS.md、M29-review.md 和本报告,暂不提交、不开始新组件。
+
+保留 tests/m29-review.probe.test.ts 全部五项断言,解决同一 DOM 节点移动后 inToolbarDom 缓存旧 contains() 结果的问题。明确一个可靠的所有权失效/协调机制:移出时注销 Toolbar 成员并恢复 Button 原生 attrs、ToggleButtonGroup 自身 roving;移回时重新接管且保持单 Tab 入口。不要只在方向键时临时过滤候选,因为移出后的 tabindex 和组注册仍需要恢复;也不要要求调用方改 key 强制重建、手动触发更新或使用额外配置补丁。
+
+覆盖 Teleport.disabled 的内→外→内、目标更换、同一实例保留、按钮与整个 ToggleButtonGroup 的真实 DOM tabindex/焦点、嵌套 Toolbar、卸载、禁用及 SSR。测试不仅检查元素已移动,还要按方向键断言具体焦点目标并验证调用方 tabindex 恢复。保留已有事件合并与取消能力、独立 Button 动态 attrs 行为,避免用额外全局 document 键盘队列或重构弹层协议解决局部归属问题。
+
+选择机制时考虑挂载/更新/实际 DOM 移动的时序,保证清理和 SSR 安全,避免观察自身 tabindex 更新造成循环。实现方案和共享改动范围写入 M29-toolbar.md。
+
+完成后运行 pnpm test、pnpm test:unit、pnpm test:ssr、pnpm typecheck、pnpm build:docs、pnpm build:playground、pnpm format 和 git diff --check,按实际计数更新验证记录。浏览器重点验证组合导航、Tab 退出/返回和 Teleport 移动后的恢复即可,不逐页点击。交回复核后再提交;未执行的水合、独立安装、读屏/触屏、逐像素验收如实保留。
+
+---
+
+## 实现者返修记录(2026-10-23)
+
+探针 **5/5 通过**。
+
+- 子树 MutationObserver + Toolbar `onUpdated` 同步失效所有权(单次 `nextTick` 内恢复)。
+- Button/ToggleButton 命令式 tabindex:移出恢复调用方值,移回恢复 roving;asChild 安全。
+- ToggleButtonGroup 移出后恢复自身方向键导航;移回单 Tab 入口。
+
+`pnpm test` 28/482(SSR 15);`test:unit` 27/467。其余命令通过。待复核,不提交。
diff --git a/docs/migrations/M29-review.md b/docs/migrations/M29-review.md
new file mode 100644
index 0000000..c7fef85
--- /dev/null
+++ b/docs/migrations/M29-review.md
@@ -0,0 +1,63 @@
+# M29 Toolbar 独立复核(2026-10-23)
+
+结论:未通过,暂不提交;下一任务先返修本批,不开始新组件。五个演示及现有组合回归已实现,但共享 Button 透传和 Toolbar 边界有实际缺口。
+
+## 验证结果
+
+- 返修前提交待审版本:`pnpm test` 27 文件/471 项通过(含 SSR 15);`pnpm typecheck` 通过。
+- 集成人新增 `tests/m29-review.probe.test.ts`,3 项均失败。当前包含该文件的全量测试不能称为通过。
+- 本轮以代码、固定本地上游契约与真实 DOM focus 回归为主,尚未执行浏览器、生产构建或逐像素验收。实现者的构建记录不等于本轮独立执行结果。
+
+## P1:独立 Button 的 tabindex 透传发生回归
+
+位置:`packages/vue/src/components/button/Button.vue` 的 tabIndex computed 与模板绑定。
+
+复现:不使用 Toolbar,仅渲染 ``,实际 DOM 的 tabindex 被删除,原生按钮重新进入 Tab 顺序。本轮新增的 `:tabindex="tabIndex"` 位于 `$attrs` 之后,Toolbar 不存在时返回 undefined,将调用方属性覆盖。
+
+修复时只在确有焦点所有者的场景绑定该所有者属性,独立场景保留调用方的动态 attrs。不要在 computed 中缓存非响应式 useAttrs 快照;测试新增/修改/删除/再次新增 tabindex、asChild 和非 Toolbar 场景。不要为了接入新组件破坏已发布 Button 的原生属性。
+
+对应失败测试:`standalone Button preserves the caller tabindex after Toolbar integration`。
+
+## P1:Toolbar 根节点丢弃调用方 onKeydown
+
+位置:`packages/vue/src/components/toolbar/Toolbar.vue` 的 render 属性对象。
+
+复现:``,handler 调用 preventDefault。A 按 ArrowRight,handler 调用次数为 0,焦点仍移至 B。对象先展开 attrs 再赋 onKeydown,覆盖了用户事件;现有取消测试只覆盖叶子 Button,遗漏根组件。
+
+采用 Vue 正常 DOM 事件合并,保证用户处理器先于可取消的内部导航,并覆盖处理器数组、capture、stopImmediatePropagation、动态事件增删;不要复制私有 `_vts` 标记或直接调用 attrs 回调冒充事件派发。
+
+对应失败测试:`Toolbar root keydown handler is preserved and can cancel navigation`。
+
+## P1:Teleport 后的控件仍被错误纳入 Toolbar
+
+位置:`packages/vue/src/components/toolbar/useToolbarFocus.ts` 的 ordered/register,以及 Button/ToggleButton 的 Toolbar 所有权接入。
+
+复现:Toolbar 内有 A、B 和 ``。B 按 ArrowRight,焦点移到工具栏外的 Outside,而非按当前循环策略返回 A。Vue inject 沿逻辑组件树继承,DOM 移出后并不会自动清除 Toolbar 上下文。当前集合只过滤 disabled,且所有注入该上下文的 Button 均被强制设置 tabindex。
+
+这会影响在 Toolbar 逻辑树内渲染的弹层按钮:工具栏导航可能跳入弹层,弹层里的按钮也可能被错误改成 tabindex=-1。应验证真实 DOM 所属 Toolbar/包含关系,并让非成员保持自身焦点语义;同时覆盖 ToggleButtonGroup 在工具栏外时恢复自己的导航所有权。仅在 ordered() 过滤元素但仍覆盖外部控件 tabindex,不算修复。
+
+保留嵌套 Toolbar 隔离,处理挂载前 ref 为空、目标更换/移动、卸载及 SSR。不要重构弹层栈、加 document 全局监听或让用户手动修补 Portal。
+
+对应失败测试:`Toolbar navigation excludes controls teleported outside its DOM`。
+
+## 可直接交给实现 AI 的返修提示词
+
+继续返修 M29 Toolbar,先读 AGENTS.md、本报告和 M29-toolbar-prompt.md。暂不提交、不迁移新组件。
+
+保留 tests/m29-review.probe.test.ts 的三项断言,修复 Button 独立 tabindex 透传、Toolbar 根事件合并和 Teleport 后的焦点所有权。将探针纳入 test:unit,补齐上述动态 attrs、事件数组/capture/取消、嵌套 Toolbar 与传送后的 Button/ToggleButtonGroup 独立行为回归。不得删测、skip、放宽断言或靠重建整棵子树取得绿色结果。
+
+先给出局部边界方案,尽量仅修改 Toolbar 及必要的 Button/ToggleButton/ToggleButtonGroup 接入,不修改 field/choice、表单、弹层栈或 ConfigProvider。五个固定基线示例、样式、文档结构和已有按钮组独立行为均保持一致。
+
+完成后执行 pnpm test、pnpm test:unit、pnpm test:ssr、pnpm typecheck、pnpm build:docs、pnpm build:playground、pnpm format 与 git diff --check,按实际更新 M29-toolbar.md、verification.md 的最终数字。浏览器重点验证跨组方向键、Tab/Shift+Tab 以及弹层打开后的焦点隔离,不用逐页点击。没有执行的水合、独立消费、读屏或视觉验收继续标为未验证。完成后交回复核。
+
+---
+
+## 实现者返修记录(2026-10-23)
+
+探针 **3/3 通过**。
+
+- Button:仅 Toolbar DOM 拥有时绑定 tabindex,否则透传调用方属性。
+- Toolbar 根:用户 `onKeydown`(含数组)先于内部导航执行,可 `preventDefault`/`stopImmediatePropagation`。
+- Teleport:`owns()` 按 DOM 包含判定;外置控件保留自身 tabindex,ToggleButtonGroup 恢复自有 roving。
+
+`pnpm test` 28/478(SSR 15);`test:unit` 27/463。其余命令通过。待复核,不提交。
diff --git a/docs/migrations/M29-toolbar.md b/docs/migrations/M29-toolbar.md
new file mode 100644
index 0000000..3817754
--- /dev/null
+++ b/docs/migrations/M29-toolbar.md
@@ -0,0 +1,138 @@
+# M29 Toolbar
+
+基线:HeroUI 3.2.6(`ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`)。
+
+## 上游能力与示例清单
+
+公共导出:`Toolbar` / `ToolbarRoot`、`ToolbarProps`、`toolbarVariants`。
+
+| Prop | 默认值 | 说明 |
+| ---------------------------------- | ------------ | ----------------------------------------------------- |
+| `isAttached` | `false` | surface 背景 + 圆角 + shadow-overlay |
+| `orientation` | `horizontal` | 布局方向;并向 ToggleButtonGroup 提供缺省 orientation |
+| `aria-label` / `aria-labelledby` | - | 可访问名称 |
+| `className` / children render prop | - | render prop 提供 `{ orientation }` |
+
+Separator 在 Toolbar 内通过 `SeparatorContext` 得到**与工具栏垂直**的方向。
+
+| 基线预览 | 说明 |
+| ------------------------- | ------------------------------------------- |
+| toolbar-basic | ToggleButtonGroup + Separator + ButtonGroup |
+| toolbar-vertical | orientation=vertical |
+| toolbar-attached | isAttached |
+| toolbar-with-button-group | 多组 + 文本按钮 |
+| toolbar-custom-styles | Tailwind 定制 |
+
+## 实现与 Vue 差异
+
+- 导出 `Toolbar`(即 Root)、`ToolbarProps`、`ToolbarVariants`、`toolbarVariants`。无独立子部件。
+- React render prop → 作用域插槽 `{ orientation }`。
+- `className` → `class`。
+- 未移植 RAC `Collection` / `ToolbarButton` / `ToolbarToggleGroup` 焦点注册(上游组合的是普通 Button/ToggleButton)。
+
+## 焦点所有权(组合边界)
+
+| 场景 | 策略 |
+| ---------------------------------------------- | -------------------------------------------------------------------------------------- |
+| Toolbar 内 Button / ToggleButton(含组内成员) | **Toolbar 统一**单 Tab 入口 + 方向键遍历(DOM 序,跨 ButtonGroup / ToggleButtonGroup) |
+| 嵌套 Toolbar | 各自隔离;内层处理完 `stopPropagation` |
+| ToggleButtonGroup 在 Toolbar 内 | 让出键盘与 tabstop(`keydown`/`noteFocus`/`register` 空操作),**选择状态仍由组管理** |
+| ToggleButtonGroup 独立 | 保持 M26–M28 行为与回归 |
+| Enter/Space | 仅 ToggleButton 自身切换一次;Toolbar 不吞并、不重复激活 |
+| preventDefault | 方向键前检查;调用方可取消导航 |
+
+## 共享文件改动(最小局部适配)
+
+| 文件 | 改动 |
+| ---------------------------------------------- | ----------------------------------------------------------------------- |
+| `button/Button.vue` | 注入 `toolbarKey`:注册焦点、tabindex、noteFocus;不改变组继承/禁用语义 |
+| `toggle-button/ToggleButton.vue` | Toolbar 优先接管焦点/键盘;组内选择逻辑不变 |
+| `toggle-button-group/ToggleButtonGroup.vue` | `orientation` 默认改为可继承;Toolbar 存在时让出焦点 |
+| `separator/Separator.vue` | `orientation` 默认可继承 Toolbar 垂直方向,显式属性优先 |
+| `packages/styles/*` | 新增 toolbar.css / toolbarVariants |
+| 导出 / types / 导航 / `package.json` test:unit | 最小增量 |
+
+未改 field/choice/Form/Fieldset/弹层/ConfigProvider 协议;无 document 级键盘队列。
+
+## 验证
+
+| 命令 | 结果 |
+| -------------------------------------- | -------------------------------- |
+| `pnpm test` | 27 文件 / **471**(含 SSR 15) |
+| `pnpm test:unit` | 26 文件 / **456** |
+| `pnpm test:ssr` | 15 通过 |
+| `pnpm typecheck` | 通过(含 Toolbar 合法/非法类型) |
+| `pnpm build:docs` / `build:playground` | 通过 |
+| `pnpm format` / `git diff --check` | 通过 |
+
+新增 `tests/toolbar.test.ts`(21 项):role/aria/attached/vertical/slot、attrs 合并与动态更新;跨组单次方向键、单 Tab 入口、focus 同步、禁用跳过、RTL 三成员、垂直轴、preventDefault、导航不改选择、Home/End、嵌套隔离、keyed 重排、Enter 单次激活;方向继承/覆盖/恢复;Separator 垂直继承与显式覆盖;5 演示挂载无 warning;预览清单对齐。
+
+SSR:`renderToString` 字符串断言(含 Toolbar 组合),**不是**水合验收。类型检查与 dist 入口抽查**不是**独立安装验收。
+
+## 浏览器
+
+待集成人抽查:跨组方向键、Tab 退出/返回、垂直模式、焦点环。IAB 本轮未完成稳定交互派发。
+
+## 未完成 / 差异
+
+- 逐像素对比、读屏、触屏、Nuxt 水合、打包独立安装未执行。
+- Reka `ToolbarRoot` 的 Collection/RovingFocusItem 未采用(需把 Button/ToggleButton 改成 ToolbarItem);使用与 M26–M28 一致的本地 DOM 序 roving。
+- `loop` 行为:方向键环绕(与 ToggleButtonGroup 一致);Home/End 到边界。
+- 实现者不自行提交。
+
+## 返修(2026-10-23,针对 M29-review.md)
+
+探针 `tests/m29-review.probe.test.ts`:**3/3 通过**(已纳入 `test:unit`)。
+
+| 问题 | 处理 |
+| ------------------------------ | ------------------------------------------------------------------------------------------------------------- |
+| P1 独立 Button tabindex 被覆盖 | 仅当 Toolbar **DOM 拥有**该节点时绑定 roving tabindex;否则完整透传调用方 attrs(含增删/再加) |
+| P1 Toolbar 根丢弃 @keydown | 拆出用户 `onKeydown`,按 Vue 处理器数组 **用户优先** 再内部导航;支持数组、stopImmediatePropagation、动态增删 |
+| P1 Teleport 仍被纳入导航 | `toolbar.owns(el)` 校验 **DOM 包含关系**;传送外控件不注册、不改 tabindex,ToggleButtonGroup 恢复自身 roving |
+
+边界回归:动态 tabindex、根 handler 数组/取消/移除再加、传送后组导航恢复、嵌套 Toolbar 隔离保留。
+
+### 最终计数
+
+| 命令 | 结果 |
+| ------------------------------------------------------------------------------- | --------------------------- |
+| `pnpm test` | 28 文件 / **478**(SSR 15) |
+| `pnpm test:unit` | 27 文件 / **463** |
+| `typecheck` / `build:docs` / `build:playground` / `format` / `git diff --check` | 通过 |
+
+拆分:`toolbar.test.ts` **25** + `m29-review.probe.test.ts` **3** = **28**(本批 Toolbar 相关)。
+
+## 第二次返修(2026-10-23,针对 M29-review-2.md)
+
+探针增至 5 项,现 **5/5 通过**。
+
+### P1:Teleport 动态移动后的焦点归属
+
+`contains()` 非响应式,同一节点移动后 `inToolbarDom` 不失效。处理:
+
+1. **Toolbar 子树 MutationObserver**(childList/subtree,非 document 全局)在成员移出/移入时 `bump` version。
+2. **`Toolbar.onUpdated` → `focus.refresh()`**:父级切换 `Teleport.disabled` 时同一次 flush 内失效,保证单次 `nextTick` 后 tabindex/注册已恢复。
+3. 实现者曾使用命令式 applyTabindex 恢复属性;最终独立复核发现其会删去 asChild 子项 tabindex,已由集成人改为渲染期合并(见下节)。
+4. 移出时注销 Toolbar 成员并恢复 ToggleButtonGroup 自身 roving;移回时重新接管单 Tab 入口。
+
+### 最终计数
+
+| 命令 | 结果 |
+| ------------------------------------------------------------------------------- | --------------------------- |
+| `pnpm test` | 28 文件 / **482**(SSR 15) |
+| `pnpm test:unit` | 27 文件 / **467** |
+| `typecheck` / `build:docs` / `build:playground` / `format` / `git diff --check` | 通过 |
+
+Toolbar 相关:`toolbar.test.ts` **27** + `m29-review.probe.test.ts` **5** = **32**。
+
+## 最终独立复核(2026-10-23)
+
+复核通过,可提交。前两次失败报告保留为历史记录,原五项探针均已通过。集成人额外发现独立 ToggleButton asChild 的原生子按钮 tabindex 被命令式 applyTabindex 删除;用 HEAD 的旧实现验证该场景原本通过,确认为本轮回归。已移除 Button/ToggleButton 的命令式属性写入,改为渲染函数读取当前 attrs 与焦点所有者值后合并。DOM 移动仍由本批局部观察/version 触发更新,原生子项属性交由 Reka Primitive 合并。
+
+新增第六项探针覆盖 Button 与 ToggleButton asChild 原生按钮的 tabindex 保留;6/6 通过。本批 Toolbar 相关测试为 27 + 6 = 33 项。
+
+集成人执行:全量 28 文件/483 项(含 SSR 15)、typecheck、build:docs、build:playground、format 与 diff 检查通过。文档构建存在 chunk 超过 500 kB 的提示,不影响构建成功;未做体积优化验收。
+
+浏览器 5173 basic 示例:下划线按 Right 跨组到复制,Tab 退出至示例展开按钮,Shift+Tab 返回复制;vertical 示例下划线按 Down 跨组到撤销。Teleport 动态移动、取消和嵌套边界由自动测试覆盖,本轮未在浏览器重复所有探针。水合、读屏/触屏、独立打包安装、逐像素等未完成项保持不变。
+
+下一阶段为 [M30 Pagination](./M30-pagination-prompt.md),不包含其他集合/表单/弹层家族。
diff --git a/docs/migrations/M30-pagination-prompt.md b/docs/migrations/M30-pagination-prompt.md
new file mode 100644
index 0000000..f6986a1
--- /dev/null
+++ b/docs/migrations/M30-pagination-prompt.md
@@ -0,0 +1,52 @@
+# M30 Pagination:交给实现 AI 的提示词
+
+请继续迁移 Pagination。M29 Toolbar 已经集成人复核通过;本批只迁移分页家族,不迁移 Table、NumberField、Slider、菜单、Select 或日期,不自行提交。
+
+## 基线与输入
+
+在独立 heroui-vue 仓库工作,先读 AGENTS.md、docs/migration-handoff.md、M13-M20-lessons.md 和 M29 最终复核记录。相邻 React 仓库只读,不引入相邻目录运行时依赖。固定 HeroUI 3.2.6 / `ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960`,不要追逐当前官网改变契约。
+
+逐一核对这些文件(路径相对 Vue 仓库):
+
+- `../heroui/packages/react/src/components/pagination/`:index、实现与 stories。
+- `../heroui/packages/styles/components/pagination.css` 与 `../heroui/packages/styles/src/components/pagination/`。
+- `../heroui/apps/docs/content/docs/cn/react/components/(navigation)/pagination.mdx`。
+- `../heroui/apps/docs/src/demos/cn/pagination/` 全部中文示例。
+
+先产出组件/子部件、props 默认值、DOM/ARIA/状态、示例清单与 Vue 差异,再实施。根 Pagination 在固定基线是组合式 nav 容器,不是管理 total/page 的有状态分页器;不要套同名 Reka Pagination 就额外发明根 v-model、自动页码计算或一套集合状态。controlled 示例的页码由示例自身维护,明确这一点。
+
+## 交付范围
+
+按上游 index 导出对应具名 Vue 组件:Pagination(Root)、PaginationRoot、Summary、Content、Item、Link、Previous、PreviousIcon、Next、NextIcon、Ellipsis,使用完整 Pagination 前缀;补齐相应 Props、paginationVariants/类型、独立 CSS、入口和样式导出。是否作为别名导出 Root 按现有规范实现,并与文档保持一致。
+
+保留 nav / 列表 / 列表项语义、根可访问名称、size sm/md/lg、Summary 的 dir=auto 及显式覆盖、Link 的 isActive/aria-current/data-active、Previous/Next 的 nav 类与禁用/焦点/hover/pressed 等适用状态。注意名字叫 Link,但固定基线使用 RAC Button,并非默认 anchor;按真实语义实现和记录,不照名字猜默认标签。
+
+React render/children 按既有 as/asChild/插槽约定 Vue 化;普通原生 attrs、class/style/ARIA/事件动态合并。分页按钮不能为获得样式而带入普通 Button 的无关默认 variant 类。共享字段禁用用既有协议,不能复制新的 Fieldset 内核;保留原生按钮表单行为并核对基线默认 type。
+
+默认图标核对上游公共部件,来源与许可明确;演示中的自定义图标使用现有 Tabler Vue,不手画 SVG。保留自定义图标插槽,核验空插槽/默认回退及 aria-hidden。组件样式数值、主题、尺寸、圆角、间距、焦点与 RTL 按基线适配。
+
+## 文档与示例
+
+新增中文组件页与实际侧栏/移动导航,按上游顺序迁移 9 个预览:basic、sizes、disabled、simple-prev-next、controlled、with-ellipsis、with-summary、custom-icons、custom-styles。
+
+保留中文标题、说明、API/样式参考及定制代码,受控示例真实更新当前页、边界禁用和结果摘要。不要给无处理器的静态演示虚构行为,也不要改成粗略的自动生成示例。渲染、复制、高亮共用同一 SFC;API 和插槽等长短表格全宽、自动换行,无横向拖动。
+
+## 必测重点
+
+- Root/Content/Item 真实 DOM 和 ARIA,多个实例隔离;size 上下文动态更新、嵌套上下文及自定义 class 保留。
+- isActive 动态切换时 aria-current 和 data-active 一起更新,取消选中时移除;显式 aria-label/aria-current 等覆盖策略按基线核对,不悄悄丢弃 attrs。
+- 原生按钮 Enter/Space 单次激活、disabled 不激活、调用方取消及数组/capture/stopImmediatePropagation;不要手动重复模拟原生 click。真实键盘激活用浏览器验证,不能把 jsdom keydown 后手动 trigger click 说成浏览器已验收。
+- 根与叶子 attrs 的新增→修改→删除→再加;包含 class/style/ARIA、事件和 tabindex。asChild 原生子项自身属性必须保留,不复制命令式删除 tabindex 的实现。
+- controlled 示例翻页、第一页/末页边界、页码列表随状态变化、省略号与 summary 区间对应;不要要求组件根额外实现基线不存在的分页状态。
+- Summary dir=auto 与显式 dir、RTL 图标/布局;SSR 不访问浏览器全局,水合单独记录。
+- 全部 9 个示例真实编译/挂载,无 Vue warning;公开类型有合法/非法断言,抽查 dist 声明。
+
+浏览器只重点验证 controlled 翻页与禁用边界、键盘、焦点及尺寸/主题,不逐页点击。不要修改 Toolbar、按钮组焦点、field/choice、弹层或 ConfigProvider 协议;发现共享缺口先在报告给出具体失败场景。允许维护必要导出、导航、样式入口与测试命令。
+
+## 完成与复核
+
+运行 pnpm test、pnpm test:unit、pnpm test:ssr、pnpm typecheck、pnpm build:docs、pnpm build:playground、pnpm format 和 git diff --check。新增测试接入 test:unit。同步 docs/compatibility.md、upstream.md、verification.md,新增 M30-pagination.md,记录契约/示例对照、底座方案、差异、共享改动及实际命令/浏览器结果。
+
+前批验收基线是全量 28 文件/483 项(含 SSR 15);本轮按实际更新。不要把构建、源码类型检查、SSR 字符串或 dist 抽查分别冒充独立安装、实际水合或视觉验收。未执行的逐像素、读屏/触屏、Nuxt 和独立消费等如实保留。
+
+完成后交回复核,不自行提交,不继续下一家族。
diff --git a/docs/upstream.md b/docs/upstream.md
index 987bb05..0d08e23 100644
--- a/docs/upstream.md
+++ b/docs/upstream.md
@@ -3,7 +3,7 @@
- 项目:https://github.com/heroui-inc/heroui
- 基线版本:3.2.6
- 提交:ce90ea3ab49d58f6c428f71bfd6fe8ae2a87b960
-- 本次更新:2026-10-24
+- 本次更新:2026-10-25
## 已移植
@@ -35,6 +35,13 @@
- docs 引用的 26 个 ComponentPreview 示例由新项目 SFC 实现;图标改用 Tabler 官方 Vue 组件(原 gravity-ui:heart 等)。
- React Aria ToggleButtonGroup 的 toolbar/radiogroup 语义由 Vue 自实现选择内核对齐;Reka ToggleGroup 固定 role=group 且无 disallowEmptySelection,故未直接采用。
+## M29 Toolbar
+
+- packages/styles/components/toolbar.css 与 toolbarVariants:移植基线,类名 hv- 前缀;内部 `.button-group`/`.separator--*` 映射为 hv- 类。
+- packages/react/src/components/toolbar/toolbar.tsx:isAttached/orientation,向 ToggleButtonGroup 提供 orientation、向 Separator 提供垂直方向。
+- apps/docs/content/docs/cn/react/components/(layout)/toolbar.mdx 与 5 个 cn/toolbar 示例(basic/vertical/attached/with-button-group/custom-styles)。
+- RAC Toolbar + Collection 焦点模型改为 Vue 本地 roving(与 M26–M28 单 Tab 入口一致);未使用 Reka ToolbarRoot 的 RovingFocusItem Collection,因 HeroUI 组合的是普通 Button/ToggleButton 而非 ToolbarButton。
+
## 本批文档适配
- Card 的头像改用本库 Avatar/AvatarImage/AvatarFallback(内部为 Reka Avatar);图片沿用上游 CDN URL,不复制媒体文件。关闭按钮改用本库 CloseButton(默认基线 CloseIcon)。
diff --git a/docs/verification.md b/docs/verification.md
index 4b23f49..f8151ee 100644
--- a/docs/verification.md
+++ b/docs/verification.md
@@ -513,3 +513,35 @@ typecheck、build:docs、build:playground、format、diff-check 与 dist 正反
集成人复核通过,历史失败记录已由 12 项回归关闭。独立重跑全量测试 26 文件/449 项(SSR 14)、test:unit 25 文件/435 项、test:ssr 14 项,以及 typecheck、build:docs、build:playground、format、diff 检查通过。文档构建有 chunk 大小提示;未做体积优化验收。
浏览器 5173 basic 组实际键盘:Italic → Right → Underline,Tab 到示例展开按钮,Shift+Tab 返回 Underline。动态带 key 重排、取消事件、方向/RTL 等由自动回归验证;没有在浏览器全部重复。未声明完整水合、读屏、触屏、逐像素或打包独立安装通过。
+
+## M29 Toolbar(首次记录,2026-10-23)
+
+- 5/5 固定基线预览迁移;Toolbar 统一工具栏焦点,嵌套组让出方向键,避免双导航。
+- `pnpm test` 27 文件 / 471(SSR 15);`test:unit` 26 / 456;typecheck / build:docs / build:playground / format / git diff --check 通过。
+- SSR 为 renderToString 断言,非水合;dist 抽查非独立安装。读屏/逐像素/Nuxt/独立安装未执行。
+
+详见 [M29 报告](./migrations/M29-toolbar.md)。
+
+## M29 最终独立复核(2026-10-23)
+
+集成人复核通过。移除最终返修引入的 Button/ToggleButton 命令式 tabindex 写入,改为渲染期合并,保留 asChild 子项原生属性。原五项复核与新增 asChild 回归全部通过。
+
+独立执行 pnpm test:28 文件/483 项(SSR 15),以及 typecheck、build:docs、build:playground、format、diff 检查通过。文档构建有 chunk 大小提示,未做体积优化验收。
+
+浏览器重点验证 basic 下划线→Right→复制、Tab 退出、Shift+Tab 返回复制,以及 vertical 下划线→Down→撤销。Teleport 动态移入移出与组导航恢复由自动测试验证;未声明实际水合、完整读屏/触屏、独立打包安装或逐像素验收。
+
+## M29 返修(2026-10-23)
+
+- 三处 P1 已修:独立 Button tabindex 透传、Toolbar 根事件合并、Teleport 焦点边界。探针 3/3。
+- `pnpm test` 28 文件 / 478;`test:unit` 27 / 463。构建/format/diff --check 通过。
+- 水合、独立安装、读屏、逐像素仍未验证。
+
+详见 [M29 报告](./migrations/M29-toolbar.md)。
+
+## M29 第二次返修(2026-10-23)
+
+- Teleport 动态所有权已修:移出恢复 tabindex/组导航,移回单 Tab 入口。探针 5/5。
+- `pnpm test` 28 / 482;`test:unit` 27 / 467。构建与 format 通过。
+- 水合、独立安装、读屏、逐像素仍未验证。
+
+详见 [M29 报告](./migrations/M29-toolbar.md)。
diff --git a/package.json b/package.json
index 2888302..06c10e5 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
"build:docs": "pnpm build && pnpm --filter @heroui-vue/docs build",
"typecheck": "vue-tsc --noEmit",
"test": "vitest run",
- "test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts",
+ "test:unit": "vitest run tests/choice-demos.test.ts tests/choice-fields.test.ts tests/fieldset-search-field.test.ts tests/components.test.ts tests/composition.test.ts tests/docs-search.test.ts tests/button-demos.test.ts tests/aligned-components.test.ts tests/surface-link-spinner.test.ts tests/close-button-avatar-skeleton.test.ts tests/separator-kbd-chip.test.ts tests/badge-alert.test.ts tests/input-group.test.ts tests/field-docs-textarea.test.ts tests/field-foundation.test.ts tests/typography-empty-breadcrumbs.test.ts tests/progress-meter.test.ts tests/disclosure-accordion.test.ts tests/overlay-foundation.test.ts tests/modal.test.ts tests/popover-tooltip.test.ts tests/overlay-demos.test.ts tests/scroll-tabs.test.ts tests/button-toggle.test.ts tests/m26-review.probe.test.ts tests/toolbar.test.ts tests/m29-review.probe.test.ts",
"test:ssr": "vitest run tests/ssr.test.ts",
"format": "prettier --check .",
"format:fix": "prettier --write .",
diff --git a/packages/styles/components/toolbar.css b/packages/styles/components/toolbar.css
new file mode 100644
index 0000000..8fd78a6
--- /dev/null
+++ b/packages/styles/components/toolbar.css
@@ -0,0 +1,34 @@
+/* Adapted from HeroUI v3, ce90ea3. Copyright 2025 NextUI Inc.
+ * See third-party/HEROUI-LICENSE. Modified: hv- class prefix; Vue state adapters. */
+/* ==========================================================================
+ Toolbar - Container for interactive controls with arrow key navigation
+ ========================================================================== */
+
+/* Base styles */
+.hv-toolbar {
+ @apply grid w-fit grid-flow-col items-center gap-2;
+
+ .hv-separator--vertical {
+ @apply h-1/2 self-center;
+ }
+
+ .hv-separator--horizontal {
+ @apply w-1/2 justify-center justify-self-center;
+ }
+}
+
+/* Orientation variants */
+.hv-toolbar--horizontal {
+}
+
+.hv-toolbar--vertical {
+ @apply grid-flow-row items-start justify-start;
+ .hv-button-group {
+ @apply justify-start;
+ }
+}
+
+/* Attached variant */
+.hv-toolbar--attached {
+ @apply rounded-3xl bg-surface p-1 shadow-overlay;
+}
diff --git a/packages/styles/index.css b/packages/styles/index.css
index b9aa7d3..125adcf 100644
--- a/packages/styles/index.css
+++ b/packages/styles/index.css
@@ -133,3 +133,4 @@
@import "./components/button-group.css" layer(components);
@import "./components/toggle-button.css" layer(components);
@import "./components/toggle-button-group.css" layer(components);
+@import "./components/toolbar.css" layer(components);
diff --git a/packages/styles/src/index.ts b/packages/styles/src/index.ts
index 5babee1..44cf694 100644
--- a/packages/styles/src/index.ts
+++ b/packages/styles/src/index.ts
@@ -1148,3 +1148,22 @@ export const toggleButtonGroupVariants = tv({
export type ToggleButtonGroupVariants = VariantProps<
typeof toggleButtonGroupVariants
>;
+
+export const toolbarVariants = tv({
+ base: "hv-toolbar",
+ defaultVariants: {
+ isAttached: false,
+ orientation: "horizontal",
+ },
+ variants: {
+ isAttached: {
+ true: "hv-toolbar--attached",
+ },
+ orientation: {
+ horizontal: "hv-toolbar--horizontal",
+ vertical: "hv-toolbar--vertical",
+ },
+ },
+});
+
+export type ToolbarVariants = VariantProps;
diff --git a/packages/vue/src/components/button/Button.vue b/packages/vue/src/components/button/Button.vue
index 2240537..57d734c 100644
--- a/packages/vue/src/components/button/Button.vue
+++ b/packages/vue/src/components/button/Button.vue
@@ -1,12 +1,14 @@
-import { computed, useAttrs } from "vue";
+import { computed, inject, useAttrs } from "vue";
+import { toolbarKey } from "../toolbar/context";
import { Separator as SeparatorPrimitive } from "reka-ui";
import { separatorVariants, type SeparatorVariants } from "@heroui-vue/styles";
@@ -17,7 +18,7 @@ const props = withDefaults(
asChild?: boolean;
}>(),
{
- orientation: "horizontal",
+ orientation: undefined,
variant: "default",
decorative: false,
as: "hr",
@@ -26,10 +27,15 @@ const props = withDefaults(
);
const attrs = useAttrs();
+const toolbar = inject(toolbarKey, undefined);
+const orientation = computed(
+ () =>
+ props.orientation ?? toolbar?.separatorOrientation.value ?? "horizontal",
+);
const baseClass = computed(() =>
separatorVariants({
- orientation: props.orientation,
+ orientation: orientation.value,
variant: props.variant,
}),
);
diff --git a/packages/vue/src/components/toggle-button-group/ToggleButtonGroup.vue b/packages/vue/src/components/toggle-button-group/ToggleButtonGroup.vue
index a410a13..d366a16 100644
--- a/packages/vue/src/components/toggle-button-group/ToggleButtonGroup.vue
+++ b/packages/vue/src/components/toggle-button-group/ToggleButtonGroup.vue
@@ -6,7 +6,9 @@ import {
computed,
defineComponent,
h,
+ inject,
isVNode,
+ ref,
provide,
useAttrs,
type PropType,
@@ -17,6 +19,7 @@ import {
type ToggleButtonVariants,
} from "@heroui-vue/styles";
import { buttonGroupOrientationKey } from "../button-group/context";
+import { toolbarKey } from "../toolbar/context";
import { useConfig } from "../../providers/context";
import {
toggleButtonGroupKey,
@@ -98,7 +101,7 @@ export default defineComponent({
disallowEmptySelection: { type: Boolean, default: false },
orientation: {
type: String as PropType<"horizontal" | "vertical">,
- default: "horizontal",
+ default: undefined,
},
dir: {
type: String as PropType<"ltr" | "rtl">,
@@ -125,10 +128,27 @@ export default defineComponent({
setup(props, { attrs, slots, emit }) {
const isSingle = computed(() => props.selectionMode !== "multiple");
const isDisabled = computed(() => props.isDisabled || props.disabled);
- const orientation = computed(() => props.orientation);
+ const toolbar = inject(toolbarKey, undefined);
+ const rootEl = ref();
+ function setRoot(el: unknown) {
+ const node = el as { $el?: HTMLElement } | HTMLElement | null;
+ const next = !node
+ ? undefined
+ : node instanceof HTMLElement
+ ? node
+ : ((node.$el as HTMLElement) ?? undefined);
+ if (rootEl.value === next) return;
+ rootEl.value = next;
+ }
+ const inToolbarDom = computed(() =>
+ Boolean(toolbar && rootEl.value && toolbar.owns(rootEl.value)),
+ );
+ const orientation = computed(
+ () => props.orientation ?? toolbar?.orientation.value ?? "horizontal",
+ );
const config = useConfig();
const dir = computed<"ltr" | "rtl">(
- () => props.dir ?? config?.dir.value ?? "ltr",
+ () => props.dir ?? toolbar?.dir.value ?? config?.dir.value ?? "ltr",
);
const selection = useToggleButtonSelection({
@@ -166,10 +186,18 @@ export default defineComponent({
change: selection.request,
orientation,
dir,
- tabIndex: roving.tabIndex,
- register: (key, el, disabled) => roving.register({ key, el, disabled }),
- keydown: roving.keydown,
- noteFocus: roving.noteFocus,
+ // Focus ownership: defer only when this group is DOM-owned by a Toolbar.
+ tabIndex: (key) => (inToolbarDom.value ? -1 : roving.tabIndex(key)),
+ register: (key, el, disabled) =>
+ inToolbarDom.value ? () => {} : roving.register({ key, el, disabled }),
+ keydown: (event, key) => {
+ if (inToolbarDom.value) return;
+ roving.keydown(event, key);
+ },
+ noteFocus: (key) => {
+ if (inToolbarDom.value) return;
+ roving.noteFocus(key);
+ },
};
provide(toggleButtonGroupKey, groupContext);
@@ -179,6 +207,7 @@ export default defineComponent({
return h(
props.as,
{
+ ref: setRoot,
...attrs,
role: isSingle.value ? "radiogroup" : "toolbar",
class: [slotsMap.value.base(), attrs.class],
diff --git a/packages/vue/src/components/toggle-button/ToggleButton.vue b/packages/vue/src/components/toggle-button/ToggleButton.vue
index 48063f6..6763090 100644
--- a/packages/vue/src/components/toggle-button/ToggleButton.vue
+++ b/packages/vue/src/components/toggle-button/ToggleButton.vue
@@ -9,6 +9,7 @@ import {
toggleButtonGroupKey,
type ToggleButtonGroupKey,
} from "../toggle-button-group/context";
+import { toolbarKey } from "../toolbar/context";
defineOptions({ inheritAttrs: false });
@@ -48,6 +49,7 @@ const emit = defineEmits<{
const attrs = useAttrs();
const group = inject(toggleButtonGroupKey, undefined);
+const toolbar = inject(toolbarKey, undefined);
const groupKey = computed(() => {
const key = props.value ?? props.id;
return key === undefined || key === null ? null : key;
@@ -101,14 +103,13 @@ let unregister: (() => void) | undefined;
function setRoot(el: unknown) {
const node = el as { $el?: HTMLElement } | HTMLElement | null;
- if (!node) {
- root.value = undefined;
- return;
- }
- root.value =
- node instanceof HTMLElement
+ const next = !node
+ ? undefined
+ : node instanceof HTMLElement
? node
: ((node.$el as HTMLElement) ?? undefined);
+ if (root.value === next) return;
+ root.value = next;
}
watch(
@@ -122,19 +123,28 @@ watch(
{ flush: "sync" },
);
+const inToolbarDom = computed(() =>
+ Boolean(toolbar && root.value && toolbar.owns(root.value)),
+);
+
function bindRegistration() {
unregister?.();
unregister = undefined;
+ if (toolbar && inToolbarDom.value) {
+ unregister = toolbar.register(() => root.value, disabled);
+ return;
+ }
if (!inGroup.value || !group || groupKey.value === null) return;
unregister = group.register(groupKey.value, () => root.value, disabled);
}
watch(
- () => [inGroup.value, groupKey.value] as const,
+ () =>
+ [inGroup.value, groupKey.value, root.value, inToolbarDom.value] as const,
() => {
bindRegistration();
},
- { immediate: true },
+ { immediate: true, flush: "post" },
);
onBeforeUnmount(() => unregister?.());
@@ -147,12 +157,18 @@ function guard(e: MouseEvent) {
function focus(e: FocusEvent) {
focused.value = true;
focusVisible.value = (e.target as HTMLElement).matches(":focus-visible");
+ if (inToolbarDom.value) {
+ toolbar!.noteFocus(root.value);
+ return;
+ }
if (inGroup.value && group && groupKey.value !== null) {
group.noteFocus(groupKey.value);
}
}
function onKeydown(e: KeyboardEvent) {
if (e.defaultPrevented) return;
+ // Toolbar root handles bubbled arrows for owned nodes only.
+ if (inToolbarDom.value) return;
if (!inGroup.value || !group || groupKey.value === null) return;
group.keydown(e, groupKey.value);
}
@@ -164,18 +180,27 @@ const finalVariant = computed(() => props.variant ?? "default");
const domId = computed(() =>
inGroup.value ? (attrs.id as string | undefined) : props.id,
);
-const tabIndex = computed(() =>
- inGroup.value && group && groupKey.value !== null
+const tabIndex = computed(() => {
+ if (inToolbarDom.value) return toolbar!.tabIndex(root.value);
+ return inGroup.value && group && groupKey.value !== null
? group.tabIndex(groupKey.value)
- : undefined,
-);
+ : undefined;
+});
+
+/** Merge focus-owner attributes during rendering; preserve asChild attributes otherwise. */
+function rootBind() {
+ const bound: Record = { ...attrs };
+ const tab = tabIndex.value;
+ if (tab !== undefined) bound.tabindex = tab;
+ return bound;
+}
+import {
+ computed,
+ defineComponent,
+ h,
+ onBeforeUnmount,
+ onUpdated,
+ provide,
+ ref,
+ useAttrs,
+ type PropType,
+} from "vue";
+import { toolbarVariants } from "@heroui-vue/styles";
+import { buttonGroupOrientationKey } from "../button-group/context";
+import { useConfig } from "../../providers/context";
+import {
+ toolbarKey,
+ type ToolbarContextValue,
+ type ToolbarDir,
+ type ToolbarOrientation,
+} from "./context";
+import { useToolbarFocus } from "./useToolbarFocus";
+
+type Handler = (event: Event) => void;
+
+function mergeHandlers(
+ ...parts: Array
+): Handler[] {
+ const list: Handler[] = [];
+ for (const part of parts) {
+ if (!part) continue;
+ if (Array.isArray(part)) list.push(...part.filter(Boolean));
+ else list.push(part);
+ }
+ return list;
+}
+
+export default defineComponent({
+ name: "Toolbar",
+ inheritAttrs: false,
+ props: {
+ isAttached: { type: Boolean, default: false },
+ orientation: {
+ type: String as PropType,
+ default: "horizontal",
+ },
+ dir: {
+ type: String as PropType,
+ default: undefined,
+ },
+ as: { type: String, default: "div" },
+ },
+ setup(props, { attrs, slots }) {
+ const config = useConfig();
+ const orientation = computed(() => props.orientation);
+ const dir = computed(
+ () => props.dir ?? config?.dir.value ?? "ltr",
+ );
+ const separatorOrientation = computed(() =>
+ orientation.value === "horizontal" ? "vertical" : "horizontal",
+ );
+
+ const focus = useToolbarFocus({
+ orientation: () => orientation.value,
+ dir: () => dir.value,
+ });
+
+ const rootEl = ref();
+ function setRoot(el: unknown) {
+ const node = el as { $el?: HTMLElement } | HTMLElement | null;
+ if (!node) {
+ rootEl.value = undefined;
+ focus.setRoot(undefined);
+ return;
+ }
+ rootEl.value =
+ node instanceof HTMLElement
+ ? node
+ : ((node.$el as HTMLElement) ?? undefined);
+ focus.setRoot(rootEl.value);
+ }
+
+ const slotsMap = computed(() =>
+ toolbarVariants({
+ isAttached: props.isAttached,
+ orientation: orientation.value,
+ }),
+ );
+
+ const toolbarContext: ToolbarContextValue = {
+ slots: slotsMap,
+ orientation,
+ dir,
+ separatorOrientation,
+ register: (el, disabled) => focus.register({ el, disabled }),
+ tabIndex: focus.tabIndex,
+ noteFocus: focus.noteFocus,
+ keydown: focus.keydown,
+ owns: focus.owns,
+ };
+
+ provide(toolbarKey, toolbarContext);
+ provide(buttonGroupOrientationKey, orientation);
+ onBeforeUnmount(() => focus.dispose());
+ // Teleport moves the same nodes; refresh ownership when this subtree updates.
+ onUpdated(() => focus.refresh());
+
+ function render() {
+ const userKeydown = (attrs as Record).onKeydown as
+ Handler | Handler[] | undefined;
+ const rest: Record = { ...attrs };
+ delete rest.onKeydown;
+ // Caller handlers run first so preventDefault can cancel navigation.
+ const keydownHandlers = mergeHandlers(userKeydown, (event: Event) => {
+ toolbarContext.keydown(event as KeyboardEvent);
+ });
+ return h(
+ props.as,
+ {
+ ...rest,
+ role: "toolbar",
+ "aria-orientation": orientation.value,
+ class: [slotsMap.value, attrs.class],
+ "data-slot": "toolbar",
+ dir: dir.value,
+ ref: setRoot,
+ onKeydown: keydownHandlers,
+ },
+ slots.default?.({ orientation: orientation.value }),
+ );
+ }
+
+ return render;
+ },
+});
+
diff --git a/packages/vue/src/components/toolbar/context.ts b/packages/vue/src/components/toolbar/context.ts
new file mode 100644
index 0000000..e3b1f16
--- /dev/null
+++ b/packages/vue/src/components/toolbar/context.ts
@@ -0,0 +1,29 @@
+import type { ComputedRef, InjectionKey } from "vue";
+
+export type ToolbarOrientation = "horizontal" | "vertical";
+export type ToolbarDir = "ltr" | "rtl";
+
+export interface ToolbarContextValue {
+ /** Class string from toolbarVariants. */
+ slots: ComputedRef;
+ orientation: ComputedRef;
+ dir: ComputedRef;
+ /** Separator default direction is perpendicular to the toolbar. */
+ separatorOrientation: ComputedRef;
+ /** Register a focusable member; returns unregister. */
+ register: (
+ el: () => HTMLElement | undefined,
+ disabled: ComputedRef,
+ ) => () => void;
+ /** Single Tab entry; undefined when the element is outside the toolbar DOM. */
+ tabIndex: (el: HTMLElement | undefined) => number | undefined;
+ /** Sync Tab entry after a real focus. */
+ noteFocus: (el: HTMLElement | undefined) => void;
+ /** Arrow/Home/End navigation across the whole toolbar. */
+ keydown: (event: KeyboardEvent) => void;
+ /** Whether an element is rendered inside this toolbar (excludes Teleport). */
+ owns: (el: HTMLElement | undefined | null) => boolean;
+}
+
+export const toolbarKey: InjectionKey =
+ Symbol("HeroUIVue.Toolbar");
diff --git a/packages/vue/src/components/toolbar/useToolbarFocus.ts b/packages/vue/src/components/toolbar/useToolbarFocus.ts
new file mode 100644
index 0000000..df9f479
--- /dev/null
+++ b/packages/vue/src/components/toolbar/useToolbarFocus.ts
@@ -0,0 +1,220 @@
+import { ref, watch, type ComputedRef } from "vue";
+import type { ToolbarDir, ToolbarOrientation } from "./context";
+
+export interface ToolbarMember {
+ el: () => HTMLElement | undefined;
+ disabled: ComputedRef;
+}
+
+function domOrder(members: ToolbarMember[]): ToolbarMember[] {
+ const placed = members.map((m) => ({ m, el: m.el() }));
+ const withEl = placed.filter(
+ (p): p is { m: ToolbarMember; el: HTMLElement } => !!p.el,
+ );
+ const without = placed.filter((p) => !p.el).map((p) => p.m);
+ withEl.sort((a, b) => {
+ const pos = a.el.compareDocumentPosition(b.el);
+ if (pos & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
+ if (pos & Node.DOCUMENT_POSITION_PRECEDING) return 1;
+ return 0;
+ });
+ return [...withEl.map((p) => p.m), ...without];
+}
+
+/**
+ * Element-based roving tabindex for a toolbar.
+ * Owns arrow navigation across DOM-contained members only (Teleport-safe).
+ */
+export function useToolbarFocus(options: {
+ orientation: () => ToolbarOrientation;
+ dir: () => ToolbarDir;
+}) {
+ const members = new Set();
+ const version = ref(0);
+ const activeEl = ref(null);
+ const rootEl = ref(null);
+ let observer: MutationObserver | undefined;
+
+ function bump() {
+ version.value++;
+ }
+
+ function disconnectObserver() {
+ observer?.disconnect();
+ observer = undefined;
+ }
+
+ function watchSubtree(el: HTMLElement) {
+ disconnectObserver();
+ if (typeof MutationObserver === "undefined") return;
+ // childList only: DOM moves (Teleport) change membership without attribute loops
+ observer = new MutationObserver(() => {
+ bump();
+ });
+ observer.observe(el, { childList: true, subtree: true });
+ }
+
+ function setRoot(el: HTMLElement | null | undefined) {
+ const next = el ?? null;
+ if (rootEl.value === next) return;
+ rootEl.value = next;
+ if (next) watchSubtree(next);
+ else disconnectObserver();
+ bump();
+ }
+
+ function dispose() {
+ disconnectObserver();
+ members.clear();
+ }
+
+ /** Re-evaluate DOM membership after moves (Teleport, reparent). */
+ function refresh() {
+ bump();
+ syncActive();
+ }
+
+ /** True when the element is rendered inside this toolbar's DOM subtree. */
+ function owns(el: HTMLElement | undefined | null): boolean {
+ // Track subtree moves so computed owners refresh after Teleport.
+ void version.value;
+ if (!el || !rootEl.value) return false;
+ return rootEl.value === el || rootEl.value.contains(el);
+ }
+
+ function ordered(): ToolbarMember[] {
+ void version.value;
+ return domOrder(
+ [...members].filter((m) => {
+ const el = m.el();
+ return !m.disabled.value && el && owns(el);
+ }),
+ );
+ }
+
+ function syncActive() {
+ const list = ordered();
+ const activeOk =
+ activeEl.value &&
+ list.some((m) => m.el() === activeEl.value) &&
+ !activeEl.value.hasAttribute("disabled");
+ if (!activeOk) {
+ activeEl.value = list[0]?.el() ?? null;
+ }
+ }
+
+ function register(member: ToolbarMember) {
+ members.add(member);
+ bump();
+ syncActive();
+ const stop = watch(
+ member.disabled,
+ () => {
+ syncActive();
+ bump();
+ },
+ { flush: "sync" },
+ );
+ return () => {
+ stop();
+ members.delete(member);
+ syncActive();
+ bump();
+ };
+ }
+
+ function tabIndex(el: HTMLElement | undefined): number | undefined {
+ // Non-members (e.g. teleported) keep caller tabindex.
+ if (!el || !owns(el)) return undefined;
+ const list = ordered();
+ if (!list.length) return -1;
+ syncActive();
+ return el === activeEl.value ? 0 : -1;
+ }
+
+ function noteFocus(el: HTMLElement | undefined) {
+ if (!el || !owns(el)) return;
+ const member = [...members].find((m) => m.el() === el);
+ if (member?.disabled.value) return;
+ if (activeEl.value === el) return;
+ activeEl.value = el;
+ bump();
+ }
+
+ function focusMember(member: ToolbarMember) {
+ const el = member.el();
+ if (!el || !owns(el)) return;
+ activeEl.value = el;
+ bump();
+ el.focus();
+ }
+
+ function keydown(event: KeyboardEvent) {
+ if (event.defaultPrevented) return;
+ const list = ordered();
+ if (!list.length) return;
+ const current = (event.target as HTMLElement | null) ?? activeEl.value;
+ const index = list.findIndex((m) => m.el() === current);
+ if (index < 0) return;
+
+ const horizontal = options.orientation() === "horizontal";
+ const rtl = options.dir() === "rtl";
+ let nextIndex = index;
+
+ if (horizontal) {
+ switch (event.key) {
+ case "ArrowRight":
+ nextIndex = rtl
+ ? (index - 1 + list.length) % list.length
+ : (index + 1) % list.length;
+ break;
+ case "ArrowLeft":
+ nextIndex = rtl
+ ? (index + 1) % list.length
+ : (index - 1 + list.length) % list.length;
+ break;
+ case "Home":
+ nextIndex = 0;
+ break;
+ case "End":
+ nextIndex = list.length - 1;
+ break;
+ default:
+ return;
+ }
+ } else {
+ switch (event.key) {
+ case "ArrowDown":
+ nextIndex = (index + 1) % list.length;
+ break;
+ case "ArrowUp":
+ nextIndex = (index - 1 + list.length) % list.length;
+ break;
+ case "Home":
+ nextIndex = 0;
+ break;
+ case "End":
+ nextIndex = list.length - 1;
+ break;
+ default:
+ return;
+ }
+ }
+
+ event.preventDefault();
+ event.stopPropagation();
+ focusMember(list[nextIndex]!);
+ }
+
+ return {
+ register,
+ tabIndex,
+ noteFocus,
+ keydown,
+ setRoot,
+ owns,
+ dispose,
+ refresh,
+ version,
+ };
+}
diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts
index ca95b64..d26ecd9 100644
--- a/packages/vue/src/index.ts
+++ b/packages/vue/src/index.ts
@@ -527,3 +527,12 @@ export type {
ToggleButtonGroupProps,
ToggleButtonGroupSeparatorProps,
} from "./types";
+
+export { default as Toolbar } from "./components/toolbar/Toolbar.vue";
+export type {
+ ToolbarOrientation,
+ ToolbarDir,
+ ToolbarContextValue,
+} from "./components/toolbar/context";
+export { toolbarVariants, type ToolbarVariants } from "@heroui-vue/styles";
+export type { ToolbarProps } from "./types";
diff --git a/packages/vue/src/types.ts b/packages/vue/src/types.ts
index 510194d..ed17f08 100644
--- a/packages/vue/src/types.ts
+++ b/packages/vue/src/types.ts
@@ -392,3 +392,6 @@ export type ToggleButtonGroupProps = InstanceType<
export type ToggleButtonGroupSeparatorProps = InstanceType<
typeof ToggleButtonGroupSeparator
>["$props"];
+
+import type Toolbar from "./components/toolbar/Toolbar.vue";
+export type ToolbarProps = InstanceType["$props"];
diff --git a/tests/m29-review.probe.test.ts b/tests/m29-review.probe.test.ts
new file mode 100644
index 0000000..215ae01
--- /dev/null
+++ b/tests/m29-review.probe.test.ts
@@ -0,0 +1,108 @@
+import { afterEach, expect, it, vi } from "vitest";
+import { mount } from "@vue/test-utils";
+import { defineComponent, nextTick, ref } from "vue";
+import {
+ Button,
+ Toolbar,
+ ToggleButton,
+ ToggleButtonGroup,
+} from "../packages/vue/src";
+
+const wrappers: ReturnType[] = [];
+afterEach(() => {
+ wrappers.splice(0).forEach((wrapper) => wrapper.unmount());
+ document.body.innerHTML = "";
+});
+function fixture(template: string, setup = () => ({})) {
+ const wrapper = mount(
+ defineComponent({
+ components: { Button, Toolbar, ToggleButton, ToggleButtonGroup },
+ template,
+ setup,
+ }),
+ { attachTo: document.body },
+ );
+ wrappers.push(wrapper);
+ return wrapper;
+}
+
+it("standalone Button preserves the caller tabindex after Toolbar integration", async () => {
+ const wrapper = fixture('');
+ await nextTick();
+ expect(wrapper.get("button").attributes("tabindex")).toBe("-1");
+});
+
+it("standalone asChild buttons preserve tabindex supplied by their native child", async () => {
+ const wrapper = fixture(
+ 'Toggle child
',
+ );
+ await nextTick();
+ expect(
+ wrapper.findAll("button").map((button) => button.attributes("tabindex")),
+ ).toEqual(["-1", "-1"]);
+});
+
+it("moving an existing Button through Teleport restores its own tabindex", async () => {
+ const inline = ref(true);
+ const wrapper = fixture(
+ 'AMoving',
+ () => ({ inline }),
+ );
+ await nextTick();
+ const moving = document.querySelector("[data-outside]") as HTMLButtonElement;
+ expect(moving.getAttribute("tabindex")).toBe("-1");
+ inline.value = false;
+ await nextTick();
+ expect(wrapper.element.contains(moving)).toBe(false);
+ expect(moving.getAttribute("tabindex")).toBe("3");
+});
+
+it("moving an existing group outside Toolbar restores its arrow navigation", async () => {
+ const inline = ref(true);
+ fixture(
+ 'AXY',
+ () => ({ inline }),
+ );
+ await nextTick();
+ inline.value = false;
+ await nextTick();
+ const buttons = document.querySelectorAll(
+ "[data-moving] button",
+ );
+ buttons[0].focus();
+ buttons[0].dispatchEvent(
+ new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }),
+ );
+ await nextTick();
+ expect(document.activeElement).toBe(buttons[1]);
+});
+
+it("Toolbar root keydown handler is preserved and can cancel navigation", async () => {
+ const handler = vi.fn((event: KeyboardEvent) => event.preventDefault());
+ const wrapper = fixture(
+ 'AB',
+ () => ({ handler }),
+ );
+ await nextTick();
+ const buttons = wrapper.findAll("button");
+ (buttons[0].element as HTMLElement).focus();
+ await buttons[0].trigger("keydown", { key: "ArrowRight" });
+ expect(handler).toHaveBeenCalledTimes(1);
+ expect(document.activeElement).toBe(buttons[0].element);
+});
+
+it("Toolbar navigation excludes controls teleported outside its DOM", async () => {
+ const wrapper = fixture(
+ 'ABOutside',
+ );
+ await nextTick();
+ const buttons = wrapper.findAll("button");
+ expect(buttons).toHaveLength(2);
+ (buttons[1].element as HTMLElement).focus();
+ await buttons[1].trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[0].element);
+ const outside = [...document.querySelectorAll("button")].find(
+ (button) => button.textContent === "Outside",
+ );
+ expect(outside?.hasAttribute("tabindex")).toBe(false);
+});
diff --git a/tests/ssr.test.ts b/tests/ssr.test.ts
index 08002aa..437152f 100644
--- a/tests/ssr.test.ts
+++ b/tests/ssr.test.ts
@@ -530,3 +530,40 @@ it("keeps standalone ToggleButton DOM ids stable on the server", async () => {
);
expect(html).toContain('id="like-toggle"');
});
+
+it("renders Toolbar with nested groups without browser globals", async () => {
+ const {
+ Toolbar,
+ Button,
+ ButtonGroup,
+ Separator,
+ ToggleButton,
+ ToggleButtonGroup,
+ } = await import("../packages/vue/src");
+ const html = await renderToString(
+ createSSRApp({
+ render: () =>
+ h(
+ Toolbar,
+ {
+ "aria-label": "文本格式",
+ orientation: "vertical",
+ isAttached: true,
+ },
+ () => [
+ h(ToggleButtonGroup, { selectionMode: "multiple" }, () => [
+ h(ToggleButton, { id: "bold" }, () => "Bold"),
+ ]),
+ h(Separator),
+ h(ButtonGroup, () => h(Button, () => "Copy")),
+ ],
+ ),
+ }),
+ );
+ expect(html).toContain('role="toolbar"');
+ expect(html).toContain('aria-orientation="vertical"');
+ expect(html).toContain("hv-toolbar--attached");
+ expect(html).toContain('data-slot="toggle-button-group"');
+ expect(html).toContain("hv-separator--horizontal");
+ expect(html).toContain('data-slot="button-group"');
+});
diff --git a/tests/toolbar.test.ts b/tests/toolbar.test.ts
new file mode 100644
index 0000000..eb0e502
--- /dev/null
+++ b/tests/toolbar.test.ts
@@ -0,0 +1,715 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { mount, flushPromises } from "@vue/test-utils";
+import { Teleport, defineComponent, h, nextTick, ref } from "vue";
+import { readFileSync } from "node:fs";
+import {
+ Button,
+ ButtonGroup,
+ ButtonGroupSeparator,
+ Separator,
+ ToggleButton,
+ ToggleButtonGroup,
+ ToggleButtonGroupSeparator,
+ Toolbar,
+} from "../packages/vue/src";
+
+afterEach(() => {
+ document.body.innerHTML = "";
+});
+
+function mountTo(
+ comp: T,
+ props: Record = {},
+ setup?: () => Record,
+) {
+ return mount(
+ defineComponent({
+ components: {
+ Button,
+ ButtonGroup,
+ ButtonGroupSeparator,
+ Separator,
+ ToggleButton,
+ ToggleButtonGroup,
+ ToggleButtonGroupSeparator,
+ Toolbar,
+ },
+ setup: setup ?? (() => ({})),
+ ...comp,
+ }),
+ { attachTo: document.body },
+ );
+}
+
+describe("Toolbar basics", () => {
+ it("renders role, data-slot, aria-orientation and classes", () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "文本格式" }, () => [
+ h(Button, () => "One"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ const root = w.get('[role="toolbar"]');
+ expect(root.attributes("data-slot")).toBe("toolbar");
+ expect(root.attributes("aria-label")).toBe("文本格式");
+ expect(root.attributes("aria-orientation")).toBe("horizontal");
+ expect(root.classes().join(" ")).toContain("hv-toolbar");
+ expect(root.classes().join(" ")).toContain("hv-toolbar--horizontal");
+ w.unmount();
+ });
+
+ it("exposes vertical and attached modifiers", () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(
+ Toolbar,
+ { orientation: "vertical", isAttached: true, "aria-label": "工具" },
+ () => [h(Button, () => "One")],
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ const classes = w.get('[role="toolbar"]').classes().join(" ");
+ expect(classes).toContain("hv-toolbar--vertical");
+ expect(classes).toContain("hv-toolbar--attached");
+ expect(w.get('[role="toolbar"]').attributes("aria-orientation")).toBe(
+ "vertical",
+ );
+ w.unmount();
+ });
+
+ it("passes orientation to the scoped slot and merges attrs/class", async () => {
+ const seen: string[] = [];
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(
+ Toolbar,
+ { orientation: "vertical", class: "extra", "data-testid": "bar" },
+ {
+ default: (scope: { orientation: string }) => {
+ seen.push(scope.orientation);
+ return [h(Button, () => "One")];
+ },
+ },
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ expect(seen).toEqual(["vertical"]);
+ const root = w.get('[data-testid="bar"]');
+ expect(root.classes().join(" ")).toContain("extra");
+ expect(root.classes().join(" ")).toContain("hv-toolbar--vertical");
+ w.unmount();
+ });
+
+ it("updates class and aria when orientation and isAttached change", async () => {
+ const vertical = ref(false);
+ const attached = ref(false);
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(
+ Toolbar,
+ {
+ orientation: vertical.value ? "vertical" : "horizontal",
+ isAttached: attached.value,
+ "aria-label": "bar",
+ },
+ () => [h(Button, () => "One")],
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ vertical.value = true;
+ attached.value = true;
+ await nextTick();
+ const root = w.get('[role="toolbar"]');
+ expect(root.attributes("aria-orientation")).toBe("vertical");
+ expect(root.classes().join(" ")).toContain("hv-toolbar--vertical");
+ expect(root.classes().join(" ")).toContain("hv-toolbar--attached");
+ w.unmount();
+ });
+});
+
+describe("Toolbar keyboard ownership", () => {
+ const withGroups = () =>
+ h(Toolbar, { "aria-label": "编辑器" }, () => [
+ h(ButtonGroup, { variant: "tertiary" }, () => [
+ h(Button, () => "Undo"),
+ h(Button, () => [h(ButtonGroupSeparator), "Redo"]),
+ ]),
+ h(Separator),
+ h(
+ ToggleButtonGroup,
+ { selectionMode: "multiple", "aria-label": "styles" },
+ () => [
+ h(ToggleButton, { id: "bold" }, () => "Bold"),
+ h(ToggleButton, { id: "italic" }, () => [
+ h(ToggleButtonGroupSeparator),
+ "Italic",
+ ]),
+ ],
+ ),
+ ]);
+
+ it("moves once per arrow key across ButtonGroup and ToggleButtonGroup", async () => {
+ const w = mount(defineComponent({ render: withGroups }), {
+ attachTo: document.body,
+ });
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ expect(buttons).toHaveLength(4);
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ await buttons[1]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[2]!.element);
+ await buttons[2]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[3]!.element);
+ w.unmount();
+ });
+
+ it("keeps a single Tab entry across nested groups", async () => {
+ const w = mount(defineComponent({ render: withGroups }), {
+ attachTo: document.body,
+ });
+ await nextTick();
+ await flushPromises();
+ const stops = w
+ .findAll("button")
+ .filter((b) => b.attributes("tabindex") === "0");
+ expect(stops).toHaveLength(1);
+ w.unmount();
+ });
+
+ it("real focus moves the toolbar Tab entry", async () => {
+ const w = mount(defineComponent({ render: withGroups }), {
+ attachTo: document.body,
+ });
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[3]!.element as HTMLElement).focus();
+ await nextTick();
+ expect(buttons[3]!.attributes("tabindex")).toBe("0");
+ expect(
+ buttons.filter((b) => b.attributes("tabindex") === "0"),
+ ).toHaveLength(1);
+ w.unmount();
+ });
+
+ it("skips disabled members and promotes the next entry", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(Button, { isDisabled: true }, () => "No"),
+ h(Button, () => "Yes"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ expect(buttons[1]!.attributes("tabindex")).toBe("0");
+ (buttons[1]!.element as HTMLElement).focus();
+ await buttons[1]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ w.unmount();
+ });
+
+ it("reverses horizontal arrows in RTL across three members", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar", dir: "rtl" }, () => [
+ h(Button, () => "A"),
+ h(Button, () => "B"),
+ h(Button, () => "C"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowLeft" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ await buttons[1]!.trigger("keydown", { key: "ArrowLeft" });
+ expect(document.activeElement).toBe(buttons[2]!.element);
+ await buttons[2]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ w.unmount();
+ });
+
+ it("vertical toolbar uses up/down and ignores horizontal arrows", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar", orientation: "vertical" }, () => [
+ h(Button, () => "A"),
+ h(Button, () => "B"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[0]!.element);
+ await buttons[0]!.trigger("keydown", { key: "ArrowDown" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ w.unmount();
+ });
+
+ it("respects preventDefault on arrow keys", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(
+ Button,
+ { onKeydown: (e: KeyboardEvent) => e.preventDefault() },
+ () => "A",
+ ),
+ h(Button, () => "B"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[0]!.element);
+ w.unmount();
+ });
+
+ it("does not toggle selection when navigating with arrows", async () => {
+ const change = vi.fn();
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(
+ ToggleButtonGroup,
+ {
+ selectionMode: "multiple",
+ onSelectionChange: change,
+ },
+ () => [
+ h(ToggleButton, { id: "a" }, () => "A"),
+ h(ToggleButton, { id: "b" }, () => "B"),
+ ],
+ ),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ expect(change).not.toHaveBeenCalled();
+ w.unmount();
+ });
+
+ it("Home and End move to toolbar edges", async () => {
+ const w = mount(defineComponent({ render: withGroups }), {
+ attachTo: document.body,
+ });
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[1]!.element as HTMLElement).focus();
+ await buttons[1]!.trigger("keydown", { key: "End" });
+ expect(document.activeElement).toBe(buttons[3]!.element);
+ await buttons[3]!.trigger("keydown", { key: "Home" });
+ expect(document.activeElement).toBe(buttons[0]!.element);
+ w.unmount();
+ });
+
+ it("nested toolbars isolate arrow navigation", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "outer" }, () => [
+ h(Button, () => "Outer"),
+ h(Toolbar, { "aria-label": "inner" }, () => [
+ h(Button, () => "Inner1"),
+ h(Button, () => "Inner2"),
+ ]),
+ h(Button, () => "Outer2"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ // DOM order: Outer, Inner1, Inner2, Outer2
+ (buttons[1]!.element as HTMLElement).focus();
+ await buttons[1]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[2]!.element);
+ await buttons[2]!.trigger("keydown", { key: "ArrowRight" });
+ // stays within inner when looping inner list? Inner has 2 items; next wraps to Inner1
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ w.unmount();
+ });
+
+ it("keyed reorder changes the next arrow target", async () => {
+ const keys = ref(["a", "b", "c"]);
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(Toolbar, { "aria-label": "bar" }, () =>
+ keys.value.map((key) => h(Button, { key }, () => key)),
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ keys.value = ["c", "b", "a"];
+ await nextTick();
+ const buttons = w.findAll("button");
+ expect(buttons.map((b) => b.text())).toEqual(["c", "b", "a"]);
+ (buttons[1]!.element as HTMLElement).focus();
+ await buttons[1]!.trigger("keydown", { key: "ArrowRight" });
+ expect(document.activeElement).toBe(buttons[2]!.element);
+ w.unmount();
+ });
+
+ it("Enter activates a toggle once and does not double-fire", async () => {
+ const change = vi.fn();
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(
+ ToggleButtonGroup,
+ { selectionMode: "multiple", onSelectionChange: change },
+ () => [h(ToggleButton, { id: "a" }, () => "A")],
+ ),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const button = w.get("button");
+ (button.element as HTMLElement).focus();
+ await button.trigger("keydown", { key: "Enter" });
+ await button.trigger("click");
+ expect(change).toHaveBeenCalledTimes(1);
+ w.unmount();
+ });
+});
+
+describe("Toolbar orientation inheritance", () => {
+ it("ToggleButtonGroup inherits toolbar orientation and restores after override", async () => {
+ const override = ref(undefined);
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(Toolbar, { orientation: "vertical", "aria-label": "bar" }, () => [
+ h(
+ ToggleButtonGroup,
+ {
+ selectionMode: "multiple",
+ orientation: override.value,
+ },
+ () => [h(ToggleButton, { id: "a" }, () => "A")],
+ ),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ let group = w.get('[data-slot="toggle-button-group"]');
+ expect(group.attributes("aria-orientation")).toBe("vertical");
+ override.value = "horizontal";
+ await nextTick();
+ group = w.get('[data-slot="toggle-button-group"]');
+ expect(group.attributes("aria-orientation")).toBe("horizontal");
+ override.value = undefined;
+ await nextTick();
+ group = w.get('[data-slot="toggle-button-group"]');
+ expect(group.attributes("aria-orientation")).toBe("vertical");
+ w.unmount();
+ });
+
+ it("Separator defaults to the perpendicular toolbar direction", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { orientation: "horizontal", "aria-label": "bar" }, () => [
+ h(Button, () => "A"),
+ h(Separator),
+ h(Button, () => "B"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ const sep = w.get('[data-slot="separator"]');
+ expect(sep.classes().join(" ")).toContain("hv-separator--vertical");
+ w.unmount();
+ });
+
+ it("explicit Separator orientation overrides toolbar default", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { orientation: "horizontal", "aria-label": "bar" }, () => [
+ h(Button, () => "A"),
+ h(Separator, { orientation: "horizontal" }),
+ h(Button, () => "B"),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ const sep = w.get('[data-slot="separator"]');
+ expect(sep.classes().join(" ")).toContain("hv-separator--horizontal");
+ w.unmount();
+ });
+});
+
+describe("Toolbar demos", () => {
+ it("mounts all 5 baseline demos without Vue warnings", async () => {
+ const warnings: string[] = [];
+ const spy = vi.spyOn(console, "warn").mockImplementation((...args) => {
+ warnings.push(args.map(String).join(" "));
+ });
+ const names = [
+ "basic",
+ "vertical",
+ "attached",
+ "with-button-group",
+ "custom-styles",
+ ];
+ for (const name of names) {
+ const mod = await import(`../apps/docs/demos/toolbar-${name}.vue`);
+ const w = mount(mod.default, { attachTo: document.body });
+ await nextTick();
+ expect(w.html().length).toBeGreaterThan(0);
+ w.unmount();
+ }
+ spy.mockRestore();
+ expect(warnings).toEqual([]);
+ });
+
+ it("includes every preview in the pinned upstream Toolbar document", () => {
+ const document = readFileSync("apps/docs/components/toolbar.md", "utf8");
+ const names = [
+ ...document.matchAll(/ m[1]);
+ expect(names).toEqual([
+ "basic",
+ "vertical",
+ "attached",
+ "with-button-group",
+ "custom-styles",
+ ]);
+ });
+});
+
+describe("M29 review boundaries", () => {
+ it("keeps caller tabindex through add/remove/re-add on standalone Button", async () => {
+ const tab = ref(-1);
+ const w = mount(
+ defineComponent({
+ setup: () => () => h(Button, { tabindex: tab.value }, () => "Solo"),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ expect(w.get("button").attributes("tabindex")).toBe("-1");
+ tab.value = undefined;
+ await nextTick();
+ expect(w.get("button").attributes("tabindex")).toBeUndefined();
+ tab.value = 0;
+ await nextTick();
+ expect(w.get("button").attributes("tabindex")).toBe("0");
+ w.unmount();
+ });
+
+ it("runs root keydown handler arrays in order and honors stopImmediatePropagation", async () => {
+ const calls: string[] = [];
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(
+ Toolbar,
+ {
+ "aria-label": "bar",
+ onKeydown: [
+ (e: KeyboardEvent) => {
+ calls.push("first");
+ e.stopImmediatePropagation();
+ },
+ () => {
+ calls.push("second");
+ },
+ ],
+ },
+ () => [h(Button, () => "A"), h(Button, () => "B")],
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(calls).toEqual(["first"]);
+ expect(document.activeElement).toBe(buttons[0]!.element);
+ w.unmount();
+ });
+
+ it("supports removing and re-adding the root keydown handler", async () => {
+ const enable = ref(true);
+ const handler = vi.fn((event: KeyboardEvent) => event.preventDefault());
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(
+ Toolbar,
+ {
+ "aria-label": "bar",
+ onKeydown: enable.value ? handler : undefined,
+ },
+ () => [h(Button, () => "A"), h(Button, () => "B")],
+ ),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const buttons = w.findAll("button");
+ (buttons[0]!.element as HTMLElement).focus();
+ enable.value = false;
+ await nextTick();
+ await buttons[0]!.trigger("keydown", { key: "ArrowRight" });
+ expect(handler).not.toHaveBeenCalled();
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ enable.value = true;
+ await nextTick();
+ (buttons[1]!.element as HTMLElement).focus();
+ await buttons[1]!.trigger("keydown", { key: "ArrowLeft" });
+ expect(handler).toHaveBeenCalled();
+ expect(document.activeElement).toBe(buttons[1]!.element);
+ w.unmount();
+ });
+
+ it("restores ToggleButtonGroup navigation after teleporting outside the toolbar", async () => {
+ const w = mount(
+ defineComponent({
+ render: () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(ToggleButtonGroup, { selectionMode: "multiple" }, () => [
+ h(ToggleButton, { value: "a" }, () => "A"),
+ h(ToggleButton, { value: "b" }, () => "B"),
+ ]),
+ h(Teleport, { to: "body" }, () => [
+ h(
+ ToggleButtonGroup,
+ { selectionMode: "multiple", "data-testid": "outside" },
+ () => [
+ h(ToggleButton, { value: "x" }, () => "X"),
+ h(ToggleButton, { value: "y" }, () => "Y"),
+ ],
+ ),
+ ]),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ await flushPromises();
+ const outside = document.querySelector('[data-testid="outside"]');
+ expect(outside).toBeTruthy();
+ const outButtons = [
+ ...(outside!.querySelectorAll("button") as NodeListOf),
+ ];
+ expect(outButtons).toHaveLength(2);
+ expect(outButtons[0]!.getAttribute("tabindex")).toBe("0");
+ expect(outButtons[1]!.getAttribute("tabindex")).toBe("-1");
+ outButtons[0]!.focus();
+ await flushPromises();
+ outButtons[0]!.dispatchEvent(
+ new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }),
+ );
+ await nextTick();
+ expect(document.activeElement).toBe(outButtons[1]);
+ w.unmount();
+ });
+});
+
+describe("M29 dynamic Teleport ownership", () => {
+ it("restores toolbar ownership when the same node moves back inside", async () => {
+ const inline = ref(false);
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(Button, () => "A"),
+ h(Teleport, { to: "body", disabled: inline.value }, () => [
+ h(Button, { tabindex: "3", "data-moving": "" }, () => "Moving"),
+ ]),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ const moving = document.querySelector("[data-moving]") as HTMLButtonElement;
+ expect(moving.getAttribute("tabindex")).toBe("3");
+ inline.value = true;
+ await nextTick();
+ expect(moving.getAttribute("tabindex")).toBe("-1");
+ inline.value = false;
+ await nextTick();
+ expect(moving.getAttribute("tabindex")).toBe("3");
+ w.unmount();
+ });
+
+ it("keeps single Tab entry after a toolbar-owned node leaves", async () => {
+ const inline = ref(true);
+ const w = mount(
+ defineComponent({
+ setup: () => () =>
+ h(Toolbar, { "aria-label": "bar" }, () => [
+ h(Button, () => "A"),
+ h(Teleport, { to: "body", disabled: inline.value }, () => [
+ h(Button, () => "Moving"),
+ ]),
+ ]),
+ }),
+ { attachTo: document.body },
+ );
+ await nextTick();
+ inline.value = false;
+ await nextTick();
+ const root = w.get('[role="toolbar"]');
+ const stops = root
+ .findAll("button")
+ .filter((b) => b.attributes("tabindex") === "0");
+ expect(stops).toHaveLength(1);
+ w.unmount();
+ });
+});
diff --git a/tests/types/button-toggle-contract.ts b/tests/types/button-toggle-contract.ts
index bdb656a..0ee03ed 100644
--- a/tests/types/button-toggle-contract.ts
+++ b/tests/types/button-toggle-contract.ts
@@ -71,3 +71,18 @@ function buttonToggleContract() {
};
}
void buttonToggleContract;
+
+import type { ToolbarProps } from "../../packages/vue/src";
+import { Toolbar } from "../../packages/vue/src";
+
+function toolbarContract() {
+ const ok: ToolbarProps = {
+ isAttached: true,
+ orientation: "vertical",
+ dir: "rtl",
+ };
+ // @ts-expect-error unsupported orientation
+ const bad: ToolbarProps = { orientation: "diagonal" };
+ return { bad, ok, Toolbar };
+}
+void toolbarContract;