Component

<dom-tooltip>

custom element

Lightweight tooltip wired through aria-describedby. The bubble appears on hover and focus, and is injected as a sibling element.

Demo

Hover tooltip

Wrap any focusable child — text and placement are attributes on the host.

basic.htmlhtml
<dom-tooltip text="Save your changes" placement="top" delay="120">
	<button
		type="button"
		class="inline-flex h-10 items-center rounded-full bg-primary px-4 text-sm font-medium text-primary-fg hover:opacity-90"
	>
		Save
	</button>
</dom-tooltip>

<script type="module">
	import '@getdom/studio/headless/tooltip.js';
</script>

Usage

Plain HTML

<dom-tooltip text="Save your changes" placement="top" delay="120">
  <button>Save</button>
</dom-tooltip>

Register every <dom-*> in one import: import '@getdom/studio/headless'.

Slots

NameScopeDescription
#(default)The trigger — any focusable element wrapped by the tooltip.

Attributes

NameTypeDescription
textstringTooltip body. Keep it short.
placement'top' | 'bottom' | 'left' | 'right'Position relative to the trigger.
delaynumberOpen delay in milliseconds (default 120).

From dom-tooltip.__doc.attributes.

Events

NamePayloadDescription
dom:showFired when the tooltip becomes visible.
dom:hideFired when the tooltip is dismissed.

Names auto-detected from defineEmits and source emit() calls; payload and description from __doc.events when present.

Keyboard

  • Focus triggerShows the tooltip.
  • Blur triggerHides the tooltip.

Related

See also

← Headless overview