lunaDOM Docs
lunaDOM Docs

lunaDOM is a collection of lightweight, accessible shadowdom based web components built with JavaScript.

v0.0.25

The <luna-tooltip> component displays contextual tooltips with multiple placements and trigger options.

Paths

/lunadom/components/tooltip/tooltip.js REQUIRED
/lunadom/components/button/button.js REQUIRED

Placements

Directional tooltips that adapt to content position.

Top Bottom Left Right

Interactions

Custom triggers and timed behaviors.

Click Trigger Toggle Me
500ms Delay Hover Me
Target ID (Fixed) External Target

Customization

Slots
default - The trigger element (when not using the 'for' attribute).
content - Rich HTML content for the tooltip body.

Attributes
content - Plain-text tooltip content (alternative to slot).
for - ID of an external element to attach the tooltip to.
placement - Where to show the tooltip (top, bottom, left, right). Defaults to 'top'.
trigger - How the tooltip is triggered (hover, click). Defaults to 'hover'.
delay - Delay in ms before showing. Defaults to 0.
offset - Distance in px from the target. Defaults to 10.
open - Present when the tooltip is visible.

CSS Variables
--luna-tooltip-bg - Background color. Defaults to rgba(20,20,20,0.95).
--luna-tooltip-color - Text color. Defaults to #eee.
--luna-tooltip-radius - Border radius. Defaults to 7px.
--luna-tooltip-size - Font size. Defaults to 0.75rem.
--luna-tooltip-padding - Inner padding. Defaults to 0.4rem 0.8rem.

Example Code

<!-- Placements --> <luna-tooltip content="Tooltip on Top" placement="top" > <luna-button>Top</luna-button> </luna-tooltip> <luna-tooltip content="Tooltip on Bottom" placement="bottom" > <luna-button>Bottom</luna-button> </luna-tooltip> <!-- Click Trigger --> <luna-tooltip content="Click to toggle" trigger="click" > <luna-button>Toggle</luna-button> </luna-tooltip> <!-- With Delay --> <luna-tooltip content="Delayed tooltip" delay="500" > <luna-button>Hover Me</luna-button> </luna-tooltip> <!-- External Target --> <luna-button id="target"> Target </luna-button> <luna-tooltip for="target" content="Attached via 'for'" > </luna-tooltip>