AI工具提示生成器。

描述你需要的提示,MeDo会生成完整行为 — 开启与关闭延迟、避开视口边缘的翻转、始终对准触发元素的箭头、键盘焦点触发,以及aria-describedby关联。

工具提示
工具提示

工具提示是三分之一用户永远看不到的那个组件

触摸屏上不存在悬停。手机上没有任何手势能可靠地表达"给我看说明,但别激活这个控件",这意味着每个工具提示对相当大比例的流量而言都是不可见的。仅这一点,就在争论开始前解决了大多数关于工具提示的设计分歧:工具提示只能承载用户并不需要的信息。字段填写要求、错误提示、价格附加条件,以及纯图标按钮的含义,都必须放在可见的位置或写进无障碍名称里。把工具提示当作一个本身就能正常工作的界面之上的锦上添花,无障碍方面的问题大多会自然而然地有了答案。

6 个模板

可以生成的 工具提示 模板

每个模板都是真实的提示词,而不是截图。复制到任意 AI 编辑器,或在 MeDo 中运行,直接拿到 React + Tailwind 代码。

BasicLabel Hint

Dark Panel Hint on Hover and Focus

The default tooltip: one line of plain text, dark panel, arrow, delays in both directions. Reach for it when a control is already named and you only want to add a detail a mouse user might appreciate.

Create a tooltip component that wraps a single trigger child and renders a short plain-text hint on pointer enter and on focus-visible. Use a dark slate panel with 13px white text, 6px vertical and 10px horizontal padding, a 6px radius, a 240px max width and an 8px offset from the trigger, plus a 6px arrow aimed at the trigger. Open after a 300ms delay and close after 100ms so the pointer can cross the gap without the panel vanishing. Dismiss on Escape, on blur and on scroll. Give the panel role="tooltip" and link it to the trigger with aria-describedby only while it is open, rather than leaving hidden markup in the tree. Fade and translate 4px on entry, and drop the transition entirely under prefers-reduced-motion.

在 MeDo 中尝试
Icon-onlyIcon Button

Tooltip as the Only Label a Control Has

When the icon is the whole button, the tooltip text is the accessible name — not a description. Getting that distinction wrong is why so many toolbars announce the same word twice.

Create a tooltip for an icon-only button where the tooltip text is the only name the control has. Put that string in aria-label on the button and do not also set aria-describedby, so the same words are not announced twice. The visible panel exists for sighted pointer users: dark surface, 12px text, a single line that does not wrap under 200px. Open on hover after a 400ms delay but open immediately on focus-visible, since a keyboard user has already committed to the control. Close on Escape, on blur and on pointer leave. Keep the button hit area at least 44px even when the glyph is 20px, and skip rendering the panel entirely when a coarse pointer is detected.

在 MeDo 中尝试
CollisionAuto Flip

Edge-Aware Placement With a Tracking Arrow

Handles the case a fixed side always breaks: a trigger near the top of a scroll container or the right edge of the viewport. The arrow has to re-anchor after the flip or it points at nothing.

Create a tooltip with collision-aware placement: a preferred side prop of top, bottom, left or right, an explicit fallback order, and shifting along the cross axis when the panel would overflow the viewport or the nearest scrolling ancestor. Add a 6px arrow that re-anchors to the trigger centre after any flip or shift, clamped so it never slides past the panel corner radius. Recompute position on scroll and resize behind a requestAnimationFrame throttle, and close rather than reposition once the trigger leaves the visible area. Keep the aria-describedby relationship stable across repositioning so the description is not re-announced. Use role="tooltip" and plain text content with no interactive children.

在 MeDo 中尝试
ToolbarGroup Skip

Shared Delay Across a Button Row

One provider, one timer. Once the first tooltip in a toolbar has opened, moving along the row should switch content instantly instead of making the user wait 300ms per button.

Create a tooltip provider that shares open state across a group of triggers in a toolbar. The first tooltip in the group waits the full 300ms open delay; while any tooltip in the group is open, moving to a sibling trigger swaps the content with no delay and no exit animation, so the panel appears to slide along the row. Leaving the group entirely closes after a 150ms grace period. Reuse a single positioned panel element rather than mounting one per trigger, and update its aria-describedby target as the active trigger changes. Escape closes the group and returns focus behaviour to normal. Under prefers-reduced-motion, replace the slide with an instant content swap.

在 MeDo 中尝试
Multi-lineRich Hint

Two-Line Tooltip With a Keyboard Shortcut

A label line plus a monospace shortcut hint on the right. Still passive, still text-only — the moment you want a link in here, you want a popover instead.

Create a tooltip that renders a label line plus a secondary line, with an optional keyboard shortcut rendered as a small monospace chip aligned to the right of the label. Cap the panel at 260px, allow the description to wrap to two lines, and keep line-height at 1.4 so the two lines read as one block. Content stays non-interactive: no links, no buttons, no selectable code — if the user needs to click inside, use a popover. Announce the whole panel as one description via aria-describedby so the shortcut is read as part of the sentence rather than as a separate node. Open after 300ms, close after 100ms, dismiss on Escape and blur.

在 MeDo 中尝试
OverflowTruncation

Tooltip Only When the Text Is Clipped

Table cells and file names truncate with an ellipsis; a tooltip that repeats already-visible text is noise. Measure the element and only attach the tooltip when scrollWidth exceeds clientWidth.

Create a conditional tooltip for truncated text: compare scrollWidth against clientWidth on the target element and only register hover and focus handlers when the text is actually clipped, so a fully visible cell never shows a tooltip repeating itself. Re-measure on resize and whenever the text content changes, using a ResizeObserver rather than a window listener. When active, show the full string in a dark panel capped at 320px with wrapping enabled, positioned below the cell to avoid covering the row header. Make the truncated element focusable with tabindex="0" only while the tooltip is registered, so keyboard users can reach it without collecting empty tab stops across the whole table.

在 MeDo 中尝试

如何自定义你的 工具提示

分别设置开启与关闭延迟

共用一个延迟在两个方向上都不对。开启前约300ms可避免指针经过工具栏时提示闪烁,而100ms的短暂关闭延迟能让指针从触发元素移动到提示面板,而不会中途消失。

要求碰撞检测,而不是固定方向

固定显示在上方的提示会被视口顶部或滚动容器边缘裁切。指定首选方向加备选方向,让组件自行翻转和平移,并说明移动后箭头仍需指向触发元素。

要求焦点也能触发,而不只是悬停

如果提示只响应鼠标,键盘用户就什么也得不到。要求在focus-visible时打开,在Escape和blur时关闭,这同时也让使用开关设备或屏幕阅读器的人能够使用它。

内容保持被动且仅为文本

一旦工具提示里放了链接、按钮或可复制的文本,就需要一种能到达它并让它保持打开的方式,它也就不再是工具提示了。明确说明内容是纯文本且不可交互,需要在里面放可点击元素时改用弹出层(popover)。

谁在使用 工具提示 组件

仪表盘或管理后台

纯图标的工具栏按钮带有真正的无障碍名称,再加一个为使用鼠标的视力正常用户重复标签的工具提示;指针在相邻按钮之间移动时跳过开启延迟。

SaaS产品

图表图例上的提示,解释某项指标如何计算;靠近面板顶部时翻转到触发元素下方,并在滚动时关闭,绝不会脱离所描述的位置悬浮在页面上。

电商店铺

尺码表缩写和配送标识图标在悬停时给出注解,同时在商品页的正文中重复相同信息,因为手机购物者永远不会触发悬停。

开发者文档

行内代码标记和缩写在悬停或获得焦点时显示一行类型签名,并限制较窄的最大宽度,让面板绝不会遮住它正在解释的代码示例。

不同网站的 工具提示 方案

同一个 工具提示 组件,针对它所在网站的类型做调整。

01 / 06

Dashboard and Admin Tools

Dense toolbars are where tooltips earn their keep and where a per-trigger delay is most annoying. Use one shared provider so moving along a row of icon buttons swaps the label instantly. The tooltip still cannot be the only place the label exists — every icon button needs a real accessible name regardless.

工具提示 的风格与变体

挑选与页面其余部分匹配的变体,然后生成它。

01 / 06

Dark Panel Tooltip

A dark slate surface with white text is the default for a reason: it reads as an overlay rather than as page content, so users do not mistake it for a permanent part of the layout. Keep the panel opaque — a translucent tooltip over a chart becomes unreadable exactly where it is needed.

在 React、Next.js、Vue 与 Svelte 中使用 工具提示

React、Next.js、Vue 3、SvelteKit、Astro 或纯 HTML —— 同一个 工具提示,六种接入方式。

01 / 06

React Tooltip

Positioning needs real DOM measurement, so this is a client component with refs on both trigger and panel. Portal the panel to document.body — a tooltip inside a container with overflow: hidden will be clipped no matter how correct the coordinates are.

src/components/Tooltip.tsx

export function Tooltip({ label, children }) {
  const [open, setOpen] = useState(false)
  const id = useId()

  return (
    <span
      onPointerEnter={() => setOpen(true)}
      onPointerLeave={() => setOpen(false)}
    >
      {cloneElement(children, { 'aria-describedby': open ? id : undefined })}
      {open && createPortal(<Panel id={id}>{label}</Panel>, document.body)}
    </span>
  )
}

如何把 工具提示 加入项目

四个步骤,从挑选 工具提示 模板到上线生产环境。

01~30s

Pick a Tooltip Pattern

Choose by what the trigger already tells the user: a label hint for a named control, the icon-only variant when the tooltip text is the accessible name, or the truncation variant for table cells.

02~10s

Copy the Prompt

Take it into MeDo, Lovable, Bolt, v0 or Cursor, and set the open and close delays before you run it. Those two numbers are what separates a helpful hint from a panel that flickers across a toolbar.

03~1min

Generate and Refine

You get React + Tailwind back with a live preview. Follow up in plain English — "flip below near the top edge", "open instantly on focus", "skip the delay between toolbar buttons" — rather than editing coordinate math by hand.

04~2min

Wire the Triggers and Test the Keyboard

Portal the panel out of any overflow-hidden ancestor, then tab to each trigger and press Escape. If the hint only appears on hover, or Escape does not close it, the component is not shippable yet.

关于 工具提示 的常见问题

如何用AI生成工具提示组件?

在一个提示词里描述触发元素、显示位置和时间设定 — 例如"触发元素上方的深色工具提示,300ms开启延迟,碰到视口边缘时翻转,获得焦点时也打开"。MeDo会一并生成定位逻辑、箭头、延迟和aria-describedby关联,因此得到的是完整的交互行为,而不是一个加了样式的绝对定位div。

工具提示和弹出层(popover)有什么区别?

工具提示是被动的:它显示你所指向元素的简短文字说明,指针离开就关闭,且不包含任何可点击内容。弹出层是交互式的:点击打开,保持展开,可容纳链接、按钮或表单字段,并会捕获或管理焦点。如果你发现自己想在工具提示里放一个按钮,那你要的其实是弹出层。

工具提示应该用aria-describedby还是aria-label?

当触发元素已经有可见名称或无障碍名称,而工具提示提供补充细节时,使用aria-describedby,因为描述会在名称之后播报。当工具提示文字是该控件唯一的名称时(例如纯图标按钮),使用aria-label,并在这种情况下省略aria-describedby,以免同一段文字被播报两次。

工具提示能在触摸设备上使用吗?

并不可靠。触摸屏没有悬停状态,长按又已被文本选择和上下文菜单占用,因此任何"点击显示提示"的模式都在与平台对抗。请假定手机和平板用户永远看不到它,把所有关键信息放在可见文案或无障碍名称中。

工具提示打开前的延迟应该设多久?

大约200到500ms效果较好,300ms是稳妥的默认值。这个延迟的作用是避免指针在前往别处、途经一排控件时让提示不断闪烁。请搭配一个短得多的关闭延迟(约100ms),这样指针朝提示移动时面板不会消失。

工具提示需要可以用键盘关闭吗?

需要。WCAG要求悬停或获得焦点时出现的内容能够在不移动指针和焦点的情况下被关闭,实际做法就是按Escape关闭。它还必须保持足够长的可见时间以供阅读,并且可以被悬停,以便指针移动到它上面。在提示词中提到键盘支持,MeDo就会接好Escape、blur以及悬停桥接行为。