Skip to content

Tooltip

Inline tooltip wrapper with configurable placement and hover/click/focus trigger modes.

Live Preview
import '@bnotk/dsx/components/tooltip.js';
<dsx-tooltip content="Helpful context" placement="right">
<button type="button">Hover me</button>
</dsx-tooltip>

Wraps a trigger element in the default slot and shows a positioned tooltip box inside the shadow root.

PropertyTypeDefaultDescription
contentstringTooltip text content.
placement’top’ | ‘bottom’ | ‘left’ | ‘right''top’Controls which side of the trigger receives the tooltip.
trigger’hover’ | ‘click’ | ‘focus''hover’Selects the interaction mode used to show or hide the tooltip.

None.

None.

SlotDescription
defaultThe trigger content rendered inside .trigger.

This element does not expose shadow parts.

  • Hover mode uses mouseenter and mouseleave on the trigger span.
  • Focus mode uses focus and blur; click mode toggles visibility on click.
  • The tooltip box is always in the DOM with role="tooltip" and switches visibility through opacity plus aria-hidden.
  • The host is inline-block and position: relative; placement styles are applied through host attributes.
  • The tooltip starts hidden (opacity: 0) and becomes visible when the reflected _visible attribute is present.
  • Dark tooltip surface uses --ds2-color-main-dark and white text.
  • Padding is 0.375rem × 0.625rem with a max width of 20rem and normal wrapping.