Displays concise contextual information on hover, keyboard focus, or touch-friendly tap.
Preview
tooltip.demo.svelte
<scriptlang="ts">import { Tooltip } from'$lib/components/ui/tooltip';</script><Tooltipcontent="Hello! This works with hover, keyboard focus, and touch."class="rounded-lg"> <buttonclass="min-h-11 rounded-lg border border-border bg-muted px-6 py-3 text-lg font-semibold shadow-sm" > Hover or tap me </button></Tooltip>
More examples
Placement
Position the tooltip on any side while collision handling keeps it inside the viewport.
Wrap a single control or element and pass content as text or a snippet. The tooltip opens on pointer hover and keyboard focus, toggles on touch tap, closes on outside interaction or Escape, avoids viewport edges, and keeps a mobile-safe maximum width. Keep tooltip content concise and non-interactive; use a popover for buttons or form controls.
API reference
Prop
Type
Default
Description
content
string | Snippet
required
Content displayed inside the floating surface.
open
boolean
false
Controls whether the interactive surface is open.
side
top | right | bottom | left
top
Preferred side of the trigger where content appears.
align
start | center | end
center
Alignment of floating content relative to its trigger.
sideOffset
number
8
Distance in pixels between the trigger and floating content.
delayDuration
number
300
Delay before the floating content opens in milliseconds.
tapToOpen
boolean
true
Allows touch users to open the tooltip with a tap.
showArrow
boolean
true
Shows the arrow pointing toward the trigger.
disabled
boolean
false
Prevents interaction when enabled.
class
string
—
Tailwind CSS classes applied to the component root.
contentClass
string
—
Tailwind CSS classes applied to the content.
children
Snippet
required
Content rendered inside the component.
Source
These files are included in the registry item and copied into the consuming project.