import React, { ReactNode } from 'react' import Tippy, { TippyProps } from '@tippyjs/react' import 'tippy.js/animations/scale.css' type TooltipProps = { content: ReactNode placement?: TippyProps['placement'] className?: string children?: ReactNode delay?: number show?: boolean maxWidth?: string } const Tooltip = ({ children, content, className, placement = 'top', delay = 0, show = true, maxWidth = '20rem', }: TooltipProps) => { if (show) { return ( document.body} maxWidth={maxWidth} interactive delay={delay} content={ content ? (
{content}
) : null } >
{children}
) } else { return <>{children} } } const Content = ({ className, children, }: { className?: string children: any }) => { return (
{children}
) } Tooltip.Content = Content export default Tooltip