Skip to content

Popover Component

Popover Component

Popover component is used to pop up a lightweight tooltip near an element, which can contain various custom content. It's commonly used for displaying hint information, operation menus, detailed descriptions, etc.

Basic Usage

Basic popover providing both hover and click trigger methods.

The popover component supports both hover and click trigger methods, you can choose the appropriate interaction method based on actual needs.

Show CodeArrow
CopyGitHub

Group Usage

You can apply popover to a group of elements and manage their popup behavior simultaneously.

Apply popover to a group of elements that share the same popup content, suitable for scenarios like button groups.

Button Group Popup

Menu Item Popup

Tip: When a group of elements need to share the same popup content, you can wrap them inside the same t-popover component.

Show CodeArrow
CopyGitHub

Supports four directions for popup: top, right, bottom, left. You can choose the appropriate popup direction based on page space.

The popover supports four directions for popup, you can choose the appropriate popup direction based on page space.

Popup Position

Application Scenarios

  • top: Suitable for scenarios where the button is located in the bottom area
  • right: Suitable for scenarios where the button is located in the left area
  • bottom: Suitable for scenarios where the button is located in the top area
  • left: Suitable for scenarios where the button is located in the right area

Set popup position through the position property

Show CodeArrow
CopyGitHub

Custom Style

You can customize the popover's width, border radius, padding, shadow and other styles.

You can customize the width, border radius, padding, shadow and other styles of the popover to meet different design requirements.

Custom Width and Border Radius

Custom Padding

Custom Shadow

No Arrow Style

Custom Gap

Style Configuration Options:
  • width: Set popover width
  • radius: Set popover border radius
  • padding: Set popover padding
  • box-shadow: Set popover shadow
  • show-arrow: Control whether to show arrow
  • gap: Set gap between popover and trigger element
Show CodeArrow
CopyGitHub

Custom Content

You can customize the popover content through slots, supporting any HTML structure.

The popover supports customizing content through slots, including title, content, and footer areas.

Available Slots

  • default: Trigger element
  • title: Custom title area
  • content: Custom content area
  • footer: Custom footer area
Show CodeArrow
CopyGitHub

Trigger Configuration

Supports multiple interaction configurations such as delayed hiding, close by pressing ESC key, close by clicking other areas, etc.

The popover supports multiple trigger methods, including hover, click, focus, and manual trigger.

Hover Trigger

Click Trigger

Focus Trigger

Manual Trigger

Hover Delay

Trigger Method Properties

  • type: Specify trigger method, options are hover, click, focus, manual
  • hover-delay: Show delay time for hover trigger, in milliseconds
  • hide-delay: Hide delay time for hover trigger, in milliseconds
  • visible: Manually control popover display state (only effective when type="manual")
Show CodeArrow
CopyGitHub

You can add a modal layer to the popover for a more focused interactive experience.

The popover can be configured with a modal overlay to achieve dialog-like effects.

Show CodeArrow
CopyGitHub

Event Handling

Popover provides various events for monitoring mouse enter, leave, state changes, etc.

The popover component provides various events for monitoring mouse enter, leave, display state changes, etc.

Supported Events

  • hover-enter: Triggered when mouse enters trigger element
  • hover-out: Triggered when mouse leaves trigger element
  • model-change: Triggered when popover display state changes
  • open: Triggered when popover opens
  • close: Triggered when popover closes
  • click-model: Triggered when clicking overlay (effective when overlay exists)
Show CodeArrow
CopyGitHub

Popover API

TPopover Attributes

AttributeDescriptionTypeAccepted ValuesDefault
widthPopover widthstring / number
disabledWhether disabledbooleantrue / falsefalse
typeTrigger methodstringhover / click / nonehover
contentDisplay contentstring
radiusBorder radius sizearray / number4
paddingPadding sizearray / number[8, 12, 8, 12]
box-shadowShadow configurationarray
gapGap between popover and trigger elementnumber10
hide-afterHide delay time (ms)number0
positionPopup positionstringtop / right / bottom / lefttop
append-toTarget position for renderingstring / elementbody
auto-positionWhether to auto adjust positionbooleantrue / falsetrue
show-arrowWhether to show arrowbooleantrue / falsetrue
customCustom position coordinatesobject {x: number, y: number}
dialog-animationWhether to use dialog animationbooleantrue / falsefalse
drawer-animationWhether to use drawer animationbooleantrue / falsefalse
close-on-press-escapeWhether to support ESC key closebooleantrue / falsefalse
close-on-press-otherWhether to close by clicking other areasbooleantrue / falsefalse
is-modalWhether to show modal layerbooleantrue / falsefalse
is-modal-nestWhether to allow modal layer nestingbooleantrue / falsefalse

Events

Event NameDescriptionCallback Parameters
click-modelTriggered when modal is clicked
hover-enterTriggered when mouse enters(el: HTMLElement)
hover-outTriggered when mouse leaves(el: HTMLElement)
model-changeTriggered when display state changes
openTriggered when popover opens
closeTriggered when popover closes

Slots

Slot NameDescriptionScope Parameters
defaultElement that triggers popover display
contentPopover content

Style Variables

Variable NameDescription
$popover-bg-colorPopover background color
$popover-text-colorPopover text color
$popover-border-radiusPopover border radius
$popover-shadowPopover shadow
$popover-arrow-sizePopover arrow size
</rewritten_file>

Released under the MIT License