Skip to content

Tooltip 文字提示

常用于展示鼠标 hover 时的提示信息。

何时使用

  • 鼠标移入则显示提示,移出消失,气泡浮层不承载复杂文本和操作
  • 可用来代替系统默认的 title 提示,提供一个更好的用户体验
  • 当某个页面元素需要解释或描述时

基本用法

最简单的用法,浮层的大小由内容区域决定。

位置

共有 12 个方向。

主题

Tooltip 组件内置了两个主题:darklight

更多内容

展示多行文本或者是设置文本内容的格式。

触发方式

鼠标悬停、聚焦、点击。

延迟

鼠标移入后延迟出现的时间,单位毫秒。

禁用

Tooltip 可以被禁用。

手动控制

通过设置 visible 属性来手动控制提示的显示。

API

Tooltip Props

参数说明类型可选值默认值
content显示的内容,也可以通过 slot#content 传入string
placementTooltip 的出现位置stringtop/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-endbottom
effect默认提供的主题stringdark/lightdark
visible / v-model:visible状态是否可见booleanfalse
disabledTooltip 是否可用booleanfalse
offset出现位置的偏移量number8
show-after延迟出现,单位毫秒number0
hide-after延迟关闭,单位毫秒number200
show-arrow是否显示 Tooltip 箭头booleantrue
popper-class为 Tooltip 的 popper 添加类名string
enterable鼠标是否可进入到 tooltip 中booleantrue
raw-content是否将 content 作为 HTML 字符串处理booleanfalse
trigger触发方式stringhover/focus/click/manualhover
aria-label屏幕阅读器标签string

Tooltip Events

事件名说明回调参数
before-show显示前触发
show显示时触发
before-hide隐藏前触发
hide隐藏时触发

Tooltip Slots

插槽名说明
defaultTooltip 触发 & 引用的元素
content自定义内容

Released under the MIT License.