Tooltip component

Display elegant tooltips with kit:tooltip. Fine-tuned customization, accessibility and SEO-friendliness for your Svelte components The kit:tooltip component can be used to display a tooltip on hover, focus or via a controlled opening. It’s designed to provide a simple, accessible way of delivering contextual information to the user, without cluttering up the interface.

kit:tooltip can be used with simple text using the label prop, or with richer HTML content using the tooltip slot.

It is particularly useful for enhancing the user experience by explaining icons, specifying actions or providing secondary details.

tooltip.svelte

kit:tooltip wraps its children in a <span> that listens for mouseenter, mouseleave, focusin, and focusout. The tooltip appears after delayDuration milliseconds (default 850ms) and is positioned fixed via a separate element. Set label for a plain text tooltip, or use the tooltip snippet for rich content.

Examples of tooltip

location

The tooltip can be positioned in four directions relative to the trigger element: top, bottom, left or right. The component will attempt to keep the tooltip within the viewport by flipping its position if necessary (this can be disabled with avoidCollisions).

  • location: 'top' | 'bottom' | 'left' | 'right' = 'bottom'
tooltip.svelte

arrow variant

Add variant="arrow" to render a directional arrow on the tooltip panel.

  • variant: 'arrow' | undefined = ''
tooltip.svelte

Custom content

Use the tooltip snippet to render any content inside the tooltip panel. When tooltip is set, forceMount is enabled automatically and label is ignored.

  • tooltip: Snippet | undefined = undefined
tooltip.svelte

Without preprocess Lapikit

If you aren’t using the Lapikit preprocessor in svelte.config.js, import the components directly:

API Reference

kit:tooltip

propstypedescriptiondefault
labelstringPlain text content of the tooltip.
locationenum'top''bottom''left''right'Preferred position relative to the trigger.'bottom'
variant'arrow'Renders a directional arrow on the tooltip panel.
delayDurationnumberHover delay before the tooltip appears (ms).850
openbooleanControls visibility. Bindable.false
disabledbooleanPrevents the tooltip from showing.false
forceMountbooleanKeeps the tooltip in the DOM when closed.false
avoidCollisionsbooleanFlips position to stay within the viewport.true
densityenum'compact''default''comfortable'Padding density.'default'
roundedenum0'xs''sm''md''lg''xl'Border radius.
colorstringForeground color override (--kit-tooltip-fg).
backgroundstringBackground color override (--kit-tooltip-bg).
tooltipSnippetRich content rendered inside the tooltip panel.
childrenSnippetThe trigger element.

Tooltips complement your Buttons or Icons by providing discreet but useful context for users.