Skip to content

Tooltip

A lightweight, high-performance tooltip component based on the industry-leading Floating UI positioning engine.

Basic Usage

Provides 12 placement directions through the `placement` prop.

Basic Usage

Theme

Two built-in themes: `light` and `dark`. Default is `dark`.

Theme Effect

Custom Theme

By setting `effect="customized"` and writing corresponding CSS, you can achieve terminal visual effects.

Custom Theme

Sizes and Styles

Supports custom width, max-height, and long content scrolling.

Sizes and Free Styles

Display HTML Content

The content property can be set as an HTML string, enabled by `raw-content`.

HTML Rendering

Trigger Behavior

Supports hover, click, focus, and contextmenu triggers. Default is `hover`.

Trigger Mode

Advanced Features

Follow Cursor

Follow Cursor

Interactive

Interactive

Use in Nuxt

YhTooltip can be used directly in Nuxt after registering the YH-UI module. Tooltip content and trigger markup render during SSR, while popup positioning and runtime trigger interaction continue on the client after hydration.

Use in Nuxt

FAQ

How to allow space input in a nested Input?

When Tooltip contains an input box, in YH-UI, we ensure interaction logic doesn't interfere with normal input. You can nest it directly.

Nested Input Example

Use `content` slot. Ensure `interactive` is enabled.

Embed External link

API

Props

NameDescriptionTypeDefault
contentDisplay text`string``''`
placementPositioning`TooltipPlacement``'top'`
triggerTrigger mode`TooltipTriggerTooltipTrigger[]`
disabledWhether disabled`boolean``false`
effectTheme style`string``'dark'`
offsetOffset [h, v]`[number, number]``[0, 8]`
show-afterShow delay (ms)`number``0`
hide-afterHide delay (ms)`number``200`
show-arrowWhether to show arrow`boolean``true`
interactiveAllow mouse enter popper`boolean``true`
visibleManual visibility control`boolean | null``null`
raw-contentWhether to render `content` as an HTML string`boolean``false`
follow-cursorFollow mouse cursor`boolean``false`
persistentWhether the popper DOM stays mounted while hidden. When set to `false`, it renders only while visible`boolean``true`
widthPopper width`stringnumber`
max-heightMax height`stringnumber`
scrollableScrollable content`boolean``false`
popper-classCustom popper class`string``''`
popper-styleCustom popper style. At runtime, only object styles are merged; string and array forms are declared but not consumed`StyleValue``{}`
content-classCustom content class`string``''`
content-styleCustom content style. At runtime, only object styles are merged`StyleValue``{}`
arrow-classDeclared arrow class prop. The current template does not consume it`string``''`
arrow-styleDeclared arrow style prop. The current template does not consume it`StyleValue``{}`
arrow-wrapper-classDeclared arrow wrapper class prop. The current template does not consume it`string``''`
arrow-wrapper-styleDeclared arrow wrapper style prop. The current template does not consume it`StyleValue``{}`
z-indexz-index`number``2000`
transitionTransition name`string``'yh-tooltip-fade'`
teleportedTeleport to body`boolean``true`
theme-overridesComponent-level theme overrides`ComponentThemeVars``undefined`

Slots

NameDescription
defaultTrigger element
contentCustom content (overrides content prop)

Events

NameDescriptionParameters
showTriggers when showing`() => void`
hideTriggers when hiding`() => void`
update:visibleVisibility change`(visible: boolean)`

Theme Variables

YhTooltip supports `themeOverrides`. The stylesheet directly consumes the following component-scoped CSS variables:

NameDescriptionDefault
`--yh-tooltip-bg`Background color`var(--yh-bg-color-overlay)`
`--yh-tooltip-border`Border color`var(--yh-border-color-light)`
`--yh-tooltip-text`Text color`var(--yh-text-color-primary)`

Other z-index, font-size, radius, and shadow values still come from shared theme tokens such as `--yh-z-index-tooltip`, `--yh-font-size-sm`, `--yh-radius-md`, and `--yh-shadow-lg`.

Dark Mode

Tooltip automatically switches to dark themes when `html.dark` is present.

Expose

NameDescriptionType
updatePositionManually refresh popper positioning.() => Promise<void> | void
visibleCurrent visibility ref.Ref<boolean>
triggerRefTrigger element ref.Ref<HTMLElement | null>
popperRefPopper element ref.Ref<HTMLElement | null>

Type Exports

NameDescription
YhTooltipPropsComponent props type
YhTooltipEmitsComponent emits type
YhTooltipSlotsComponent slots type
YhTooltipExposeComponent expose type
YhTooltipPlacementPlacement union type
YhTooltipTriggerTrigger union type
YhTooltipInstanceComponent instance type

Released under the MIT License.