组件
OneTooltip
默认使用 hover-focus 触发,定位器会按可用空间翻转并限制在视口或自定义容器内。
复制链接
查看代码收起代码
import { OneButton, OneTooltip } from '@geektech/one';
new OneTooltip({
content: '复制链接',
placement: 'bottom-end',
children: [{ component: OneButton, children: ['复制'] }],
});示例
new OneTooltip({ content: '复制链接', placement: 'bottom-end', children: [{ component: OneButton, children: ['复制'] }] })12 个方向
top-start, top, top-end, right-start, right, right-end, bottom-start, bottom, bottom-end, left-start, left, left-end。
API
| 名称 | 签名 | 说明 |
|---|---|---|
content | content: VNode | string | 提示内容。 |
placement | placement?: OneOverlayPlacement | 首选方向,空间不足时自动翻转和位移。 |
trigger | trigger?: 'hover-focus' | 'click' | 'manual' | 触发方式。 |
open | open?: boolean | 受控显示状态。 |
defaultOpen | defaultOpen?: boolean | 非受控初始状态。 |
openDelay | openDelay?: number | 打开延迟,默认 100ms。 |
closeDelay | closeDelay?: number | 关闭延迟,默认 100ms。 |
offset | offset?: number | 与触发元素的距离,默认 8px。 |
container | container?: OneOverlayContainer | 自定义挂载与碰撞边界。 |
arrow | arrow?: boolean | 是否显示箭头。 |
disabled | disabled?: boolean | 禁用提示。 |
children | children?: Array<VNode | string> | 必须包含一个 HTMLElement 触发节点。 |
openChange | (open: boolean) => void | 显示状态变更请求。 |
键盘与 ARIA
气泡使用 role=tooltip,打开时通过 aria-describedby 关联触发元素;focus 可打开,Escape 可关闭,并在卸载时恢复原属性。