Skip to content
kitn AI/UI

Tooltip

kai-tooltip

The hint sits above the page, so an icon-only button can still say what it does.

  • Shadow DOM
  • Hover + focus
  • Self-positioning
  • Text or markup hint

Put the trigger in the default slot (any focusable control) and set the hint text. The bubble is portaled inside the shadow root so it is not clipped, and it dismisses on Escape or an outside click. openDelay tunes the hover wait; focus shows it immediately.

<kai-tooltip content="Voice input">
<kai-button variant="subtle" size="icon" icon="mic" label="Voice input"></kai-button>
</kai-tooltip>

openDelay is the hover wait in milliseconds, 600 by default.

A child carrying slot="content" replaces the content text, so a tip can hold a key cap, an icon, or a label with a shortcut in it. The bubble is an inverted surface: it re-expresses the muted, border and foreground tokens on itself, so a kit component inside it adapts instead of reading as a light blob on a dark bubble.

SaveSave changes
<kai-tooltip>
<kai-button variant="outline">Save</kai-button>
<span slot="content">Save changes <kai-kbd keys="Mod+S"></kai-kbd></span>
</kai-tooltip>

Anything a light-DOM child can hold works here, because the bubble is portaled inside the element’s own shadow root: the slotted content sits next to the kit’s stylesheet and tokens. Set content as well to keep a text fallback for the same tip.

SlotModePurpose
injectThe TRIGGER the tooltip describes. The tip text is the `content` prop, or the `content` slot when it carries markup.
replaceThe tip body, replacing the `content` text so it can hold markup such as a `<kai-kbd>`.
PropertyTypeDefaultNotes
theme'auto'Color mode (`auto` follows prefers-color-scheme).
content''The hint text shown on hover/focus of the slotted trigger.
openDelay—Delay (ms) before the tooltip appears on hover. Defaults to 600. Focus shows it immediately regardless.
closeDelay—Delay (ms) before it hides after the pointer leaves. Defaults to 0 (hides immediately).
placement—Preferred placement: `'top' | 'bottom' | 'left' | 'right'` (+ optional `-start`/`-end`). Defaults to `'top'`; flips to stay in view.
open—Drive/observe the open state: `el.open = true` or the bare `open` attribute. Listen for `kai-open-change`.
defaultOpen—Initial open state on mount (uncontrolled seed).
disabled—Turn the tooltip off while keeping the trigger mounted (hover/focus and `show()` no longer open it).
MethodSignatureNotes
(): voidOpen it programmatically (no-op while disabled).
(): voidClose it programmatically.
(): voidFlip the open state (closes while disabled).

This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.

Tooltip