Tooltip

The Tooltip component displays additional information when users hover over or focus on an element.

Installation

npm install @duskmoon-dev/el-tooltip

Usage

import '@duskmoon-dev/el-tooltip/register';
<el-dm-tooltip content="This is a tooltip">
  <button>Hover me</button>
</el-dm-tooltip>

Live Demo

Tooltip Positions

TopBottomLeftRight

Properties

PropertyTypeDefaultDescription
contentstring-Tooltip text content
position'top' | 'bottom' | 'left' | 'right''top'Tooltip position
trigger'hover' | 'click' | 'focus''hover'How to trigger the tooltip
delaynumber0Show delay in milliseconds
arrowbooleantrueShow tooltip arrow
disabledbooleanfalseDisable the tooltip

Positions

Tooltip Positions

TopBottomLeftRight
<el-dm-tooltip content="Top" position="top">
  <button>Top</button>
</el-dm-tooltip>
<el-dm-tooltip content="Bottom" position="bottom">
  <button>Bottom</button>
</el-dm-tooltip>

Trigger Modes

Trigger Modes

HoverClickFocus
<el-dm-tooltip content="Hover to show" trigger="hover">
  <button>Hover</button>
</el-dm-tooltip>
<el-dm-tooltip content="Click to show" trigger="click">
  <button>Click</button>
</el-dm-tooltip>

With Delay

Delayed Tooltip

Delayed tooltip
<el-dm-tooltip content="Appears after 500ms" delay="500">
  <button>Delayed tooltip</button>
</el-dm-tooltip>

Without Arrow

No Arrow

No arrow
<el-dm-tooltip content="No arrow" arrow="false">
  <button>No arrow</button>
</el-dm-tooltip>

Slots

SlotDescription
defaultThe trigger element

CSS Parts

PartDescription
tooltipThe tooltip wrapper
contentThe tooltip content
arrowThe tooltip arrow

Accessibility

  • Uses role="tooltip" for proper semantics
  • Triggered by focus as well as hover
  • Content is accessible to screen readers