Component

Tooltip

安装 Installation

npx timkit add tooltip --yes --framework react

用法 Usage

import { Tooltip } from "@/components/ui/tooltip"

className 与 variant、size 可以一起用。字段以 timkit agent inspect tooltip --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

12 / 12

Tooltip · Overlay Pattern · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

tooltip

Logic

zag / tooltip

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
tooltipUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/popper, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
use-machineDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
delayDuration
number
700The duration from when the mouse hovers over the trigger until the tooltip opens.
open
boolean
-The controlled open state.
defaultOpen
boolean
-The default open state of the tooltip when uncontrolled.
disabled
boolean
falseWhen true, opening the tooltip is ignored.

Events

PropTypeDefaultDescription
onOpenChange
event
-Event handler called when the open state changes.

Slots

PropTypeDefaultDescription
default
slot
-The tooltip items

Parts

PropTypeDefaultDescription
root*
root
-The tooltip container
trigger
part
-The triggering element
content
part
-The tooltip content
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • Focus opens the tooltip after the delay.
  • Escape or blur closes it.
  • A disabled tooltip stays closed.
  • On the mini program, the trigger is a button and a long press also opens it.
  • A disabled trigger is not in the tab order.
  • An open tooltip is visible as Opened.
  • A closed tooltip has no open status.
  • An open tooltip has the tooltip role.
  • The trigger is described by it while open.
  • A closed tooltip does not describe the trigger.
  • In static HTML, that tooltip stays hidden.
  • On the mini program, a closed tooltip leaves that description off the trigger.

行为契约

Contract

props、默认值和运行时状态。

  • The tooltip opens after delayDuration.
  • The default wait is 700.
  • Focus opens it after that delay.
  • On the mini program, the trigger is a button.