logo polydile dile-components

dile-tooltip

Web component to display a configurable tooltip.

Installation

npm install @dile/dile-tooltip

In this package you also will find dile-chip-tooltip component.

Usage

Import the component.

import '@dile/dile-tooltip/dile-tooltip';

Use the component.

<dile-tooltip tooltip="tooltip text" position="top" arrow fadeIn > Text </dile-tooltip>

Properties

The component has the properties bellow:

Styling

Custom propertyDescriptionDefault
--dile-tooltip-background-colorThe background color of the tooltip#e74c3c
--dile-tooltip-widthThe width of the tooltip120px
--dile-tooltip-border-radiusThe border radius of the tooltip6px
--dile-tooltip-paddingThe padding of the tooltip text5px
--dile-tooltip-time-transitionThe time of transition of the animation if fadeIn sets true1s
--dile-tooltip-font-sizeThe font size of the tooltip16px
--dile-tooltip-colorThe text color of the tooltip#fff
--dile-tooltip-text-alignText align for the tooltipcenter

dile-tooltip demos

Default tooltips

<style>
  dile-tooltip {
    color: #777;
  }
</style>
<dile-tooltip tooltip="tooltip text" position="top" fadeIn>I have a top tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="right" fadeIn>I have a right tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="left" fadeIn>I have a left tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="bottom" fadeIn>I have a bottom tooltip</dile-tooltip> 

Arrow tooltips

<dile-tooltip tooltip="tooltip text" position="top" fadeIn arrow>I have a top tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="right" fadeIn arrow>I have a right tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="left" fadeIn arrow>I have a left tooltip</dile-tooltip> | 
<dile-tooltip tooltip="tooltip text" position="bottom" fadeIn arrow>I have a bottom tooltip</dile-tooltip> 

Styled tooltips

<style>
.styled {
  --dile-tooltip-background-color: #cef;
  --dile-tooltip-color: #303030;
  --dile-tooltip-padding: 8px;
  --dile-tooltip-font-size: 1.1rem;
}
</style>
<dile-tooltip class="styled" tooltip="tooltip text" position="top" fadeIn arrow>I have a top tooltip</dile-tooltip> | 
<dile-tooltip class="styled" tooltip="tooltip text" position="right" fadeIn arrow>I have a right tooltip</dile-tooltip> | 
<dile-tooltip class="styled" tooltip="tooltip text" position="left" fadeIn arrow>I have a left tooltip</dile-tooltip> | 
<dile-tooltip class="styled" tooltip="tooltip text" position="bottom" fadeIn arrow>I have a bottom tooltip</dile-tooltip>