HoverCard (悬停卡片)
鼠标悬停或键盘聚焦在链接上时浮出的预览卡片,点击照常跟随链接,触屏上不出现。
基础用法
鼠标停在链接上 openDelay(默认 600ms)后浮出,移开后留 closeDelay 的余量,沿安全三角移进卡片不会关闭,卡片里的按钮照常可点。 点击不被拦截:点头像照常跟随链接,同时关闭卡片,不会跟着页面切换残留。 触屏上不出现——轻点就是打开链接。
发布于 3 小时前
Basic.vue
列表中的分组
同一 group 的卡片同时只开一张;一张打开后移到相邻头像立即切换,不再等 openDelay。触发器外层是 display: contents, 不产生盒子,放进 flex 行里不改变头像的布局。
打开时加载
卡片内容只在打开期间挂载,放在内容组件 setup 里的请求就是在打开时发出的。 需要在外面知道开合(预取、埋点)时绑定 v-model:open。
LazyContent.vue
键盘与读屏
键盘 Tab 到链接(:focus-visible)时同样在 openDelay 后打开, 离开或按 Esc 关闭;鼠标点击带来的聚焦不会打开。卡片是补充预览:没有 role, 不移动焦点,也不在 Tab 顺序里,链接本身始终是唯一的可访问入口——所以不要把 目标页面上没有的信息或操作只放在卡片里。需要可交互、可聚焦的浮层用 KunPopover。
属性
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| autoPosition | boolean | true | Avoid viewport collisions: flip to the opposite side, shift along the edge, and cap height/width to the available space so tall content scrolls instead of overflowing. Set `false` to honour `position` verbatim. |
| closeDelay | number | 300 | ms grace after the pointer leaves the trigger or the card, long enough to cross the gap between them. |
| disabled | boolean | false | Render the trigger alone, with no card and no listeners. For a trigger that has nothing to preview, such as a deleted user. |
| group | string | — | Shared id for a list of cards (every author avatar on a page): only one is open at a time, and once one is open, moving to a sibling switches at once instead of waiting out `openDelay` again. |
| innerClass | string | "" | Classes for the floating panel. |
| opaque | boolean | false | Force a fully opaque panel, ignoring a globally lowered `--kun-surface-opacity`. See KunPopover's `opaque`. |
| open | boolean | false | Whether the card is open. Bind `v-model:open` to prefetch or track it, or to close it from outside. |
| openDelay | number | 600 | ms a mouse must rest on the trigger, or keyboard focus stay on it, before the card opens. |
| position | KunPopoverPosition | "bottom-start" | Placement relative to the trigger. |
| rounded | KunUIRounded | — | Corner radius of the card. Left unset it follows the app-wide config. |
| showArrow | boolean | false | Render a caret pointing at the trigger. |
事件
| 事件 | 回调参数 |
|---|---|
| update:open | value: boolean |
插槽
| 插槽 | 作用域 | 说明 |
|---|---|---|
| #default | { close: () => void; } | The card. Mounted only while open, so a fetch in its setup runs on open. |
| #trigger | any | The element the card previews, usually a link. The card anchors to its first element. |

