mango-ui-v2/components/Tooltip.tsx

35 lines
760 B
TypeScript
Raw Normal View History

import React, { FunctionComponent, ReactNode } from 'react'
2021-04-16 11:16:31 -07:00
import Tippy from '@tippyjs/react'
import 'tippy.js/animations/scale.css'
type TooltipProps = {
content: ReactNode
className?: string
2021-04-16 11:16:31 -07:00
}
const Tooltip: FunctionComponent<TooltipProps> = ({
children,
content,
className,
}) => {
2021-04-16 11:16:31 -07:00
return (
<Tippy
animation="scale"
2021-04-16 12:07:59 -07:00
appendTo={() => document.body}
maxWidth="20rem"
2021-04-16 11:16:31 -07:00
interactive
content={
<div
className={`rounded p-3 text-xs bg-th-bkg-3 leading-5 shadow-md text-th-fgd-3 outline-none focus:outline-none ${className}`}
>
2021-04-16 11:16:31 -07:00
{content}
</div>
}
>
<div className="outline-none focus:outline-none">{children}</div>
2021-04-16 11:16:31 -07:00
</Tippy>
)
}
export default Tooltip