Ant Design Svelte

Tooltip

Text tooltips with positions, arrow, colors and visibility controls.

When to use

Tooltip provides a short, non-interactive explanation of an action or text. The tooltip complements the available name, but should not be the only way to find out what the button does. For buttons, links, and fields within popup content, use Popover.

trigger and hint state

title contains text, value or Svelte snippet. children outputs the actual DOM trigger: a button, a link, or a suitable element of its own component. null and empty title disable explanations; numeric 0 is displayed.

Problem Setting Example
Explain action title, children Brief explanation
Select events trigger Opening
Use your component native control in snippet Your trigger
Manage content cache fresh, destroyOnHidden Cache
Update position bind:ref, forceAlign Recalculation

trigger supports hover/focus/click/contextMenu and an array of events. For the keyboard, provide focus and keep the name of the control itself accessible. mouseEnterDelay/mouseLeaveDelay are measured in seconds; focus/blur delays are configurable separately.

defaultOpen sets the initial opening. bind:open reflects the state of the application, onOpenChange reports the change. Don't count on hover as the only way to open for touch.

Position, pointer and container

placement supports twelve main and corner positions. autoAdjustOverflow can flip the popup; main directions also allow displacement along the edge of the viewport, corner directions remain snapped to the trigger edge. When correction is disabled, the popup may go off the screen.

arrow can be disabled or directed to the center via pointAtCenter. color accepts a preset or CSS color; custom background matches text color based on brightness. With your own semantic colors, check the contrast.

GetPopupContainer selects the popup location in the DOM after hydration. After changing the layout, wait for the tick and call ref.forceAlign(). The method concatenates calls and does not open a private tooltip. An open trigger is also tracked automatically.

Cache, Svelte snippets and design

By default, hidden scalar title is cached. fresh updates it and the semantic container when the popup is closed. The selected snippet can be saved, but its captured Svelte state remains reactive: there is no complete React.memo freezing.

destroyOnHidden removes content while preserving the native shell; forceRender creates hidden content and portal after hydration. These settings apply to the DOM, not to data retrieval or draft storage.

ConfigProvider.tooltip sets its class/style, semantic defaults, trigger, arrow and delays. classNames/styles are styled root/container/arrow; styles - CSS strings. Tooltip design tokens include maxWidth and zIndexPopup. Semantic styles root can override the explicit layer level.

Wrap adjacent buttons in Tooltip.UniqueProvider to move one tooltip between them. The shared popup changes content and position while keeping the same DOM element. Set unique={false} for a separate tooltip. Try the transition.

Your own Svelte component must output a real trigger; React.forwardRef is not needed here. Save its handlers, focus, and accessible name. Leave important information visible in the main page content so that it is not dependent on opening the tooltip.

A non-empty local prefixCls specifies the popup classes and the standard openClassName. The empty string and undefined inherit ConfigProvider.prefixCls with the -tooltip suffix, defaulting to ant-tooltip. Native wrapper, CSS variables and semantic slots preserve names. Example ConfigProvider shows inheritance, local exclusion and separate Tooltips inside Slider.

Examples

Quick tip

Hovering or focusing reveals additional description of the action.

Shared tooltip

Move the pointer or keyboard focus between the buttons.

Opening methods

Hover and focus, normal click and context menu.

12 positions

Twelve positions

Basic and angular positions around the trigger. There is a correction at the edge of the window.

Arrow

A regular arrow, turning it off and directing it to the center of the button.

Automatic offset

Turn on the button at the bottom edge of the window and open the tooltip: it moves to the accessible area.

Changing layout and forceAlign

After changing the button's location, ref.forceAlign is called; an open prompt follows trigger.

Colors

Preset names and custom CSS background colors.

Disable hint

An empty title removes the tooltip, leaving the button itself intact.

Presses: 0

Custom trigger

Svelte component with native button retains action, focus and tooltip binding.

Semantic DOM

The object and function classNames/styles are styled root, container and arrow.

Open: no

Cache and content deletion

Managed open, scalar title, fresh and destroyOnHidden.

General settings

ConfigProvider.tooltip specifies trigger, delay and arrow; local prop specifies the setting.

Component tokens

Local theme changes maxWidth and zIndexPopup.

Popup container

getPopupContainer selects the popup location in the DOM after hydration.

Escape closes the tooltip and maintains focus. At the edge of the window, the position changes automatically.

Tips from the review

Saved example with position settings, arrow and external controls.

API

Tooltip.UniqueProvider lets adjacent tooltips share a single popup.

Topics of official examples
ThemeExample or limitation
BasicHover and focus tooltip.
Smooth TransitionUses the shared surface of the nearest Tooltip.UniqueProvider.
PlacementAll 12 physical directions.
Arrowtrue, false and pointAtCenter.
Auto ShiftReal viewport edge, translation and offset.
Realign after layout changesbind:ref and forceAlign after tick.
Colorful TooltipPreset and CSS colors.
DisabledAn empty title disables the tooltip.
Wrap custom componentDOM trigger inside its own Svelte component.
Custom semantic dom stylingstyles/classNames object and function.
Main parameters
PropertyDescriptionTypeDefault
uniqueUses the shared surface of the nearest Tooltip.UniqueProvider.booleanTooltip.UniqueProvider
motionCSS transition name. An empty string disables animation.{ motionName?: string }zoom-big-fast
afterOpenChangeRuns after a standalone popup finishes its transition.(open: boolean) => void—
prefixClsFull local CSS prefix of popup and standard openClassName; native wrapper and CSS variables are preserved. The empty string and undefined inherit ConfigProvider.prefixCls; default ant-tooltip.stringConfigProvider + -tooltip
hideActionClosing events. [] disables trigger/outside closure, preserving Escape.readonly TooltipTrigger[]trigger
titleText, number, content array or Snippet. Empty content hides the tooltip.TooltipContent—
placementFour main and eight corner directions; left/right physical also in RTL.TooltipPlacementtop
alignPointAnchors the popup to the pointer coordinates.booleanfalse
triggerhover, focus, click, contextMenu; [] leaves external control.TooltipTrigger | readonly TooltipTrigger[]native hover/focus/context
openSupports bind:open; the owner of the managed value accepts the changes.boolean | undefinedlocal state
defaultOpenInitial local state.booleanfalse
onOpenChangeNotification of visibility changes.(open: boolean) => void—
arrowVisibility of the arrow and direction to the center.boolean | { pointAtCenter?: boolean }true
colorPreset or CSS background color; for custom color, the text is selected based on brightness.TooltipColortheme
autoAdjustOverflowPosition correction. adjustX/adjustY accept 0 or 1.boolean | AdjustOverflowtrue
alignAdditional alignment and offset options.TooltipAlignConfig—
mouseEnterDelayHover opening delay in seconds.number0.1
mouseLeaveDelayHover-closing delay in seconds.number0.1
getPopupContainerBrowser-only container selection. The local function takes precedence over ConfigProvider.(trigger: HTMLElement) => HTMLElementnative inline / context
freshUpdates the payload of a private tip; opaque Snippet retains its own reactivity.booleanfalse
destroyOnHiddenRemoves contents when closed, preserving the native shell.booleanfalse
forceRenderMounts hidden content and portal after hydration.booleanfalse
disabledHides popup, keeping trigger and raw open.booleanfalse
idTooltip ID for ARIA communication with trigger.stringstable ID
zIndexExplicit CSS z-index before semantic root styles.numbertheme
classNamesClasses root/container/arrow; object or function.TooltipSemantic—
stylesCSS lines root/container/arrow; object or function.TooltipSemantic—

ConfigProvider and ref

tooltip sets general trigger, arrow, delays, class/style and semantic styles. Local props refine the settings. To open from the keyboard, explicitly enable focus. A nested provider replaces the entire tooltip object; undefined inherits from the parent.

bind:ref returns TooltipRef after mount. nativeElement points to the DOM trigger, including SVG; popupElement - on native span shell. forceAlign updates the alignment without opening the closed tooltip. Binding is cleared upon unmount.

Semantic DOM

Svelte implementation links trigger and surface with role=tooltip via aria-describedby. Popup uses native popover and top layer; by default its shell remains next to trigger. getPopupContainer can transfer it to the selected DOM container after hydration.

SlotPurpose
rootpopup surface, position, layer and maximum width.
containerText, background, padding, radius and shadow.
arrowHint arrow.

classNames and styles accept an object or function with props; styles are set by CSS strings. The content of the tooltip describes the trigger. Place interactive elements in Popover.

Registration tokens

Set zIndex for an explicit layer. A nested tooltip takes its dialog’s layer into account.

Core Component Tokens
TokenPurpose
maxWidthMaximum tooltip width.
zIndexPopupCSS tooltip layer.
Common tokens of the current topic
TokenMeaning
colorBgSpotlightrgba(0,0,0,0.85)
colorTextLightSolid#fff
fontSize14
lineHeight1.5714285714285714
paddingXS8
paddingSM12
sizePopupArrow16
motionDurationMid0.2s

FAQ

Why has the situation changed?

autoAdjustOverflow adjusts the position at the edge of the viewport. The main sides allow flip/shift, the corner sides allow flip.

Why is the closed title not updated?

Scalar payload is cached before opening. fresh updates it immediately; reactivity inside the snippet is not frozen.

When is forceAlign needed?

After changing the layout, you can call it via ref after tick. This method does not open a closed popup.

How to use a custom component?

It should output the real DOM trigger. Save its name, keyboard and custom action.