Skip to main content

Tooltip

Commonly used to show hint information on hover.

Basic usage​

Placements and triggers
import { LhButton, LhTooltip } from '@lh-ui/react'

export default function Demo() {
return (
<>
<LhTooltip content="Top tip" placement="top">
<LhButton>Top</LhButton>
</LhTooltip>
<LhTooltip content="Click trigger" trigger="click">
<LhButton>Click</LhButton>
</LhTooltip>
<LhTooltip content="Semantic color tip" type="success">
<LhButton>Semantic</LhButton>
</LhTooltip>
</>
)
}

Tooltip Props​

PropDescriptionTypeOptionsDefault
contentTooltip contentstring——
placementPlacementLhTooltipPlacementtop / bottom / left / right (with -start / -end)'top'
triggerTrigger method'hover' | 'click' | 'focus'—'hover'
disabledDisable the tooltipboolean—false
visibleControlled visibilityboolean——
defaultVisibleUncontrolled default visibilityboolean—false
showAfter / openDelayShow delay (ms; aliases of each other)number—0
hideAfter / closeDelayHide delay (ms; aliases of each other)number—0
effectTheme'dark' | 'light'—'dark'
typeSemantic color type (overrides the effect background color)'primary' | 'success' | 'warning' | 'danger' | 'info'——
bgColorCustom background color (overrides effect and type)string——
maxWidthMaximum widthstring | number—'200px'
themeVarsComponent-level theme variablesRecord<string, string>——
sxShorthand layout props (applied to the trigger)SxProps——

Tooltip events​

EventDescriptionCallback signatureVue equivalent
onVisibleChangeVisibility change (fires in both controlled and uncontrolled modes)(visible: boolean) => voidupdate:visible

ref​

forwardRef<HTMLDivElement> — the trigger root element. LhTooltipInstance exposes show() / hide() / toggle().

Simplified controlled mode

Unlike plus, this library has no manual switch: passing visible makes it controlled, and onVisibleChange notifies the outside. See the migration guide.

Collapse on scroll

The tooltip collapses automatically when its trigger scrolls out of the viewport (onScrollOut), preventing a fixed overlay from floating over page content.

Styles​

import '@lh-ui/react/style/tooltip'