1.0.1 • Published 3 years ago

@miraidesigns/tooltip v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Tooltips

Tooltips reveal information when users focus or hover over an element.


HTML

<button class="mdf-button" data-tooltip="This shows a tooltip message">Tooltip</button>

Sass

// Include default styles without configuration
@forward '@miraidesigns/tooltip/styles';
// Configure appearance
@use '@miraidesigns/tooltip' with (
    $variable: value
);

@include tooltip.styles();

TypeScript

import { MDFTooltip } from '@miraidesigns/tooltip';

new MDFTooltip(document.querySelectorAll('[data-tooltip]'));

Implementation

Attributes

Please see the WAI-ARIA page for attributes and best practices regarding tooltips.

NameElementDescription
data-tooltip<any>Tooltip text that will be displayed

Classes

NameTypeDescription
mdf-tooltipParentTooltip element
mdf-tooltip--scaleModifierChange the tooltips scale while fading-in
mdf-tooltip--activeModifierTooltip becomes visible (active)

Events

NameDataDescription
MDFTooltip:active{anchor: HTMLElement, tooltip: HTMLElement}Fires whenever a tooltip gets activated. Includes the anchor and tooltip element
MDFTooltip:hidden{anchor: HTMLElement, tooltip: HTMLElement}Fires whenever a tooltip gets hidden. Includes the anchor and tooltip element

Properties

NameTypeDescription
.anchorsHTMLElement[]Returns an Array holding all anchor elements