chrome

<tc-tooltip>

Hover or focus tooltip anchored to a slotted trigger. Auto-flips when it would overflow. Renders in the top-layer via the popover API.

import "@ra9/tan-compose-kit/tooltip"

Props

NameTypeDefaultDescription
textstring""Short tooltip text. For rich content, use the `content` slot instead.
placement"top" | "bottom" | "left" | "right""top"Preferred side. The tooltip auto-flips to the opposite side if it doesn't fit.
delaynumber200Open delay in milliseconds. Prevents flicker on quick pointer crossings.
offsetnumber8Gap between the trigger and the tooltip, in pixels.
disabledbooleanfalseSuppress the tooltip without removing it from the DOM.

Slots

SlotDescription
(default)The trigger element. Tooltips fire on `pointerenter` and `focusin` of the host.
contentRich tooltip body. Overrides the `text` prop.

CSS variables

VariableDefaultDescription
--tc-tooltip-bgvar(--tc-color-ink, #14171f)Tooltip background.
--tc-tooltip-fgvar(--tc-color-surface, #ffffff)Tooltip text color.
--tc-tooltip-radiusvar(--tc-radius-sm, 6px)Corner radius.
--tc-tooltip-padding6px 10pxPadding inside the tooltip.
--tc-tooltip-max-width240pxWrap text after this width.
--tc-tooltip-shadow0 10px 30px rgba(0, 0, 0, 0.25)Drop shadow.
--tc-tooltip-fontvar(--tc-font-sans, …)Font family.

Examples

Basic

Copy   Delete
<tc-tooltip text="Copy to clipboard"> <tc-button variant="ghost">Copy</tc-button> </tc-tooltip>

Placement

Top Bottom Left Right
<tc-tooltip text="…" placement="bottom">…</tc-tooltip>

Rich content

Use the content slot for tooltips with formatting, multiple lines, or icons. Keep them short — tooltips are for hints, not paragraphs.

Hover for shortcut
Save ⌘S
<tc-tooltip placement="bottom"> <button>Save</button> <div slot="content"> <span>Save</span> <kbd>⌘S</kbd> </div> </tc-tooltip>

Delay

Set delay="0" for instant tooltips on data-dense UIs, or raise it for less aggressive hints.

0ms   200ms   600ms

Accessibility

  • Trigger on pointer hover and on keyboard focus, so keyboard users get parity with mouse users.
  • Esc dismisses while the tooltip is open and the trigger has focus.
  • The tooltip carries role="tooltip". For announceable tooltips, give the trigger an aria-describedby pointing to a labelled live region if you need stronger semantics — the popover model defers to the browser for now.
  • The tooltip auto-flips when its preferred side would push it past the viewport edge.

Theming

<tc-tooltip text="Custom palette" style=" --tc-tooltip-bg: #ffe7b0; --tc-tooltip-fg: #2b1d00; --tc-tooltip-radius: 10px; --tc-tooltip-padding: 8px 12px; " > <tc-button variant="ghost">Hover</tc-button> </tc-tooltip>