Popover & Tooltip

Popovers & Tooltips display informative text when users hover over, focus on, or tap an element.

Basic Usage

arrowed, placement & trigger Props:

import Spross from 'spross'
<Spross.Popover popup="This is a popup." trigger="hover" placement="topLeft">
topLeft
</Spross.Popover>

Inner scrollable

no more getPopupContainer in the past:

Flip & Shift

This is a popup.This is a popup.
This is a popup.

This is a popup.

Self-adaptive height

combine with autoPlacements to maximize space. It’s very important that flip will be replaced by autoPlacement:

name 1
name 2
name 3
name 4
name 5
name 6
import Spross from 'spross';
const [maxHeight, setMaxHeight] = useState(0);
<Spross.Popover
autoPlacements={['topRight', 'bottomRight']}
size={({ availableHeight }) => {
setMaxHeight(availableHeight - 30);
}}
popupStyle={{ padding: 0 }}
popup={
<div className="w-[200px] overflow-auto scrollbar-custom" style={{ maxHeight }}>
{Array.from({ length: 6 }).map((_, index) => (
<div key={index} className="flex items-center pl-2 h-9">
name {index + 1}
</div>
))}
</div>
}
/>

Controlled

visible & onVisibleChange Props:

import Spross from 'spross'
// true
const [visible, setVisible] = useState(true);
<Spross
popup="This is a popup."
visible={visible}
onVisibleChange={(bool, e, reason) => {
setVisible(bool);
}}
>
controlled
</Spross>

API

PropsDescriptionTypeDefault
arrowedWhether to show the arrowbooleantrue
childrenThe child elementReact.ReactNodeundefined
mouseEnterDelayThe delay time for mouseEnter, unit: s, only effective when trigger="hover"numberundefined
mouseLeaveDelayThe delay time for mouseLeave, unit: s, only effective when trigger="hover"numberundefined
offsetThe offsetnumber | { mainAxis?: number; crossAxis?: number; alignmentAxis?: number | null }undefined
onVisibleChangeThe handler when the display changes(visible: boolean, e?: Event, reason?: OpenChangeReason) => voidundefined
placementThe position of the popup"top" | "left" | "right" | "bottom" | "topLeft" | "topRight" | "bottomLeft" | "bottomRight" | "leftTop" | "leftBottom" | "rightTop" | "rightBottom"top
popupThe content of the popupReact.ReactNodeundefined
popupClassNameThe className of the popup contentstringundefined
popupStyleThe style of the popup contentReact.CSSPropertiesundefined
portalWhether to use portal to render to bodybooleantrue
sizeAdapt to size, the component will push out the available space, and the business side needs to use it by itself(availableWidth: number, availableHeight: number) => voidundefined
triggerThe trigger method"hover" | "focus" | "click"hover
visibleThe outer control whether to displaybooleanundefined
zIndexSet z-indexnumber | stringundefined