Skip to content

Poptip

Poptip is a lightweight text prompt component primarily used to explain the meaning of interface elements (such as buttons or text) or to provide brief auxiliary information. Compared to Popinfo, it has a smaller footprint, contains no title, features a more compact visual style, and its interaction logic leans toward "point-and-display."

Basic Usage

Component Call

The most standard way to use it is by wrapping the <TuiPoptip> component around the trigger element. Use the content attribute to define the tip text.

vue
<template>
  <div class="demo-box">
    <TuiPoptip content="This is a basic tip">
      <TuiButton>Hover Me</TuiButton>
    </TuiPoptip>

    <TuiPoptip 
      content="Danger Type / Bottom" 
      type="danger" 
      placement="bottom"
    >
      <TuiButton type="danger">Delete</TuiButton>
    </TuiPoptip>
  </div>
</template>

Directive Call

Using the v-tui-popover directive can reduce nesting levels by binding the tip directly to the target element.

Tip: The default appearance for directive calls is 'poptip', so there is no need to explicitly specify the appearance as you would with Popinfo.

vue
<template>
  <TuiButton 
    v-tui-popover="{ 
      content: 'Poptip displayed via directive', 
      placement: 'right',
      type: 'primary' 
    }"
  >
    Directive Trigger
  </TuiButton>
</template>

Visual Styles

Poptip supports the same rich variety of color and tone combinations as Popinfo to adapt to various background depths and semantic scenarios.

Type Semantic Color and Tone

Define semantic colors via type and control tone intensity with tone.

vue
<template>
  <div class="row">
    <TuiPoptip content="Primary Type" type="primary">
      <TuiButton type="primary">Primary</TuiButton>
    </TuiPoptip>

    <TuiPoptip content="Strong Tone" type="success" tone="strong">
      <TuiButton type="success">Success Strong</TuiButton>
    </TuiPoptip>
    
    <TuiPoptip content="Invert Tone" type="warning" tone="strongInvert">
      <TuiButton type="warning">Warning Invert</TuiButton>
    </TuiPoptip>
  </div>
</template>

Frosted Glass Effect

Enabling transparent and backgroundBlur creates a translucent effect with background blur. This usually works best with tone="weak" to present a refined visual texture.

vue
<template>
  <TuiPoptip 
    content="Glass Effect Poptip" 
    :transparent="true" 
    :backgroundBlur="true"
    tone="weak"
  >
    <TuiButton>Frosted Effect</TuiButton>
  </TuiPoptip>
</template>

Functional Call

In scenarios where DOM binding is not possible (such as Canvas drawing areas, interactions within chart elements, or asynchronous operation feedback), you can use the globally injected $tPopover method to manually trigger the tip.

vue
<script setup>
import { inject } from 'vue'

const $tPopover = inject('$tPopover')

const openManualPoptip = (event) => {
  $tPopover({
    event: event, // Must pass the event object or target DOM for position calculation
    // appearance: 'poptip', // Defaults to poptip, can be omitted
    content: 'This is a Poptip called dynamically via JS',
    type: 'info',
    trigger: 'click', // Functional calls usually pair with click or manual logic
    showTrigger: true // Displays the click ripple animation
  })
}
</script>

<template>
  <div class="manual-area" @click="openManualPoptip">
    Click this area to trigger functional Poptip
  </div>
</template>

API Reference

Props

PropertyDescriptionTypeOptional Values (Full List)Default
contentTip contentString
placementPopup positionString'top', 'top-start', 'top-end', 'right', 'right-start', 'right-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end''top'
typeSemantic typeString'default', 'invert', 'primary', 'success', 'warning', 'danger', 'info', 'emphasis'null
toneTone intensityString'base', 'weak', 'strong', 'strongInvert', 'extremeInvert''base'
shadowColorShadow intensityString'weakest', 'weaker', 'weak', 'base', 'strong', 'stronger', 'strongest', 'match''weak'
triggerTrigger methodString'hover', 'click''hover'
appearanceAppearance mode (for directive/functional calls)String'poptip', 'popinfo''poptip'
offsetOffset distance (px)Number8
showArrowWhether to show arrowBooleantrue
enterableWhether the mouse can enter the tip interiorBooleanfalse
autoCloseWhether to close automatically when clicking outsideBooleantrue
transparentWhether to enable background transparencyBooleantrue
backgroundBlurWhether to enable background blurBooleantrue
disabledWhether it is disabledBooleanfalse
delayDisplay delay (ms)Number500
durationAuto-close time (ms), 0 for persistentNumber0 (persistent) or specific milliseconds3000
hasShadowWhether to display shadowBooleantrue

Slots (Component Mode)

Slot NameDescription
defaultTarget element to trigger the tip

Global Methods

Method NameDescriptionParameters
$tPopoverCreates a Poptip instance(options: Object) => void
$tPopoverCloseAllCloses all instances created via JS/events() => void
$tPopoverDirectiveCloseAllCloses all instances created via directives() => void

Global ESC Monitoring

To provide a unified and elegant keyboard interaction experience, all floating components are deeply integrated with TechUI's global service (TuiService).

The component internally listens to the global EscCounter parameter in real-time. When the user presses the Esc key, the global service updates this counter, and the component, catching this change, automatically triggers the hide logic. This mechanism ensures that no matter how many independent floating layers are on the page, they all respond to a unified close command without the developer needing to manually bind keyboard events.

Positioning Dependencies

TechUI's bubble and popup components rely entirely on the industry-standard Floating UI library for anchor positioning calculations.

This means you do not need to worry about complex geometric calculations; the component automatically handles the following scenarios:

  • Collision Detection (Flip): Automatically flips to the opposite position when the preset position has insufficient space (such as at the edge of the screen).
  • Viewport Correction (Shift): Ensures the bubble always stays within the visible range of the viewport and is not truncated.
  • Precise Offset: Achieves pixel-level precise positioning through the offset property.

You simply specify the desired orientation via the component's placement property, and the remaining complex calculations are handled automatically by the underlying engine.

Released under the MIT License.