Anchor Design System

Tooltip (broken, fix coming soon)1.0

Tooltips display a brief, informative message that appears when a user interacts with an element.

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-spinner';
  defineCustomElement();
</script>
<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip target="#info" text="A mind controlling fungus." />

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip target="#info" text="A mind controlling fungus." />

API

Tooltip

A basic tooltip component.

It has several useful inbuilt features.

1. Stays within viewport. Translating x/y transform and/or changing position if supplied position renders it partially or completely outside viewport.

2. The trigger mouseenter will default to a click trigger if device displaying component doesn't have hover capabilities (tablet, phone, etc....)

Usage

Basic usage

<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip target="#info" text="A mind controlling fungus." />

With a class selector as target. (Only an example. You should prefer unique selectors like id or similar)

<p class="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip target=".info" text="A mind controlling fungus." />

Appear really fast and stay for a loooong time

<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip appearDelay="0" duration="13371337" target="#info" text="A mind controlling fungus." />

Advanced usage

Triggering manually

<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip id="infoTip" target="#info" text="A mind controlling fungus." />
<script>
  document.querySelector('#infoTip').open();
</script>

Custom tooltip content

<p id="info">What is Toxoplasma Gondii?</p>
<anchor-tooltip target="#info">
  <h1>Custom content simply goes inside the anchor-tooltip tag</h1>
  <img src="http://www.placecage.com/200/200" />
</anchor-tooltip>

Properties

PropertyAttributeDescriptionTypeDefault
appearDelayappear-delayTime from trigger event until tooltip appearing.number350
durationdurationHow long before tooltip closes. Only works when trigger is mouseenter.number400
positionposition"bottom" | "left" | "right" | "top"'bottom'
targettargettooltip uses querySelector(target) to select the trigger element.stringundefined
texttextText to display in the tooltipstring''
tooltipIdtooltip-idThe id of the tooltip componentstring`anchor-tooltip-${generateGuid()}`
triggertrigger"click" | "manual" | "mouseenter"'mouseenter'

Methods

close() => Promise<void>

Returns

Type: Promise<void>

open() => Promise<void>

Returns

Type: Promise<void>

Dependencies

Used by

Graph


Built with StencilJS

On this page